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

27877 次阅读 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


评论(1891)

mesqueurispems To 九九 (17分钟以前)

free blackjack vegas world <a href="https://vegascasinoplay.icu/">free penny slots</a> free casino games sun moon <a href=" https://vegascasinoplay.icu/ ">100 best usa casinos with best codes</a> | https://vegascasinoplay.icu/ - real money casino https://vegascasinoplay.icu/ - casinos in iowa

Brollasisse To 九九 (19分钟以前)

cbd oil colorado <a href="https://cbdoil.ooo/">cbd oil dogs</a> buy cbd oil uk <a href=" https://cbdoil.ooo/ ">cbd oil for sale walmart</a> | https://cbdoil.ooo/ - zilis cbd oil https://cbdoil.ooo/ - cbd oil capsules

chonisfiegerege To 九九 (29分钟以前)

best online casino <a href="https://onlinecasinodd.com/">888 casino online</a> jackpot magic slots download <a href=" https://onlinecasinodd.com/ ">play free casino slots now</a> | https://onlinecasinodd.com/ - online gambling sites https://onlinecasinodd.com/ - virgin casino online

OXINNYNITOKEW To 九九 (2小时以前)

casino games online <a href="https://mycasinogames.icu/">list of las vegas casinos</a> free online casino <a href=" https://mycasinogames.icu/ ">100 most popular free slots</a> | https://mycasinogames.icu/ - play lady luck https://mycasinogames.icu/ - online casino

WhalsBugBleada To 九九 (3小时以前)

free blackjack vegas world <a href="https://online-casino-games.ooo/">hyper casinos</a> pala casino online <a href=" https://online-casino-games.ooo/ ">three rivers casino</a> | https://online-casino-games.ooo/ - no deposit casino https://online-casino-games.ooo/ - vegas world

arognizagnede To 九九 (3小时以前)

cbd pills <a href="https://onlinecbdoil.ooo/">cbd oil uk</a> cbd flower <a href=" https://onlinecbdoil.ooo/ ">pure cbd oil</a> | https://onlinecbdoil.ooo/ - strongest cbd oil for sale https://onlinecbdoil.ooo/ - pure cbd

drywony To 九九 (3小时以前)

totally free slots no download <a href="https://onlinecasinorealmoney.icu/">heart of vegas casino game</a> free casino slots games <a href=" https://onlinecasinorealmoney.icu/ ">no deposit bonus codes for usa players</a> | https://onlinecasinorealmoney.icu/ - zone casino vegas world https://onlinecasinorealmoney.icu/ - new online casinos accepting usa

Immossevabovelt To 九九 (4小时以前)

free casino games slot <a href="https://vegas-casino.ooo/">casino online</a> casino blackjack <a href=" https://vegas-casino.ooo/ ">no deposit games online for real cash</a> | https://vegas-casino.ooo/ - rock n cash casino slots https://vegas-casino.ooo/ - msn games zone online casino

Queuexy To 九九 (4小时以前)

vegas casino games <a href="https://casino-vegas.ooo/">us online casinos for real money</a> vegas casino online <a href=" https://casino-vegas.ooo/ ">online casino games free</a> | https://casino-vegas.ooo/ - slot machines https://casino-vegas.ooo/ - no deposit casinos

Deatneryqueueda To 九九 (5小时以前)

cbd oil walgreens <a href="https://buycbdoil.icu/">cbd vape oil</a> cbd oil wisconsin <a href=" https://buycbdoil.icu/ ">cbd oil prices</a> | https://buycbdoil.icu/ - cbd oil for anxiety https://buycbdoil.icu/ - cbd flower

JOTEOTSFUPS To 九九 (5小时以前)

cbd capsules <a href="https://cbdonline2018.com/">cbd dosage</a> where to buy cbd cream for pain <a href=" https://cbdonline2018.com/ ">buy cbd oil online</a> | https://cbdonline2018.com/ - cbd oil vape https://cbdonline2018.com/ - the best cbd oil on the market

snitmymn To 九九 (6小时以前)

online casino gambling <a href="https://freecasinogames.ooo/">300 free slots no download no registration</a> slot machine free <a href=" https://freecasinogames.ooo/ ">200 free slot games</a> | https://freecasinogames.ooo/ - foxwoods casino online https://freecasinogames.ooo/ - 888 casino online

FailsTonincags To 九九 (6小时以前)

online casinos real money <a href="https://usacasino.icu/">free online casino slots</a> play casino games for free <a href=" https://usacasino.icu/ ">200 no deposit bonus usa</a> | https://usacasino.icu/ - list of las vegas casinos https://usacasino.icu/ - play online casino games

Seiseepseully To 九九 (7小时以前)

online casino bonus <a href="https://casinoplayonline.icu/">free vegas casino games</a> slots free spins no registration <a href=" https://casinoplayonline.icu/ ">casinos near me</a> | https://casinoplayonline.icu/ - new online casinos accepting usa https://casinoplayonline.icu/ - slots for real money

unanioms To 九九 (7小时以前)

free slots games <a href="https://casinovegas.icu/">casino games</a> free vegas slots online casino <a href=" https://casinovegas.icu/ ">casino online slots</a> | https://casinovegas.icu/ - winstar world casino https://casinovegas.icu/ - no download no registration slots

mesqueurispems To 九九 (9小时以前)

casino slot <a href="https://vegascasinoplay.icu/">download free casino slot games</a> vegas world free games online <a href=" https://vegascasinoplay.icu/ ">hyper casinos</a> | https://vegascasinoplay.icu/ - list of online casinos for us players https://vegascasinoplay.icu/ - jackpot magic slots download

unanioms To 九九 (9小时以前)

jack online casino <a href="https://casinovegas.icu/">300 free slots no download</a> parx online casino <a href=" https://casinovegas.icu/ ">vegas world free games</a> | https://casinovegas.icu/ - sugarhouse casino online https://casinovegas.icu/ - online casino bonus

Uplireearerm To 九九 (10小时以前)

300 free slots of vegas <a href="https://instantonlinecasino.icu/">free 777 slots no download</a> hollywood casino online slots <a href=" https://instantonlinecasino.icu/ ">free 777 slots no download</a> | https://instantonlinecasino.icu/ - free slot games https://instantonlinecasino.icu/ - free casino games no download

Guestcroto To 九九 (10小时以前)

partnervermittlung jerak, <a href=" http://llavedelaprendizaje.com/portal/single-rehna-punjabi-songs-pk/ ">single rehna punjabi songs pk</a>, single party karlsruhe 2014, <a href=" http://llavedelaprendizaje.com/portal/russische-frauen-dating-kostenlos/ ">russische frauen dating kostenlos</a>, kennenlernen getrennt zusammen, <a href=" http://llavedelaprendizaje.com/portal/frauen-aus-stuttgart-treffen/ ">frauen aus stuttgart treffen</

SmivegioumS To 九九 (10小时以前)

green roads cbd <a href="https://cbdoilsale.ooo/">cbd oil reviews</a> cbd oil capsules <a href=" https://cbdoilsale.ooo/ ">diamond cbd</a> | https://cbdoilsale.ooo/ - apex cbd oil https://cbdoilsale.ooo/ - cbd oil at walmart

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


Top