我经常gq用来将更长的注释包装在一些字符内,如果我正在使用//或/* /*评论我的代码,它可以正常工作:
// here is a simple comment that exceeds my line width
// across multiple lines
// here is a simple comment that
// exceeds my line width across
// multiple lines
Run Code Online (Sandbox Code Playgroud)
但是,如果我有三次斜杠评论,例如对于doxygen,它不起作用:
/// here is a simple comment that exceeds my line width
/// across multiple lines
/// here is a simple comment that
// exceeds my line width / across
// multiple lines
Run Code Online (Sandbox Code Playgroud)
vim似乎包括最后一个斜杠作为文本的一部分,并没有认识到它构成了评论的一部分.我怎样才能解决这个问题?当我选择三次斜杠评论并按时,我想看到的包装结果gq:
/// here is a simple comment that
/// exceeds my line width across
/// multiple lines
Run Code Online (Sandbox Code Playgroud)
请注意,我不想影响正常c++注释的现有行为.
我在用 vim 7.4.52
jxh*_*jxh 20
将此添加到您的.vimrc文件应该可以做到这一点:
autocmd Filetype c,cpp set comments^=:///
Run Code Online (Sandbox Code Playgroud)
有关评论格式的帮助可以在:h format-comments.
| 归档时间: |
|
| 查看次数: |
568 次 |
| 最近记录: |