Today I Learned

hashrocket A Hashrocket project

Allow j and k to work on visual lines

Wrapped lines in Vim can be challenging at times. Try to move up or down in a perceived paragraph and instead of moving one line down/up you move to one of the ends of the paragraph.

To solve this you might be using gj and gk, but that slows your navigation considerably.

To allow vim to navigate between wrapped lines (visual lines) more naturally, as if they where hard lines, you can add the following mappings to your vimrc:

nnoremap k gk
nnoremap j gj

Now when you press j or k the cursor will move where you really intended for it to move. Normal j and k will still work as intended.

See More #vim TILs
Every developer at Hashrocket is a Vim expert. Check out our development environment, Dotmatrix, and if you are in Chicago, come to the Vim Chicago Meetup hosted at our Chicago office.