white_space.vim 737 B

1234567891011121314151617181920212223242526
  1. " Remove trailing spaces before save
  2. if has("autocmd")
  3. " Are there really any files we care about that Need trailing white space?
  4. "autocmd FileType c,cpp,java,go,php,javascript,python,twig,xml,yml
  5. autocmd BufWritePre * call StripTrailingWhitespace()
  6. function! StripTrailingWhitespace()
  7. " Preparation: save last search, and cursor position.
  8. let _s=@/
  9. let l = line(".")
  10. let c = col(".")
  11. " do the business:
  12. %s/\s\+$//e
  13. " clean up: restore previous search history, and cursor position
  14. let @/=_s
  15. call cursor(l, c)
  16. endfunction
  17. endif
  18. " Add extra lines up and down
  19. nnoremap <Leader>j o<Esc>k
  20. nnoremap <Leader>k O<Esc>j
  21. " Convert tabs to spaces
  22. nnoremap <silent> <Leader><Tab> :%s/<Tab>/ /g<CR>