Mac – Vim: Shortcut to move to beginning of next line / end of previous line

macvimvim

Is there any shortcut in vim to move to the beginning of the next line or the end of the previous line? Is there any way to do it without having to use $ or ^?

Also, is there any way to make it so that if I hit right or l at the end of a line, it moves to the beginning of the next line? Similarly for left or h at the beginning of a line to move to the end of the preceding line? I'm using MacVim if that makes any difference.

Best Answer

To move to the beginning of the next line, hit Enter. See :help <CR>.

To make right and l wrap to the beginning of the next line, add > and l to the 'whichwrap' option, e.g.,

:set whichwrap+=>,l

Similarly, to make left and h wrap to the end of the previous line, add < and h to the 'whichwrap' option, e.g.,

:set whichwrap+=<,h

See :help 'whichwrap'.

I don't know of a single-key shortcut to move to the end of the previous line, but with those 'whichwrap' settings, 0h or 0left would work, and you could possibly map either of those to some key you don't often use.

Related Question