white_space.vim 1017 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. " White Space - Modeline and Notes {{{
  2. " vim: set sw=2 ts=2 sts=2 et tw=78 foldmarker={{{,}}} foldlevel=0 foldmethod=marker spell:
  3. "
  4. " cinaeco/dotfiles functions to do with manipulation of white space
  5. "
  6. " }}}
  7. " Remove trailing spaces before save {{{
  8. if has("autocmd")
  9. " Are there really any files we care about that Need trailing white space?
  10. "autocmd FileType c,cpp,java,go,php,javascript,python,twig,xml,yml
  11. autocmd BufWritePre * call StripTrailingWhitespace()
  12. function! StripTrailingWhitespace()
  13. " Preparation: save last search, and cursor position.
  14. let _s=@/
  15. let l = line(".")
  16. let c = col(".")
  17. " do the business:
  18. %s/\s\+$//e
  19. " clean up: restore previous search history, and cursor position
  20. let @/=_s
  21. call cursor(l, c)
  22. endfunction
  23. endif
  24. " }}}
  25. " Mappings {{{
  26. " Add extra lines up and down {{{
  27. nnoremap <leader>j o<Esc>k
  28. nnoremap <leader>k O<Esc>j
  29. " }}}
  30. " Convert tabs to spaces {{{
  31. nnoremap <silent> <leader><TAB> :%s/<TAB>/ /g<CR>
  32. " }}}
  33. " }}}