Mariy
Mariy

Reputation: 5924

vim end of line

I want to view where lines end in gvim. I very often have spaces after statements and I don't want to have. How to toggle this editor feature?

Upvotes: 10

Views: 11168

Answers (3)

AnthonyHurst
AnthonyHurst

Reputation: 133

you should be able to highlight anything by just doing a /character and hit enter.

for example /\n (enter) should show where the newlines are.

Upvotes: 3

DrAl
DrAl

Reputation: 72726

Use:

set list

That will show lots of stuff (see :help 'list' for more information). If you want to just show the line endings, do this as well:

set lcs=eol:$,tab:\ \ 

(Note that there are two "backslash, space" pairs on the end of the line). This prevents tabs from being highlighted.

You could alternatively do:

set lcs=eol:$,tab:\ \ ,trail:#

To make all trailing spaces as #. Play with it to your hearts content and see:

:help 'listchars'

Alternatively, you can just highlight it with something like this:

syn match Error /\s\+$/

Upvotes: 22

Ben James
Ben James

Reputation: 125327

You can highlight trailing whitespace like this: (lifted from http://ertius.org/blog/highlighting-trailing-whitespace-in-vim/)

highlight ExtraWhitespace ctermbg=red guibg=red
autocmd Syntax * syn match ExtraWhitespace /\s\+$\| \+\ze\t/

This isn't a built-in toggleable feature, though; the above snippet would go in your config and would make this active all the time.

Upvotes: 4

Related Questions