自动“花式"用 Vim 插入注释 [英] Automatic "fancy" comment insertion with Vim
问题描述
我喜欢在我的 C 代码中有这样的注释:
I like to have comments like this in my C code:
/********************************************************
* Blah
********************************************************/
但是我厌倦了输入所有这些星号,复制/粘贴也很烦人.我想知道我是否可以用 Vim 创建一个宏,这样如果我按下(例如)CTRL+L
,它会自动在我的代码中插入该结构并将光标对齐在中间(实际评论写在哪里).
But I get tired of typing all those asterisks, and copy/pasting can also get annoying. I was wondering if I could possibly create a macro with Vim so that if I press (for example) CTRL+L
, it'll automatically insert that structure in my code and align the cursor in the middle (where the actual comment is written).
任何建议将不胜感激.谢谢!
Any advice would be appreciated. Thanks!
推荐答案
看一看 snipmate,一个类似 TextMate 的片段的 vim 插件.
Take a look at snipmate, a vim plugin for TextMate-like snippets.
snipMate.vim 在 Vim 中实现了一些 TextMate 的片段功能.一种片段是一段经常输入的文本,您可以将其插入到您的使用触发词后跟
snipMate.vim implements some of TextMate's snippets features in Vim. A snippet is a piece of often-typed text that you can insert into your document using a trigger word followed by a <tab>.
这篇关于自动“花式"用 Vim 插入注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!