Search code examples
vimline-breaksword-wrap

make gvim treat wrapped line as new line


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?


Solution

  • 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