* Rory Winston <rwinston at eircom.net> [2001-07-02 09:33:34]:
> really good, but what I'd like to be able to do is to place the cursor
> on a line containing a subprocedure, hit a key, and Vim to generate an
> automatically formatted comment block, e.g. for
>> sub foo()
>> Vim generates
>> # Name : foo
> # Author : blah
> # Last Modified: whenever
let MyName="Jo Blogs"
let MyDateFormat="%Y-%m-%d %H:%M:%S"
function! MyCommentBlock(MyName, MyDateFormat)
let MyName=a:MyName
let MyDateFormat=a:MyDateFormat
normal 0w"aye
normal o# Name : ^["ap
normal o# Author : ^R=MyName^M^[
normal o# Last Modified : ^R=strftime(MyDateFormat)^M^[
endfunction
nmap ,C :call MyCommentBlock(MyName, MyDateFormat)
you can also issue:
:call MyCommentBlock('John Foobar', '%d-%m-%y')
to avoid using the predefined vars at the top
In the above ^R = Ctrl + V followed by Ctrl + R
^] = Ctrl + V followed by Esc
^M = Ctrl + V followed by Ret
Also the above function does not check to see if a comment block
already exists, but this feature could be easily added with a call to
match() etc etc
--
Matthew Sammon <m at banjaxed.net>
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!