请问Vim如何注释掉一段 c 代码
- nickleeh
- 帖子: 130
- 注册时间: 2008-08-06 13:24
请问Vim如何注释掉一段 c 代码
如题:怎样在 Vim 中注释/反注释掉一段 c 代码?
- kofshower
- 帖子: 1343
- 注册时间: 2007-03-13 11:23
- 联系:
自己写一个函数
参考代码:
参考代码:
代码: 全选
function! CPP_CodeComment( mode, style )
if a:mode=="a"
if a:style == 'yes'
silent exe ":s#^#/\* #"
silent put = ' */'
else
silent exe ":s#^#//#"
endif
endif
if a:mode=="v"
if a:style == 'yes'
silent exe ":'<,'>s/^/ \* /"
silent exe ":'< s'^ '\/'"
silent exe ":'>"
silent put = ' */'
else
silent exe ":'<,'>s#^#//#"
endif
endif
endfunction
"We are all in the mud, but some of us are looking at the stars." (Oscar Wilde)
We are not born for ourselves.
人生天地间,并非为自己
Homepage:http://sites.google.com/site/polarisnotme/
We are not born for ourselves.
人生天地间,并非为自己
Homepage:http://sites.google.com/site/polarisnotme/
- nickleeh
- 帖子: 130
- 注册时间: 2008-08-06 13:24
谢谢楼上的回复。
我找到了一个非常好的插件,解决这个问题:
http://www.vim.org/scripts/script.php?script_id=1173
非常方便,可以用gc来注释/反注释文本块。(不仅支持c,还支持 TeX/ruby/python/perl
regions in vim scripts, HTML or JavaScript in php code ... .... 推荐大家试一下)
我找到了一个非常好的插件,解决这个问题:
http://www.vim.org/scripts/script.php?script_id=1173
非常方便,可以用gc来注释/反注释文本块。(不仅支持c,还支持 TeX/ruby/python/perl
regions in vim scripts, HTML or JavaScript in php code ... .... 推荐大家试一下)
- ccbrighty
- 帖子: 17
- 注册时间: 2008-05-01 11:36
http://www.vim.org/scripts/script.php?script_id=1218
推荐试试这个,我是过很多,这是最优秀的一个
推荐试试这个,我是过很多,这是最优秀的一个
-
- 帖子: 204
- 注册时间: 2008-01-07 16:39