Hacking the cocoa text system to accept vi commands…
It starts out in input mode (unlike vi, which starts in command mode) and you hit the backtick key (instead of the escape key) to invoke vi command mode. You can set it to use the escape key but apparently that’s used for other things in OS X.
It’s still in a fairly early beta and only has a small subset of vi commands, the most common ones.
I came across this just the other day and was ecstatically amused! I had to change the default key assignment right away, though. I suppose I use the back-tick far more than most people. I found a simple KeyBindings file a long time ago with some Vi commands, but it was very limited because it lacked the plug-in component. It was modal, but only a few commands (what Cocoa itself can handle) were available.
It cannot yet handle one of my favourite tricks: 60i-
Ultimately, I found it interesting, but command support was sparse enough to make it frustrating rather than useful. Also, it does not work with TextMate because that program does not use the Cocoa text system, it has its own text system – and that is probably the one place where I would most like vi commands. No fault for either part, just … sigh. So close!
Typing a number before a command tells Vi to perform that command x number of times. For example, ‘3dw’ will delete the next three words after the cursor. 3 times, delete, word.
60i- tells Vi to do the command sixty times. The command is insert to enter text, in this case a single dash; and then to leave insert mode and initiate the numbered executions: Sixty dashes!
That serves me right. I use aquamacs (OS X emacs …err…variety) but only skimmed the surface of what it does editor-wise. It does one thing exceptionally well, however, it specializes in reconstruction of molecular structures. Honest.
if we could really get all cocoa input boxes to default to vim-style (and i mean go straight into command mode, not input mode, which is probably the biggest and most effective difference), I would be deliriously happy. But right now it’s true that the vim input manager is kind of a toy; it lacks the flexibility and featureset of vim, and as long as you need to press a special key to go INTO it, rather than go OUT of it, the built in cocoa controls will probably be more useful.