Is there any utility/plugin for vim editor to add comments/headers?

1k views Asked by At

I have searched a number of plugins for adding automatic/manual headers/comments/function details in any C/C++ file when open in vim editor, even tried using .vimrc file using autocommands. But they are for while opening a new file. Is there any same for already existing files?

Its very tedious for adding information about a code/function in a large code-base.

2

There are 2 answers

0
Xavier T. On

There are at least two approaches, one using abbreviations and one using snippets.

For example, you could use Ultisnips to add a pre established header.

1
Luc Hermitte On

lh-cpp provides:

  • customisable templates for file headers
    • loaded automatically when a new file is created from the file template, before expanding the dedicated .h/.cpp file template
    • or on demand as they are 3 ways to trigger a template/snippet expansion (automatically on new files, or on demand with :MuTemplate c/internals/c-file-header here (you can also set an alias to something else) or on snippet expansion). As lh-cpp/mu-template snippets/templates are actually similar to functions/variations points, you can ask to expand only file headers (which are customizable on a per-project basis), or anti-reinclusion guards, and so on.
  • :DOX command that analyses functions signature to fill the function headers as best as possible
  • advanced snippets for various kind of classes (entity classes, base classes, copiable classes, exception classes, ...) and should eventually fill as much information as possible in the class doxygen from the class semantics -- I just didn't have enough time yet to implement this feature.