Vim - hiding carriage returns (^M)
Sometimes, you end up editing files with mixed line endings.
You would like to have less visual distraction by removing those ^M
Vim displays.
Yet you don't want to convert the whole file to LF or CRLF (for various reasons like not creating meaningless diffs in the SCM).
Just add the following snippet to your .vimrc
:
for i in ['cterm', 'gui']
for j in ['fg', 'bg']
let c = synIDattr(hlID('Normal'), 'bg', i)
if (!empty(c))
exec 'highlight CarriageReturn ' . i . j . '=' . c
endif
endfor
endfor
if hlID('CarriageReturn')
match CarriageReturn /\r$/
endif
Not ideal, but better than nothing.
Written by Gregory Pakosz
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Vim
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#