Oh! Nice :-) I'll be doing that - I'm a serial offender, but I only ever annoy myself!<div><br></div><div>Chris<br><br>On Friday, January 1, 2016, Ashod Nakashian <<a href="mailto:ashnakash@gmail.com">ashnakash@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Dec 30, 2015 at 8:38 PM, Chris Sherlock <span dir="ltr"><<a href="javascript:_e(%7B%7D,'cvml','chris.sherlock79@gmail.com');" target="_blank">chris.sherlock79@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hi all,<br>
<br>
Quick tip I’d like to share - every now and then I accidentally add a space on the end of lines of code.<br>
<br>
You can highlight this occurring in vim by adding the following to your .vimrc file:<br>
<br>
highlight ExtraWhitespace ctermbg=red guibg=red<br>
match ExtraWhitespace /\s\+$/<br>
<br>
Probably most vi/vim users know this, but to remove newlines, you can use the following:<br>
<br>
:%s/ \+$//g<br>
<br></blockquote><div><br></div><div>You could also run that :substitute on :w and never have to worry about trailing whitespace ever again :)</div><div><br></div><div><div><pre style="border:1px solid rgb(204,204,204);margin-top:0px;margin-bottom:0px;padding:12px;vertical-align:baseline;line-height:14px;overflow:auto;word-wrap:normal;color:rgb(58,58,58);font-size:14px;background-color:rgb(242,242,242)">autocmd BufWritePre * :%s/\s\+$//e</pre></div></div><div><br></div><div>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.)</div><div><br></div><div>More here: <a href="http://vim.wikia.com/wiki/Remove_unwanted_spaces" target="_blank">http://vim.wikia.com/wiki/Remove_unwanted_spaces</a></div><div><br></div><div>Happy Vimming!</div></div></div></div>
</blockquote></div>