Is it possible to surround a selected part of a line with /* and */?
start COMMENT ME end
start /*COMMENT ME*/ end
Is it possible to surround a selected part of a line with /* and */?
start COMMENT ME end
start /*COMMENT ME*/ end
There is a plugin name NerdCommenter provide many ways of commenting, includes /* */: https://github.com/scrooloose/nerdcommenter
If you just need a quick solution, here is the macro which does the trick:
Update:
let @j="viws/*<esc>pa */<esc>"
Let save it to your .vimrc file then using by moving the cursor at the word then @j.
The simple (redoable version, that messes * register) is
xnoremap µ s/* <c-r>" */<esc>
PS: this is quite certainly a duplicate
You can use either of the following sequences of keystrokes from visual mode to comment out the currently selected text:
c/**/<Esc>hP
c/*<C-R>"*/<Esc>
(Note that the second of these is essentially the same as in Luc Hermitte's mapping. See :help i_CTRL-R if you're not sure how it works.)