useful vim commands

Useful in coding:
Add a space before '{':

%s/\([^ ]\)\({\)/\1 \2/
%s/\s\+$//

Or you can add following code snippet to your .vimrc

autocmd FileType c,cpp,java,php
    \ autocmd BufWritePre <buffer> 
    \ :call setline(1,map(getline(1,"$"),'substitute(v:val,"\\s\\+$","","")'))
vim
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License