Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I let vim wrap triple-slash comments?

Tags:

c++

vim

I often use gq to wrap longer comments to within some number of characters, which works fine if I am using // or /* /* to comment my code:

// 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

However, if I have triple-slash comments, e.g. for doxygen, it doesn't work:

/// 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 seems to be including the last slash as part of the text, and not recognizing that it forms part of the comment. How can I fix this? Here is the wrapped result that I want to see when I select triple-slash comments and press gq:

/// here is a simple comment that
/// exceeds my line width across
/// multiple lines

Note that I don't want to affect the existing behaviour for normal c++ comments.

I am using vim 7.4.52

like image 781
quant Avatar asked Jan 21 '15 22:01

quant


1 Answers

Adding this to your .vimrc file should do the trick:

autocmd Filetype c,cpp set comments^=:///

Help about comment formatting can be found at :h format-comments.

like image 151
jxh Avatar answered Oct 19 '22 06:10

jxh