LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] Re: Question for Vim gurus

[ILUG] Re: Question for Vim gurus

Matthew Sammon m at banjaxed.net
Tue Jul 3 19:07:07 IST 2001


* 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>




More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


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!
RSS Version
Powered by Dell