Last active
August 29, 2015 13:56
-
-
Save tavisto/9080826 to your computer and use it in GitHub Desktop.
Add some commands to fix whitespace issues.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Make all tabs 4 spaces | |
" Make tabs delete properly | |
" Make autoindent add 4 spaces per indent level | |
set tabstop=4 | |
set softtabstop=4 | |
set shiftwidth=4 | |
set expandtab " Convert all tabs | |
set smarttab | |
function! Preserve(command) | |
" Preparation: save last search, and cursor position. | |
let _s=@/ | |
let l = line(".") | |
let c = col(".") | |
" Do the business: | |
execute a:command | |
" Clean up: restore previous search history, and cursor position | |
let @/=_s | |
call cursor(l, c) | |
endfunction | |
nmap <leader>$ :call Preserve("%s/\\s\\+$//e")<CR> | |
nmap <leader>= :call Preserve("normal gg=G")<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment