Re: git and trailing whitespace



2009-05-05 klockan 23:00 skrev Lennart Poettering:
> Then there is the question about editors. emacs has stuff like this:
> http://www.splode.com/~friedman/software/emacs-lisp/src/whitespace.el. vim
> has something similar I heard. Not sure if other editors do.

If you put the following lines in ~/.vimrc, you can press F12 in both normal
and insert mode to remove all trailing whitespace from the file currently
edited:

  " Strip trailing whitespace (and keep the cursor position)
  command! StripTrailingWhitespace normal mx<Enter>:%s/\s\+$//<Enter>:nohlsearch<Enter>`x
  nnoremap <F12> :StripTrailingWhitespace<CR>
  inoremap <F12> <C-O>:StripTrailingWhitespace<CR>

Good luck! :)

    — Wouter

Attachment: signature.asc
Description: Digital signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]