Vintage Mode in Sublime Text
Will is one of my colleague at iMarc, and an avid Sublime Text 2 user. He’s written a number of plugins for it now, and every once in a while vintage mode comes up.
Vintage mode is an ‘official’ plugin that’s bundled with ST2 itself which tries to add many vi behaviors to ST2. The first couple times I tried it, I found short comings within 2-3 minutes and this time it took 5, so it’s slowly getting better. Anyone who had used vi or vim (or gvim/macvim) for a while will probably notice these.
These are all command mode or visual mode commands, as that’s all Vintage mode claims to affect. There’s certainly a number of ex and insert commands which I would sorely miss as well.
The lists below are by no means exhaustive, just commands that I use fairly often and recalled from memory.
- h, l (left and right) - already found differences. h and l don’t ‘wrap’ around the beginning and the end of the line in vim, and in Sublime, they do. If you think this is an irrelevant difference, think of using multi-selections to edit a bunch of lines at once. vim is very mindful of what commands will cause line changes and which ones won’t, and I think this ties into making sure that macros are more robust or degrade more smoothly.
- 0, ^, $ (first character, first non-blank character, last character) - these all seem to be consistent.
- g^, g$ (first character of the visual line, last character of the visual line) - these don’t seem to exist. It’s interesting that Sublime implemented the ‘true’ line operations here and didn’t implement the visual line operations, whereas in other places, Jon did the opposite.
- f{char}, F{char}, t{char}, T{char} (go to the next/previous character, go up to the next/previous character) - these all seem to be working correctly.
- ; and , (repeat last f, F, t, or T command) - all seem to work.
- {column}| (goes to column {column} in the current line) - not implemented.
Vim Left-Right Motions
- j, k (up and down) - in vim, j and k do their best to move to the same column in the previous line. In Sublime, j and k move to the same visual column and may only change visual lines. The ‘visual line down’ and ‘visual line up’ commands do exist in vim too, they’re just gj and gk respectively.
- gg, G (first line and last line) - seem to work.
- +, - (goes to first character of next/previous line) - don’t exist.
Line Motions
- w, W, b, B - these all seem consistent. For those that don’t know, w moves your caret to the next first character of a word (like ctrl-right/cmd-right.) Similarly, b moves your caret to the previous first character of a word. W/B are nearly the same, but they work on WORDs instead of words, where a WORD in vim is a string of any non-whitespace characters.
- e, E, ge, gE - these are very similar to w/W/b/B, but instead of going to the first character, they go to the last character of a word or WORD. e/E seem to work fine, but it looks like Sublime is lacking ge or gE entirely.
- cw/cW - this is an inconsistency in vim (maybe even a bug originally), where cw should have included the space(s) after the current word, but instead, cw and cW were changed to behave identically to ce and cE. All things considered, its extremely rare that anyone would have actually wanted the correct behavior, but it is still a little strange, as similar commands like dw and vw do not behave the same as de and vw. Still, Sublime decided to implement this to be consistent with vim, so all is well.
Word Motions
- viw,vaw,vaW,viW (select word/WORD without or with whitespace) - these seem to work.
- vit, vat (select inside tag, inside tag and tag) - these don’t seem to be implemented.
- vi’, va’, vi”, va” (select inside single/double quotes without or wite whitespace) - these seem to work.
Text Selection
I didn’t test clipboard/registers very much, but I did want to note that while it appears that dd (delete line) works fine, pasting the line back doesn’t correctly preserve newlines. ddp should just swap two lines, whereas in sublime I have to ddpi<enter><esc>. Another nicety would be for Vintage mode to change some global keybings, like <ctrl-r> to redo.