Reputation: 17521
I would like to commentize a word under the cursor and use it as a macro or map it as a key binding.
For example this:
void somefunc(MyType* pType);
Would become:
void somefunc(MyType* /*pType*/);
I know that I just need to prepend and append word with /* and */ but I dont know how to do this.
Upvotes: 1
Views: 275
Reputation: 6332
A way more general way to create inline comments is to use the Tcomment plugin.
When you've installed it you can use the gc
operator to comment something, for example if you have the following file (with ^
indicating the cursor):
void somefunc(MyType* ^pType);
Pressing gce
will get you:
void somefunc(MyType* /*pType*/);
You can use this for any motion command, but of course a line wise operator (eg. gcj
) will not comment inline but entire lines instead.
Upvotes: 1
Reputation: 195109
try either of this mapping, pick one you feel better.
nnoremap <leader>cw caw/*<c-o>P*/<esc>
or
nnoremap <leader>cw viw<esc>a*/<esc>hbi/*<esc>
type <leader>cw
in normal mode.
Upvotes: 3