Saturday, February 12, 2011

How to fix cursor keys in insert mode in Vim

I've been working a lot in Vim lately especially since I miserably failed in the Linux IQ test. My objective is to remember all the things I used to do when I was using Ubuntu as my primary computer ( almost 3 years ago i think).

I started installing ssh so I could log in from work or any other computer. Obviously you only have command line there. At the beginning was difficult but then I started remembering a couple of things. One trick I really like is this one. Usually when you work in Vim you have two states: Insert mode and Command mode that is all. So when you are in insert mode by defect you start moving using the cursor keys but those do not work the same. Every time you press them it will trigger an echo character and this is just annoying. I order to fix that you just need to edit this file /etc/vim/vimrc and add set nocompatible at the beginning of it (in some cases you just need to uncomment it). And since you are already there you can also add set nu this will turn on line numbering :)

Now you should be able to use the cursor keys as usual when using insert mode. This trick works on Ubuntu, I tried on version 10.10 a.k.a Maverick Meerkat, it should work on any flavor of it though.

No comments:

Post a Comment