mirror of https://github.com/bjeanes/dotfiles.git
Remove trailing whitespace from files on save
parent
544a1db252
commit
0892bc5f35
15
vim/vimrc
15
vim/vimrc
|
@ -247,6 +247,21 @@ set directory=~/.vim/backup
|
||||||
" better way to run this?
|
" better way to run this?
|
||||||
let ignorethisvar = system("mkdir -p ~/.vim/backup")
|
let ignorethisvar = system("mkdir -p ~/.vim/backup")
|
||||||
|
|
||||||
|
" Strip trailing whitespace
|
||||||
|
function! <SID>StripTrailingWhitespaces()
|
||||||
|
" Preparation: save last search, and cursor position.
|
||||||
|
let _s=@/
|
||||||
|
let l = line(".")
|
||||||
|
let c = col(".")
|
||||||
|
" Do the business:
|
||||||
|
%s/\s\+$//e
|
||||||
|
" Clean up: restore previous search history, and cursor position
|
||||||
|
let @/=_s
|
||||||
|
call cursor(l, c)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
autocmd! BufWritePre * :call <SID>StripTrailingWhitespaces()
|
||||||
|
|
||||||
" Align cucumber tables
|
" Align cucumber tables
|
||||||
inoremap <silent> <Bar> <Bar><Esc>:call <SID>align()<CR>a
|
inoremap <silent> <Bar> <Bar><Esc>:call <SID>align()<CR>a
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue