Vim: vertical motions through full or wrapped lines
In Vim a line is a set of characters ending with a Carriage Return.
What’s so special about that definition?
Think about wrapped lines that exceed the right edge: Vim handles each wrapped line as belonging to one line only.
Standard vertical motions in Vim using j
e k
keys or the arrow keys occur within full lines.
You can jump through wrapped lines by adding the g
key to j
e k
.
But, did you know that you can have both movements available without adding any keys?
You can remap arrow keys by insering the following code in the .vimrc configuration file:
nnoremap <Down> gj
nnoremap <Up> gk
vnoremap <Down> gj
vnoremap <Up> gk
inoremap <Down> <C-o>gj
inoremap <Up> <C-o>gk
From now you will be able to use the arrow keys for the motions through wrapped lines and the jk
keys for the default Vim motions.
Comments
Post a Comment