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

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


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

> 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
character.)

More here: http://vim.wikia.com/wiki/Remove_unwanted_spaces

Happy Vimming!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20151231/cceb406f/attachment.html>


More information about the LibreOffice mailing list