我经常使用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
但是,如果我有三次斜杠评论,例如对于 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
vim
似乎包括最后一个斜杠作为文本的一部分,并没有认识到它构成了评论的一部分。我怎样才能解决这个问题?以下是我想要看到包含的结果,当我选择三重斜杠评论并按gq
时:
/// here is a simple comment that
/// exceeds my line width across
/// multiple lines
请注意,我不想影响正常c++
评论的现有行为。
我正在使用vim 7.4.52
答案 0 :(得分:17)
将此添加到.vimrc
文件应该可以解决问题:
autocmd Filetype c,cpp set comments^=:///
有关评论格式的帮助可以在:h format-comments
找到。