A sublime text 2/3 plugin to show an icon in the gutter area indicating whether a line has been inserted, modified or deleted.
You can install via Sublime Package Control:
- GitGutter - Release based
- GitGutter-Edge - Stick with master branch (at your own peril)
Or you can clone this repo into your Sublime Text x/Packages:
OSX
cd ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/
git clone git://github.com/jisaacks/GitGutter.git
Ubuntu
cd ~/.config/sublime-text-2/Packages
git clone git://github.com/jisaacks/GitGutter.git
Windows
GitGutter assumes that the git
command is available on the command line. If it's not, add the directory containing git.exe
to your PATH
environment variable. Then clone the repo:
cd "%APPDATA%\Sublime Text 2\Packages"
git clone git://github.com/jisaacks/GitGutter.git
By default, Git Gutter compares your working copy against the HEAD. You can change this behaviour through the ST command palette. The following options are available:
- Compare against HEAD
- Compare against particular branch
- Compare against particular tag
- Compare against specific commit
To change the compare option:
- Open the command palette (
Ctrl-Shift-P
for Windows/Linux,Cmd-Shift-P
for Mac) - Start typing
GitGutter
- You'll see the 4 options listed above, select one with the keyboard.
- Choose the branch/tag/commit to compare against.
Settings are accessed via the Preferences > Package Settings > GitGutter menu.
Default settings should not be modified, as they are overwritten when GitGutter updates. Instead, you should copy the relevant settings into GitGutter's user settings file.
By default, GitGutter runs in the same thread which can block if it starts to perform slowly. Usually this isn't a problem but depending on the size of your file or repo it can be. If you set non_blocking
to true
then GitGutter will run in a seperate thread and will not block. This does cause a slight delay between when you make a modification and when the icons update in the gutter. This is a Sublime Text 3 only feature, ST2 users can turn off live mode if performance is an issue.
When using non_blocking mode, delay update of gutter icons by the following amount (in milliseconds). Useful for performance issues. Default 1000 (1 second).
By default, GitGutter detects changes every time the file is modified. If you experience performance issues you can set it to only run on save by setting live_mode
to false
.
GitGutter shows icons for new files and ignored files. These icons will be on everyline. You can toggle the setting show_markers_on_untracked_file
to turn this feature off. Defaults to true (shows icons). You may need to add scopes to your color scheme (markup.ignored.git_gutter
and markup.untracked.git_gutter
) to color the icons.
If git is not in your PATH, you may need to set the git_binary
setting to the location of the git binary, e.g. in a portable environment;
{
"git_binary": "E:\\Portable\\git\\bin\\git.exe"
}
Sublime Text supports project-specific settings, allowing live_mode
to be set differently for different repositories.
To implement, use the Project > Edit Project menu and add the settings
key as shown.
{
"folders":
[
{
"path": "src"
}
],
"settings":
{
"live_mode": false
}
}
The colors come from your color scheme .tmTheme file.
Color schemes that already have support for GitGutter include:
- Dark Room
- Deep Blue See
- Flatland
- Monokai Extended
- Perv
- Tomorrow Theme
- Neon Color Scheme
- Underscore Colour Theme
- Solarized Colour Theme
- Baara Dark
- Specials Board
- Oblivion
- Glacier
- Neon
- Afterglow
- Desert Night
- Cobalt2
- Contact me if you want your color scheme listed here. Or do a pull request.
If your color scheme file does not define the appropriate colors (or you want to edit them) add an entry that looks like this:
<dict>
<key>name</key>
<string>GitGutter deleted</string>
<key>scope</key>
<string>markup.deleted.git_gutter</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#F92672</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>GitGutter inserted</string>
<key>scope</key>
<string>markup.inserted.git_gutter</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#A6E22E</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>GitGutter changed</string>
<key>scope</key>
<string>markup.changed.git_gutter</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#967EFB</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>GitGutter ignored</string>
<key>scope</key>
<string>markup.ignored.git_gutter</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#565656</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>GitGutter untracked</string>
<key>scope</key>
<string>markup.untracked.git_gutter</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#565656</string>
</dict>
</dict>
There are commands to jump between modifications. The default keybindings for these commands are:
OSX
prev: command + shift + option + k next: command + shift + option + j
Windows
prev: ctrl + shift + alt + k next: ctrl + shift + alt + j
Don't use Sublime?
Don't use Git?