views:

257

answers:

1

When I press "j" or arrow down in vim/gvim the cursor moves to the next line. which is good for writing code.

When writing text however the lines are usually much longer then the text with. Therefore I can not easily get the word just above THIS word. So in almost all editors and text processors pressing the up arrow HERE ↑ would put the cursor in front of "word". But in gvim the cursor moves to the blank line between "code." and "When".

I use wrap (set: wrap) and linebreak (set: lbr).

With all the power of vim - this has to be straight forward?

+11  A: 

gk and gj move up/down by visual line instead of text line. You could map j and k to these using

noremap j gj
noremap k gk

Some people prefer to only setup those maps for specific filetypes, in which case you'd want something like

au FileType html,tex noremap <buffer> j gj
au FileType html,tex noremap <buffer> k gk
jamessan
+1 for teaching me <kbd> inadvertantly.
StephenPaulger
This is freaking excellent. Thank you for that excellent and thorough answer. If I could accept twice.... Oh - btw: the mappings go in .vimrc right?
Andreas
@StephenPaulger: I learned that from someone else using it on SO too. :)@Andreas: Correct.
jamessan
Andreas - yes put them in .vimrc
Dan Goldstein