写了一Vim的注释插件,支持PHP/JS/JAVA/C#/PYTHON

42557 次阅读 by 九九 2012-05-17 | 标签:vim 玩具 总结

之前一直想能不能弄到一个自动添加注释的vim插件,像之前用phpdesinger它里面可以配置快捷键,来对应代码模板,通过这个设置可以做到自己的代码注释。不过它不能自动的检测当前函数里的变量参数等。之前一段时间也在网上找了好多的相关插件像javacommenter.vim等,但还是不能达到我想要的效果。于是,哈哈,自己动手码了一个,自己用了有一段时间了,感觉还不错,特点:
1. 可以按当前文件的后缀来自动判断当前使用的注释类型,如*.java/*.php/*.cs用“*”、“//”来注释,而对于*.py/*.vim则用“"”、“'”来注释。
2. 对于方法注释可以自动完成对当前方法变量参数的注释(还不支持换行的参数自动注释 :D);
3. 可以通过配置来设置当前的svn版本号是来自手动设,还是通过“$Id$”来生成;
4. 用户可以自己配置更多的注释变量。
Ok,接下来看几个实例。
1. 对文件的注释:
快捷键:ctrl + f
操作:在需要添加文件注释的地方输入“//f”,然后按快捷键“ctrl+f”即可。
示例:

//f
得到:
//单引号类型的注释,如python
""" 
" @version	 $Id: test-codecommenter.vim 74 2012-02-17 01:45:19Z xjiujiu@gmail.com $ 
" @package None 
" @subpackage None 
" @copyRight Copyright (c) 2011-2012 http://www.xjiujiu.com.All right reserved 
" 
""" 
//* 类型的注释,如java/php/C#
/** 
* @version	 $Id: test-codecommenter.vim 74 2012-02-17 01:45:19Z xjiujiu@gmail.com $ 
* @package: None 
* @subpackage: None 
* @copyRight: Copyright (c) 2011-2012 http://www.xjiujiu.com.All right reserved 
* @license: Apache GNU 
* 
*/
2. 对类的注释:
快捷键:
ctrl+v
操作:在需要添加变量注释的地方输入“//c”然后,按快捷键“ctrl+v”即可。
示例:

//c
class ExampleClass 
{
    //some code
}

得到:br/>

/** 
* @point 
* 
* @desc 
* 
* @author 九九* @package None 
* @version	 $Id: test-codecommenter.vim 74 2012-02-17 01:45:19Z xjiujiu@gmail.com $ 
*/ 
class ExampleClass 
{
    //some code
}

3. 方法注释
快捷键:ctrl+m
操作:在需要添加方法注释的地方输入“//m”然后,按快捷键“ctrl+m”即可。
示例:

//m
function GetName(string test, int yes) 
endfunction

得到:

//vim 注释
""" 
" @point 
" 
" @desc 
" 
" @access public 
" @param string test 
" @param  int yes 
" @return void 
" @exception none 
""" 
function GetName(string test, int yes) 
endfunction

4. 变量的注释
快捷键:ctrl + v
操作:在需要添加方法注释的地方输入“//v然后,按快捷键“ctrl+v”即可。
示例:

//v
$string     = "test"

得到:

/** 
* var $string     
*/ 
$string     = "test"

如果你觉得OK,下载地址:codecommenter.vim
如果你感兴趣,灰常欢迎前来一起完善它,svn 地址为:https://xjiujiu-open-work.googlecode.com/svn/tags/CodeCommenter1.0.0


评论(2755)

e1v4n6w2 To 九九 (7天以前)

<a href=" https://tetracycline.ooo/ ">tetracycline without a doctors prescription</a> - buy cheap tetracycline why is tetracycline discontinued - <a href=" https://tetracycline.ooo/ ">tetracycline drug interactions</a> https://tetracycline.ooo/

b4d8d6k6 To 九九 (7天以前)

<a href=" https://vardenafil.ooo/ ">generic levitra vardenafil 20mg</a>, vardenafil without a doctor prescription vardenafil without a doctor prescription - <a href=" https://vardenafil.ooo/ ">vardenafil vs viagra</a> https://vardenafil.ooo/

z0v6l7x8 To 九九 (7天以前)

<a href=" https://finasteride.ooo/ ">finasteride 1mg</a> - what is finasteride used for finasteride teaching - <a href=" https://finasteride.ooo/ ">buy cheap finasteride</a> https://finasteride.ooo/

endeararist To 九九 (2018-12-04)

las vegas casinos <a href="https://onlinecasinodd.com/">old vegas slots</a> | <a href=" https://onlinecasinodd.com/ ">chumba casino</a> | <a href=https://onlinecasinodd.com/>foxwoods online casino</a> <a href=https://onlinecasinodd.com/>online gambling casino</a>

JOTEOTSFUPS To 九九 (2018-12-04)

casino games free <a href="https://onlinecasinodd.com/">real money casino</a> | <a href=" https://onlinecasinodd.com/ ">virgin online casino</a> | <a href=https://onlinecasinodd.com/>casino play</a> <a href=https://onlinecasinodd.com/>vegas slots online</a>

lerearteboaceli To 九九 (2018-12-03)

real money casino <a href="https://onlinecasinodd.com/">online casinos for us players</a> | <a href=" https://onlinecasinodd.com/ ">casino games online</a> | <a href=https://onlinecasinodd.com/>pch slots</a> <a href=https://onlinecasinodd.com/>heart of vegas free slots</a>

