vimtricks.wiki Concise Vim tricks, one at a time.

How do I let h/l and arrow keys wrap to adjacent lines at line boundaries?

Answer

:set whichwrap+=<,>,h,l

Explanation

By default, h and l stop at line boundaries. In dense edits, that means extra j/k motions just to continue horizontally. Tuning whichwrap lets horizontal keys cross line edges, which makes fast cursor travel feel more continuous in code and prose.

How it works

:set whichwrap+=<,>,h,l
  • whichwrap controls which keys are allowed to wrap to adjacent lines.
  • += appends behavior without overwriting your existing setting.
  • <,> enables wrapping for left/right arrow keys.
  • h,l enables wrapping for Normal-mode h and l.

After enabling this, pressing l at end-of-line jumps to the first character of the next line, and pressing h at column 1 jumps to the previous line's end. This is especially useful when reviewing diffs or making precise inline edits across short lines where vertical movement is unnecessary overhead.

Example

Before (l stops on b):

abc
def

After enabling whichwrap with h,l, pressing l on c moves to d on the next line.

Tips

  • Add [, ] if you also want <Left> and <Right> in Insert mode to wrap.
  • Use :set whichwrap? to inspect your current value before changing it.
  • If this feels too aggressive globally, set it only for specific filetypes via setlocal.

Next

How do I join a wrapped paragraph into one line without manual cursor moves?