I want to automatically generate block comments for documentation using vim.
Something like:
/**
* comment
*/
are there any plugins for this?
I want to automatically generate block comments for documentation using vim.
Something like:
/**
* comment
*/
are there any plugins for this?
Vim has this functionality built-in. See :help format-comments
for details. Basically if you have filetype plugin on
in your ~/.vimrc and are using a bracket language (like C, C++, Java, javascript, etc.), you can type /**<cr>
and it will expand to:
/**
* _
where _
is the cursor position. When you're done with the comment block just hit /
to end it.
A low-budget way of simplifying a Vimmer's life with C- or Java-style block comments is to add the following mapping to .vimrc
.
autocmd FileType c,java inoreabbrev <buffer> /** /**<CR>/<Up>
That way, whenever you type /**<Enter>
in your C or Java source it will be expanded to the following, with the cursor at _
:
/**
* _
*/
Edit: As @Conner mentioned, you need to have filetype plugin indent on
in your vimrc to make this work.