Skip to content

Instantly share code, notes, and snippets.

@aaronstaves
Created February 26, 2013 18:37
Show Gist options
  • Select an option

  • Save aaronstaves/5040905 to your computer and use it in GitHub Desktop.

Select an option

Save aaronstaves/5040905 to your computer and use it in GitHub Desktop.
" Highlight trailing white space in command mode
highlight ExtraWhitespace ctermbg=red guibg=red
au ColorScheme * highlight ExtraWhitespace guibg=red
au BufEnter * match ExtraWhitespace /\s\+$/
au InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
au InsertLeave * match ExtraWhiteSpace /\s\+$/
"fix whitespace on write
autocmd FileType vim,perl,c,cpp,python,ruby,java autocmd BufWritePre <buffer> :%s/\s\+$//e
@aaronstaves
Copy link
Copy Markdown
Author

Highlights trailing whitespace, and removes it on write

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment