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

How do I stop Vim from replacing long lines with rows of '@' signs and show as much text as possible instead?

Answer

:set display+=lastline,truncate

Explanation

By default, when a line is too long to fit in the window, Vim fills the remaining rows with @ characters to indicate the line continues off-screen. Enabling lastline and truncate in the display option changes this behaviour so Vim shows as much of the line as it can, appending @@@ only where the text is cut off. This is especially useful when editing files with very long lines (logs, minified code, JSON blobs) because you can actually see what's on the line instead of staring at a wall of @ symbols.

How it works

  • display+=lastline — when the last visible line in a window is too tall to fit entirely, show as much of it as possible rather than replacing the whole thing with @ rows
  • display+=truncate — adds @@@ at the point of truncation so you know the line continues; without this flag the truncation is silent
  • The += syntax appends to the current value so you don't lose other flags you may have set

Example

A 300-character minified JSON line with default settings:

{"name":"foo","value":42}
@
@
@

With :set display+=lastline,truncate:

{"name":"foo","value":42,"extra":"data","more":"fi@@@

You now see the actual content up to the window edge, with @@@ marking where it's cut.

Tips

  • Add set display+=lastline,truncate to your vimrc so the setting is permanent
  • Combine with :set nowrap to keep lines from wrapping; the @@@ indicator then tells you when a line extends beyond the visible area
  • To see the full line you can still use $ to jump to the end, or :set wrap temporarily

Next

How do I programmatically read and write Vim register contents including their type from Vimscript?