Wiki

by yszheda

View project onGitHub

Tip 47: Distinguish Between Real Lines and Display Lines

Return to the top: <<Practical Vim>>

Pattern: j/k/0/$ all interact with real lines, while prefixing any of these with g tells Vim to act on display lines instead.

Command Move Cursor
j Down one real line
gj Down one display line
k Up one real line
gk Up one display line
0 To first character of real line
g0 To first character of display line
^ To first nonblank character of real line
g^ To first nonblank character of display line
$ To end of real line
g$ To end of display line

Remap Line Motion Commands

nnoremap k gk
nnoremap gk k
nnoremap j gj
nnoremap gj j