How to fold all C comments in Vim
In vim, you can use global command to apply actions across lines matching the given pattern.
There are two types of patterns to apply the global command:
g/found/v/notfound/cmd
g/found/cmd
For our use case, you can use following global command to apply foldc
action to all the lines which match the given pattern.
The pattern here is matching for all the multiline C
comments (\* comments *\
type) which are not ending on the same line.
g/^\s*\/\*.*/v/^\s*\/\*.*\*\//foldc
You can also do this with foldmethod=expr
and setting expressions. Which I found a bit more work to set up.
Some of the plugin uses this methods becuase it is easier to extend.
Reference :