Sublime Text 3 and git gutter icons

One of the features from Netbeans that I misses the most is the way, how it marked and handled changes to source code directly in code editor.

There’s no way, you’re going to have the same in Sublime Text 3. Simply, because ST3 API limits implementing of such behavior. So, you have to accept, that you’ll get much less usable tool instead.

Modific

There are many plugins for either “git” or “changes” query in Package Control repository. I decided to use “Modific“, because:

  • it offers not only a gutter icons, but also a bunch of useful keyboard shortcuts,
  • in my opinion it is closest to Netbeans
  • it’s author is former Netbeans-user, who misses this feature as much as I do :]
  • it shows changes between current state of file and committed changes / changes pushed to remote only after saving currently edited file.

Thus, it doesn’t show any performance limitation, while other vcs-gutter-like plugins does on-the-fly compare and can slow down noticeable even as fast-and-furious IDE as Sublime Text 3.

Modific is, what it is. It was meant to provide git gutter icons and that is all. It does not offer anything else. For example, as for git diff, it only displays raw effect of executing this command (great, that it does at least this, as other gutter icons plugins doesn’t even have this).

If you need something more, for example — professional diff, compare and merge — you need something different. Like, for example Sublimerge Pro plugin. It gives you a complete power of git and complete control over it. But, you have to pay for this a one-time fee of $25. Visit plugin’s homepage for details on this.

Installation

Installation of Modifc, using Package Control, is a snap. After restarting Sublime Text 3 and opening any version-controlled file, you should be able to see any changes marked on gutter with: diamond (changed line), left-pointing triangle (removed line) or right-pointing triangle (inserted / added line).

You can change colors used by gutter icons. See plugin webpage for details on this.

Keyboard shortcuts

Here is the list of keyboard shortcuts for Modific:

  • Ctrl+Shift+Page Down and Ctrl+Shift+Page Up to browse through through changed lines,
  • Ctrl+Alt+D to show standard git diff for current file in separate tab,
  • Ctrl+Alt+C to preview committed code for current line,
  • Ctrl+Alt+R to revert changes for current line,
  • Ctrl+Alt+U to view all uncommitted files in a quick panel.

The Ctrl+Alt+D shortcuts uses git diff command, so you have to have path to your Git interpreter (i.e. C:\Program Files (x86)\Git\bin) added to your system PATH or else this will fail.

This is specially important on Windows, as on Linux and MacOS, it usually is properly configured. Also note, that if you find this to not working, because of missing path to Git in your PATH, and if you fix this, you have to restart Sublime Text 3, before Modific plugin starts to “see” this change.

If you’re using Polish keyboard (or any other, that uses language specific characters), note, that Modific’s default key bindings interfere with certain Polish national characters, because Sublime Text 3 doesn’t make any difference between pressing Right Alt and Ctrl+Left Alt. This is a classic bug, found in many editors, that makes life of non-Latin alphabets users just a little bit nightmare.

If you want a workaround for it, you must paste these two keyboard shortcuts to user key bindings file:

{ "keys": ["ctrl+alt+c"], "command": "insert_snippet", "args": {"contents": "ć"} },
{ "keys": ["ctrl+shift+alt+s"], "command": "insert_snippet", "args": {"contents": "Ś"} },

This will solve a problem, but disable Ctrl+Alt+C shortcut used to preview committed code for current line. You need to define a new key binding for it or stop using this keyboard combination.

Final words

If you’re using Git, but don’t like Modific, you may consider highly rated (many downloads) “GitGutter“. I tried it, but it had strange icons issues in my installation of ST3 and it doesn’t have any of above handy keyboard shortcuts and functions.

And, if you’re using different VCS, then “VCS Gutter” might be for you. It is a “friendly fork” of GitGutter.

Leave a Reply