如何使用vim围绕一行描述发表评论?

mko*_*mko 5 c vim comments

我认为创建一个将当前行或视觉选择行转换为注释标题的映射会很方便.

像这样的东西:

This is the description of the usage of the class
Run Code Online (Sandbox Code Playgroud)

按下快捷方式后会变成:

/*----------------------------------------------------*/
/* This is the description of the usage of the class  */
/*----------------------------------------------------*/
Run Code Online (Sandbox Code Playgroud)

rom*_*inl 9

我在我的这条线上~/.vimrc完全符合你的要求:

nnoremap <leader>g I/* <Esc>A */<Esc>yyp0llv$r-$hc$*/<Esc>yykPjj
Run Code Online (Sandbox Code Playgroud)

将光标放在一条线上,按<leader>g,完成.

默认<leader>\,这样就可以了\g.

显然,您可以使用任何您想要的快捷方式.