Fun with VIM: autocmd part 2

More to write about after spending a weekend hacking on vim plugins. Autocmd is probably one of the most powerful features of vim, but also one of the easiest to mis-use. If you ever end up copy-and-pasting someone else’s autocmd examples, beware! Here’s one that I had in my .vimrc forever autocmd BufRead,BufNewFile,BufAdd *.php setlocal […]

Fun with VIM: autocmd

Here’s a fun gotcha. I had this snippet in my vimrc, which kills trailing whitespace in buffers full of programming code, right before the buffer gets written out… autocmd FileType c,css,cabal,cpp,haskell,javascript,php,python,readme,text autocmd BufWritePre <buffer> :call setline(1,map(getline(1,”$”),’substitute(v:val,”\s\+$”,””,””)’)) Which is all well and good. Except when your kind of anal like me, and you end up editing […]