current: version 0.3.1 released 2 february 2007

Vi Input Manager
by: Jason Corso

This bundle patches the Cocoa Text System to add a Vi-like command mode. After entering command-mode (typically, by hitting escape in Vi), ordinary Vi commands can be typed and the text field will be updated accordingly. Essentially, this add Vi command functionality (albeit a small subset) to any (and all) text editors that use the Cocoa text system; e.g., Safari, TeXShop, XCode, etc. Note, however, this does not work for other programs that do not use the Cocoa system.

All the text windows, will initialize in "input" mode (standard cocoa text input). You invoke the Vi-command window (exit the input mode) by hitting ` (the back-apostrophe key, this is customizable, see installation instructions) and then key in your favorite Vi commands. For example, move down a line 'j', move right 'l', delete two lines 'd2d', and so on. You enter back into "input" mode by typing the 'i'. You get the idea. Right now, you should be thinking -- "you mean the editor in XCode will behave like Vi?" Answer: Yes.

News
  • 2 Feb. 2007 - Minor Release 0.3.1 that improves placement, sizing, and feel of the window. Fixed dw and added d$.
  • Oct. 2006 - Thanks to the many donators. They really help give me the time to spend on projects like this one.
  • 31 Oct. 2006 - Feature/Bugfix Release 0.3. Added (cw,dl,dh,dj,dk,:w)
  • 29 Sept. 2006 - Feature/Bugfix Release 0.2. Added (A,I,O,G,#G,r*) and fixed bugs with multiline delete and insert on new line.
  • 24 Sept. 2006 - A bugfix patch for 0.1 is available here. This fixes the delete word bug posted to the forums by jbaty. The zip contains only the plugin and should be unzipped directly into your Library/InputManagers folder. This fix will be incorporated into the next release 0.2.
  • 23 Sept. 2006 - Feature Release: 0.1 Addition of search functionality.
  • 23 Sept. 2006 - I installed the forums to make it easy to disseminate release announcements, encourage bug posting, feature requests and general discussion about the Vi Input Manager.
  • 21 Sept. 2006 - Initial release of version 0.0. Check back regularly for updates; releases will come rapidly with enhancements.
Download

Version 0.3.1 is a Universal Binary: [here].
Please note that I only have access to a powerpc mac and cannot test it on an Intel architecture (hint!), but it has been independently verified to work on Intel macs.

Vi Commands Supported

Only a subset of Vi functionality is currently implemented; but it is enough to give you the gist of what is possible. This list is growing...

Key(s) Action Since
{ move to beginning of previous paragraph 0.1
} move to beginning of next paragraph 0.1
$ move to the end of the line0.0
? begin searching reverse, repeat last search in reverse0.1
/ begin searching forward, repeat last search forward 0.1
_ move to the beginning of the line0.0
^ move to the first nonblank character of current line0.0
0 move to the beginning of the line0.1
a enter insert mode after the current point0.0
A enter insert mode at the end of the current line0.2
b,B move one word backward0.0,0.1
c#*w change word (or multiple words)0.3
d#*d delete one or more lines, e.g., dd, d2d, d34d0.0
d#*h delete from current location * characters left, e.g., dh, d2h, d34h0.3
d#*j delete from current location * lines down, e.g., dj, d2j, d34j0.3
d#*k delete from current location * lines up, e.g., dk, d2k, d34k0.3
d#*l delete from current location * characters right, e.g., dl, d2l, d34l0.3
d#*w delete one or more words0.0
d$ delete to end of line0.3.1
e,E move to end of word0.1,0.1
G,#G move to last line, or line number #0.2
h move left0.0
i enter insert mode0.0
I enter insert mode at the beginning of the current line0.2
j move down0.0
k move up0.0
l move right0.0
n repeat last search in the same direction0.1
N repeat last search in the opposite direction0.1
o enter insert mode on a new line0.0
O enter insert mode on a new line above0.2
p puts back whatever is in the "kill" buffer (deleted text...again, uses cocoa functions directly)0.0
r* replace the character under the cursor with typed character0.2 (not undoable)
u undo last operation (this uses the cocoa undo manager directly)0.0
w,W move one word forward0.0,0.1
x delete character under the cursor0.0
EX Commands
:w "Save File" command implemented by issuing the mnemonic ⌘S that typically means saving the current editing window. In future releases, the mnemonic issued will be customizable. 0.3

Contributors

  1. J. Duquennoy -- Improved the look and feel of the ViInputManager command window.

Caveats

Use at your own risk. I use it on a daily basis and will be fixing any bugs I come across. It is a work in progress and will be rapidly enhanced. If you have any suggestions or find any bugs please email me jcorso at acm dot org.

This plugin presupposes that you know how to use Vi. There are numerous books and online tutorials to introduce you to the wildly popular and productive editor.

Word-wrapping tends to cause some problems and unexpected behavior with various commands. While I do use word-wrapping with the ViInputManager, for example during LaTeX writing, the cursor may jump above to the earlier line if the wrapping changes after issuing a command. Please email any specific bugs associated with word-wrapping.

Uninstall

To uninstall:

  1. Remove the directory ~/Library/InputManagers/ViInputManager
  2. Remove the key binding. If you have no other key bindings in your system, then simply remove the file: ~/Library/KeyBindings/DefaultKeyBinding.dict. Otherwise, in that file, remove the entries for "Vi_escapeMode".

Support Further Development

ViInputManager is free and open software. You can help support further development by

  • Debugging and/or improving the source code directly. It is packaged with the download. Please email any fixes or improvements to jcorsoatacmdotorg.
  • Contribute ideas to the forums.
  • Making a monetary donation to further the development.

License

This work is licensed under the Creative Commons Attribution-ShareAlike License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/1.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.



This site and ViInputManager software are Copyright Jason J Corso 2003-2007.
Email jcorso__at__acm__dot__org for more information.
Site last updated 2 February 2007.