Monday, July 5, 2010

working with long lines in vim


When we have long lines in VIM and we set wrap option to make it a lone lines look like 
several lines in view.  But the moving across lines using jk are still on real lines. How to work around this? 

First, we can map like the following:
 noremap <C-J> gj noremap <C-K> gk 

That's really useful when dealing with long lines. It lets you use Control-J and Control-K to move up and down screen lines instead of buffer lines with j and k. Control-J isn't really mapped to anything by default, it's like hitting enter, but Control-K is something to do with digraphs. However, noremap won't remove this ability in insert mode.

Alternatively, you could use:

 noremap <Up> gk noremap <Down> gj 


No comments: