Vim Tips Wiki
No edit summary
 
m (Move through wrapped lines. moved to Move through wrapped lines: Page moved by JohnBot to improve title)

Revision as of 09:22, 18 October 2007

Previous TipNext Tip

Tip: #308 - Move through wrapped lines

Created: August 12, 2002 1:34 Complexity: intermediate Author: Little Dragon Version: 5.7 Karma: 155/58 Imported from: Tip#308

If you don't like the fact that when you press Up and Down on a wrapped line, you get to the next phisical line instead of the next line on the screen, you can do something like this:


imap <silent> <Down> <C-o>gj

imap <silent> <Up> <C-o>gk


nmap <silent> <Down> gj

nmap <silent> <Up> gk

Comments

just make sure that you don't do something odd like I did and copy the spaces at the end of the code :S.

Anonymous , March 9, 2003 16:55


or you can just jump into paste mode.

in paste mode you will be able to navigate from line to line without the cursor jumping around *and* you won't have the long text wrap if you put a space in, which usually is not a desired effect.

set paste

or

set pastetoggle=<F9> (or whatever keybinding you want) in your .vimrc

Anonymous , March 5, 2004 15:53


My current settings are:

map <silent> <up> gk imap <silent> <up> <C-o>gk map <silent> <down> gj imap <silent> <down> <C-o>gj map <silent> <home> g<home> imap <silent> <home> <C-o>g<home> map <silent> <end> g<end> imap <silent> <end> <C-o>g<end>

setlocal linebreak setlocal nolist setlocal display+=lastline

But i'm still trying to find a way to avoid "jumps" when i'm scrolling and a wrapped line enters or exits the screen...

PS: See also VimTip38

Anonymous , August 14, 2004 17:19


I have the same problem in long line cases. That is, can vim scroll in screen lines instead of physical lines when one long line is about to scroll out of window (up or down)?

lei.wang--AT--computer.org , August 25, 2004 0:59