Lundipr To 九九 (2018-12-03)

Forden Se Ringenes herre: Atter en konge Online Gratis pa nett Du kan ogsa se hvordan Geitekillingen som kunne telle til ti blir til film, i lopet av 2014 Hurtiglenker: Sistetball - Premier League Politikk - Norsk. <a href=http://duaoftheday.net/online-games-gratis-spielen/1374>online games gratis spielen</a> <a href=http://florawestland.com/slots-online-sverige/449>slots online sverige</a> Blackjack, ogsa kjent som Black Jack, og noen ganger 21, er et kortspill der

JOTEOTSFUPS To 九九 (2018-12-03)

online slot games <a href="https://onlinecasinodd.com/">free casino slot games</a> | <a href=" https://onlinecasinodd.com/ ">heart of vegas free slots</a> | <a href=https://onlinecasinodd.com/>online casino slots</a> <a href=https://onlinecasinodd.com/>online casino real money</a>

lerearteboaceli To 九九 (2018-12-03)

gsn casino <a href="https://onlinecasinodd.com/">cashman casino slots</a> | <a href=" https://onlinecasinodd.com/ ">casino online</a> | <a href=https://onlinecasinodd.com/>real casino</a> <a href=https://onlinecasinodd.com/>caesars slots</a>

endeararist To 九九 (2018-12-03)

casino games free online <a href="https://onlinecasinodd.com/">heart of vegas free slots</a> | <a href=" https://onlinecasinodd.com/ ">casino games free online</a> | <a href=https://onlinecasinodd.com/>real casino</a> <a href=https://onlinecasinodd.com/>vegas casino slots</a>

Lundipr To 九九 (2018-12-02)

Finn laveste pris Spill, Smykke Her finner du alle tilbud pa Smykke og kan sammenligne pris for du handler Kjop Smykke til laveste pris tilgjengelig pa nett. <a href=http://boisefilters.com/online-casino-bonus-without-deposit/4018>online casino bonus without deposit</a> <a href=http://binaryrobot247.com/kjpe-xbox-spill-online/974>kjope xbox spill online</a> Rapunzel of Sweden rabatt og rabattkoder - finn alt til haret med en kupongkode fra Rapunzel of Sweden. <a

endeararist To 九九 (2018-11-28)

casino games slots free <a href="https://onlinecasino888.us.org/">world class casino slots</a> | <a href=" https://onlinecasino888.us.org/ ">free casino</a> | <a href=https://onlinecasino888.us.org/>empire city online casino</a> <a href=https://onlinecasino888.us.org/>slots online</a>

JipifsLitesaf To 九九 (2018-11-28)

no deposit casino <a href="https://onlinecasino888.us.org/">online casinos</a> | <a href=" https://onlinecasino888.us.org/ ">hyper casinos</a> | <a href=https://onlinecasino888.us.org/>online casino</a> <a href=https://onlinecasino888.us.org/>mgm online casino</a>

snitmymn To 九九 (2018-11-28)

online casino real money <a href="https://casinorealmoney.us/">zone online casino</a> | <a href=" https://casinorealmoney.us/ ">free online casino games</a> | <a href=https://casinorealmoney.us/>gold fish casino slots</a> <a href=https://casinorealmoney.us/>zone online casino games</a>

Immossevabovelt To 九九 (2018-11-28)

parx online casino <a href="https://casinorealmoney.us/">online casino bonus</a> | <a href=" https://casinorealmoney.us/ ">high 5 casino</a> | <a href=https://casinorealmoney.us/>hollywood casino</a> <a href=https://casinorealmoney.us/>free slots 777</a>

Queuexy To 九九 (2018-11-28)

high 5 casino <a href="https://casinorealmoney.us/">caesars free slots</a> | <a href=" https://casinorealmoney.us/ ">free casino games vegas world</a> | <a href=https://casinorealmoney.us/>play online casino</a> <a href=https://casinorealmoney.us/>no deposit casino</a>

Immossevabovelt To 九九 (2018-11-28)

best online casinos <a href="https://casinorealmoney.us/">gold fish casino slots</a> | <a href=" https://casinorealmoney.us/ ">free casino games</a> | <a href=https://casinorealmoney.us/>tropicana online casino</a> <a href=https://casinorealmoney.us/>casino online slots</a>

JipifsLitesaf To 九九 (2018-11-28)

casino real money <a href="https://onlinecasino888.us.org/">casino play</a> | <a href=" https://onlinecasino888.us.org/ ">casino slots</a> | <a href=https://onlinecasino888.us.org/>casino games slots free</a> <a href=https://onlinecasino888.us.org/>online casino gambling</a>

SPOISSITA To 九九 (2018-11-28)

online casino bonus <a href="https://casinorealmoney.us/">free online casino games</a> | <a href=" https://casinorealmoney.us/ ">free slots 777</a> | <a href=https://casinorealmoney.us/>big fish casino</a> <a href=https://casinorealmoney.us/>foxwoods online casino</a>

WhalsBugBleada To 九九 (2018-11-28)

online slots <a href="https://casinorealmoney.us/">slots free games</a> | <a href=" https://casinorealmoney.us/ ">play casino</a> | <a href=https://casinorealmoney.us/>casino game</a> <a href=https://casinorealmoney.us/>lady luck</a>

PS:多打字可以减肥哦~234字以内。支持表情:


Top