Got some fire under me recently with the assistance of the kind folks in the #vim channel on irc.freenode.net, and came up with a few interesting usefuls for my ~/.vimrc
" Automatically source in my blank html file template locally.
:autocmd BufNewFile *.htm 0r ~/.vim/blank.htm
:autocmd BufNewFile *.html 0r ~/.vim/blank.htm
" same for Perl, except position the cursor at the bottom ready to start typing.
:autocmd BufNewFile *.pl 0r ~/.vim/skeleton.pl|normal G
Created a 'blank' html file with all the usual things I'm normally forced to go fetch from other finished files so I don't forget the correct formatting. Now, when I create a new *.htm(l) file, it's automatically filled in with all the basics I'd be starting with. Same goes for Perl, with the shebang line, and warnings/strict, except we move the cursor to the bottom and get ready to start typing.
Also, if we worked out a way for me to keep my html template on my website, and source it in remotely thanks to vim's 'netrw' script (which is built-in to current releases of vim)
" Automatically source in my blank html file template remotely.
:autocmd BufNewFile *.htm nested:0r http://www.webdragon.net/miscel/blank.htm|normal zR
:autocmd BufNewFile *.html nested:0r http://www.webdragon.net/miscel/blank.htm|normal zR
This version also automatically opens all the nested folds for me, as well.
Another useful, this one is self explanatory thanks to the comment
" map F12 to change the pwd of vim to the cwd of the current file
:noremap <F12>:cd <C-R>=expand("%:p:h")<CR><CR>
Anyone else out there have a useful trick or two they'd care to share?
VIM for perl Developers (Score:2)
nice .. (Score:1)
Anyone else have any interesting tricks ?