Vi(M) tips #1
I’ve been using the ViM and Vi editors for years, but I would not say I know all their short cuts or nifty features by any stretch. Here are three shortcuts (two for plan old Vi) which I learned just this week:
- (Vi/ViM) shift-a puts you in insert mode and brings you to the end of current line.
- (Vi/ViM) shift-i puts you in insert mode and brings you to the start of current line.
- (ViM) Key sequence gqip reformats the current paragraph nicely, much like M-q in Emacs. Very useful for writing email.
I also found one very nice ViM plugin this week, SuperTab. I used to not bother with ViM plugins because of the hassle of installing them on many machines, but I found now that plugin installation consists merely of creating ~/.vim/plugin/ and dropping the .vim file in there. ViM already has some fairly cool word-completion but SuperTab makes it work all with one key (tab). I’m not exactly sure about what it will complete, but so far it will complete based on a) the content of its dictionary file and b) words in the file you are editing. Very useful for completing variable or function names in source code, and also useful as a spelling tool for words you may be unsure of in email. Perhaps even useful as a poor man’s thesauraus
Lastly, I finally got around to binding my Caps Lock key to Escape. Obviously using Vi/ViM, you hit the escape key all the time. Escape is positioned out of my left hand’s easy reach on just about every keyboard I have used, however. Binding it to Caps Lock means less strain on my hands and more speed in my editing. When I was a big Emacs user, I similarly bound Caps Lock to Control. The magic xmodmap incantation to bind Caps Lock to Escape this is:
keycode 0x42 = Escape







i recently found ctrl-[ is the same as esc. hitting esc still ends up being less awkward for me.
ctrl-c is even more cooler