Hot tip for vim users: highlight spaces at end of lines

Ashod Nakashian ashnakash at
Thu Dec 31 07:00:24 PST 2015

On Wed, Dec 30, 2015 at 8:38 PM, Chris Sherlock <chris.sherlock79 at>

> Hi all,
> Quick tip I’d like to share - every now and then I accidentally add a
> space on the end of lines of code.
> You can highlight this occurring in vim by adding the following to your
> .vimrc file:
> highlight ExtraWhitespace ctermbg=red guibg=red
> match ExtraWhitespace /\s\+$/
> Probably most vi/vim users know this, but to remove newlines, you can use
> the following:
> :%s/ \+$//g
You could also run that :substitute on :w and never have to worry about
trailing whitespace ever again :)

autocmd BufWritePre * :%s/\s\+$//e

Change the asterisk to any pattern matching filenames to apply this to
certain filetypes only. (Also note the use of \s to match any whitespace

More here:

Happy Vimming!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the LibreOffice mailing list