Home » Questions » Computers [ Ask a new question ]

Vim: show line feeds & carriage-return

Vim: show line feeds & carriage-return

How can I display line feeds and/or carriage-return characters in vi/vim?

Asked by: Guest | Views: 330
Total answers/comments: 2
Guest [Entry]

"In recent versions of Vim there's a 'listchars' setting that lets you specify which characters should be used for the EOL and TAB characters, and for trailing spaces.

You could:

set listchars=eol:$,tab:\[SPACE]\[SPACE]

...to display eol chars specially without collapsing tabs (type a space character, not [,S,P,A,...).

I don't know of anything specifically about return chars in the 'listchars' setting, but I suspect you can use syntax highlighting for this.
I think the default display of \r characters is to show them with SpecialKey highlighting.

So the default SpecialKey highlighting of \r characters, combined with setting 'listchars' as above, should be close to what you need.

:highlight SpecialKey ctermfg=5

...if you're fond of magenta."
Guest [Entry]

"Add the following line to your .vimrc file:

set fileformats=unix

This causes vim to support only unix-style files natively. For non-Unix style line-endings, the carriage return character \r will be displayed explicitly in vim as ^M."