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

How do I prevent long lines from wrapping on screen?

Answer

:set nowrap

Explanation

The nowrap option prevents long lines from wrapping to the next screen line. Instead, the line extends beyond the visible area and you scroll horizontally.

How it works

  • :set nowrap disables visual line wrapping
  • :set wrap re-enables wrapping
  • Long lines are cut off at the window edge

Example

With nowrap, a 200-character line shows only what fits in the window width. The rest is hidden until you scroll right.

Tips

  • zl and zh scroll horizontally one character
  • zL and zH scroll half a screen width
  • :set sidescroll=1 makes horizontal scrolling smooth
  • :set linebreak wraps at word boundaries when wrap is on
  • Use gj/gk to navigate wrapped lines when wrap is on

Next

How do you yank a single word into a named register?