Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 6 down vote accepted

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.

share|improve this answer
Pressing enter goes to the beginning of the next line, not the end. (Which is what the OP wanted, but your answer reversed the terminology.) – Heptite Jun 1 '12 at 0:15
@Heptite: That's what I meant. Bad fingers! Thank you for catching that. Fixed. – garyjohn Jun 1 '12 at 0:31
Thank you! Also I just figured out that to get this to work in insert mode, you can do set whichwrap+=[,]. – Kevin H. Lin Jun 1 '12 at 0:50

For your first question, I am not aware of any shortcut that will do what you want, but you could map it. For example:

:nnoremap <c-p> k$
:nnoremap <c-n> j0

For your second question, look at ":help 'whichwrap'" (with the single quotes as part of the command).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.