Date: prev next · Thread: first prev next last
2015 Archives by date, by thread · List index


Oh! Nice :-) I'll be doing that - I'm a serial offender, but I only ever
annoy myself!

Chris

On Friday, January 1, 2016, Ashod Nakashian <ashnakash@gmail.com> wrote:

On Wed, Dec 30, 2015 at 8:38 PM, Chris Sherlock <
chris.sherlock79@gmail.com
<javascript:_e(%7B%7D,'cvml','chris.sherlock79@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!


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.