Chinaunix首页 | 论坛 | 博客
  • 博客访问: 101512401
  • 博文数量: 19283
  • 博客积分: 9968
  • 博客等级: 上将
  • 技术积分: 196062
  • 用 户 组: 普通用户
  • 注册时间: 2007-02-07 14:28
文章分类

全部博文(19283)

文章存档

2011年(1)

2009年(125)

2008年(19094)

2007年(63)

分类: LINUX

2008-05-03 10:53:16

代码中的注释不光可以用来描述代码功能,更多的时候是 debug 时用来屏蔽某些代码,把某些语句注释掉查看运行结果,再恢复作对比,相信写过程序的人都有这个经历吧。

不同的语言注释的写法不同,有的时候要注释一大传代码,确实是挺闷的,像 /* ... */ 这种还算好,如果只有单行注释,比如 # 这样的方式的话,就只有一行一行来了……

是个可以帮你轻松插入注释的 Vim 脚本,支持c、js、tex、lua、python、bash、html 等常见的注释格式~

使用方法非常简单: >c 是加上注释,

你可以直接 >c 把当前行注释,也可以用鼠标选取一段代码,再 >c 把他们全部注释掉~

如果你想添加新的注释格式和支持的文件格式,也很简单,打开 comments.vim,会看到最后有这样的代码:

au FileType * CommentStyle #
au FileType vim CommentStyle "
au FileType c,css,js,sql CommentStyle /* @ */
au FileType tex,mf,mytex,lilypond,postscr CommentStyle %
au FileType cpp,xkb CommentStyle \\\\
au FileType groff,nroff CommentStyle .\\"
au FileType config CommentStyle dnl
au FileType lua CommentStyle --
au FileType xdefaults CommentStyle !
au FileType html CommentStyle
au FileType python CommentStyle """ @ """

这就是各种注释的定义了,很容易就看出格式: au FileType 文件格式 CommentStyle 注释格式,@  是注释内容的占位符。 想加入新格式,就照猫画虎写个就可以了~

comments.vim 的下载地址:

阅读(434) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~