Remove white-spaces, please!
I like to navigate through code using paragraph motion ("{" and "}" keys). But if you leave white-spaces between every single empty line of code, it's impossible to do that.
So, please. Remove white-spaces for the sake of your teammates.
Add to your ~/.vimrc:
function! <SID>RemoveWhitespaces()
let l = line(".")
let c = col(".")
execute '%s/\s\+$//e'
call cursor(l, c)
endfunction
" Remove white-spaces on write
autocmd BufWritePre * :call <SID>RemoveWhitespaces()
" Shift+Space will remove white-spaces immediately
nnoremap <silent> <S-Space> :call <SID>RemoveWhitespaces()<CR>
Written by Endel Dreyer
Related protips
1 Response
How about the simpler:
:%s/^\s+$//
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Vim
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#