Friday, March 5, 2010

VIM copy/paste/navigation in Insert mode.

A few months ago, I made a commitment to learn the VIM editor. I was primarily an EMACS user, but I wanted to become proficient with VIM since EMACS is not always available I found myself too slow when using VIM. To learn it, I pretty much told myself that I'm not allowed to use any other editor while programming and just immerse myself in VIM. For the most part, it worked. I've been using VIM daily for about 4 months now and I've gotten used to it... mostly.

I can see the reasoning and benefits of having a separate mode for inserting text, but for me it isn't as intuitive to use. Maybe my fingers are just to conditioned to be able to write chunks of text and still be able to copy, paste, etc. The way I work, I edit text while jumping around a lot and that mode leads to a lot of hitting ESC to the point where I'm using more key strokes then on EMACS (where the criticism is that it requires mult-combos to do an action such as 'C-x C-c'). So I found myself editing text, ESC, move around, 'i', edit text. For the most part, I was willing to live with that, but the breaking point is that I just kept making mistakes editing. I'd hit 'i' when I'm already in edit mode or be typing outside of edit mode leading to typos and jumping to another part of the screen. I figure that 4 months is enough and while I'll stay with VIM, I'll likely be in Insert mode a lot and so I want to reduce bouncing back-and-forth between modes.

I made the following changes to my .vimrc to allow me to do things like move around (without using the arrow keys) and copy/paste without leaving Insert mode:

" Key mappings in INSERT mode
" Tired of lifting hand to hit ESC or having ctrl-[
imap ;;

" navigate without lifting hand off of keys

" paste in Insert Mode

" undo
imap u

" Select text
imap vgG

1 comment:

  1. To paste in Insert or Command-line mode the last thing that was copied:
    CTRL-R 0