C 如何使用vim对描述行进行注释?

C 如何使用vim对描述行进行注释?,c,vim,comments,C,Vim,Comments,我认为创建一个映射将当前行或可视选择的行转换为注释横幅会很方便 大概是这样的: This is the description of the usage of the class 按下快捷键后,将变成: /*----------------------------------------------------*/ /* This is the description of the usage of the class */ /*-------------------------------

我认为创建一个映射将当前行或可视选择的行转换为注释横幅会很方便

大概是这样的:

This is the description of the usage of the class
按下快捷键后,将变成:

/*----------------------------------------------------*/
/* This is the description of the usage of the class  */
/*----------------------------------------------------*/

我的
~/.vimrc
中有一行代码,它完全符合您的要求:

nnoremap <leader>g I/* <Esc>A */<Esc>yyp0llv$r-$hc$*/<Esc>yykPjj
nnoremap gi/*A*/yyp0llv$r-$hc$*/yykPjj
将光标放在一行上,按
g
,完成

默认的
\
,因此应该是
\g


很明显,你可以使用任何你想要的快捷方式。

@kev
tcommont
很酷,但我不知道如何制作一个看起来很花哨、很容易识别的a形注释。这是一个好习惯吗?