Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

WebDragon (1204)

WebDragon
  (email not shown publicly)
http://www.webdragon.net/

Macintosh owner/user since 1987
Perl hacker since 2000
Linux (Redhat/Fedora) user since 2001

Journal of WebDragon (1204)

Tuesday December 07, 2004
04:49 PM

vim-fu revisited

[ #22196 ]

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?

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.