VIM 注释插件Enhanced Commentify

各种语言的注释风格迥异,有的支持多行注释,有的只支持单行注释,有的注释还不能嵌套。
调试程序的时候,经常要注释/反注释一些代码。每次都手工注释真是很累。

实验了无数插件,终于弄到个好用的。

EnhCommentify.vim

http://www.vim.org/scripts/script.php?script_id=23

官网说明:

description
The development of the script is done at http://kotka.de/projects/enhancedcommentify/index.html. Releases may be downloaded from below.

There is a major rework for Vim7 underway. In case you are missing any features, this is the time to suggest them. Send me an email or report your bugs or suggestions in the trac at the link above. This is a serious request from me to the users. In the past a lof of people complained on mailing lists, that "this doesn't work" or "that feature is missing", without contacting me. If you don't tell the upstream author, then this won't change!

Stay tuned.
 
install details

Simply drop the script in your .vim/plugin directory. There is a detailed EnhancedCommentify.txt, since there are to much options to explain here. Put it in your .vim/doc directory and issue the ':helptags ~/.vim/doc' command. ':help EnhancedCommentify' should then give you any information you need in order to use the new features of the script.                 

 

安装:

安装还算简单,解压出来的文件分别放在vim下相对应的文件夹里。插件放在vim72/plugin中,帮助文件放在vim/doc中就OK了。          

 

使用:

首先要在vimrc中设置你的leader。我设置的是‘,’。

"Set mapleader
let mapleader = ","
let g:mapleader = ","

有2种方式来注释:

1 <leader>c 这个注释之后光标会跳转到下一行。

2 <leader>x 用这个注释之后,光标仍然停留在当前行。

可以设置单独的按键来代替这个leader模式

"注释
nmap <silent> <F3> ,x
vmap <silent> <F3> ,x
imap <silent> <F3> ,x

稍作解释:nmap 是你在普通模式下可以执行的命令就是按下esc后的那个模式。

vmap 是在按下v 选择了模块之后,执行的。

imap 是在插入状态下可以执行的。

 

OK ,设置好这些按<F3>就是注释再次按<F3>就是反注释了。可以单行注释,也可以选中一个块进行注释。还算方便。

 

 

 


 

posted @ 2010-08-13 14:25  楼心月  阅读(1652)  评论(0编辑  收藏  举报