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

How do I scroll through wrapped long lines smoothly without skipping screen rows?

Answer

:set smoothscroll

Explanation

The smoothscroll option makes scroll commands respect screen rows rather than buffer lines when wrap is enabled. Without it, pressing <C-d> or <C-u> treats a 10-screen-row wrapped line as a single line — the cursor teleports past the wrapped portion. With smoothscroll enabled, scrolling moves one visual row at a time, even within a single long buffer line.

How it works

When wrap is on, a single buffer line can occupy many rows on screen. Standard scroll commands (<C-d>, <C-u>, <C-f>, <C-b>) count movement in buffer lines, so they can appear to jump erratically on screens full of wrapped prose or long code.

With :set smoothscroll, these commands shift the viewport by screen rows instead:

  • <C-d> / <C-u> — scroll half a screen by rows, not buffer lines
  • <C-f> / <C-b> — scroll a full screen by rows
  • zz, zt, zb — still center/top/bottom by the cursor's screen row

Example

With a buffer containing one very long line that wraps across 20 screen rows:

Before: <C-d> jumps the entire 20 wrapped rows at once.
After:  <C-d> scrolls exactly half the screen height in rows.

Tips

  • Requires Vim 9.0+ or Neovim 0.10+. Check with :version or :echo has('smoothscroll').
  • Only affects wrapped-line scrolling; has no effect when set nowrap is active.
  • Works well with set scrolloff=5 — the context lines are preserved in screen rows.
  • Add set smoothscroll to your vimrc alongside set wrap linebreak for prose editing.

Next

How do I extract regex capture groups from a string in Vimscript?