vim:每次缓冲区更改时运行一些代码

发布于 2024-11-07 16:48:14 字数 124 浏览 0 评论 0 原文

我想捕获所有修改 vim 缓冲区的事件,这样我就可以记录它们并将它们发送到服务器。我想在插入模式下捕获逐个字符的事件,并且在执行 pdd 等命令时收到通知——只要文档发生更改。

I want to trap all events that modify the vim buffer, so I can record them and send them to a server. I want to trap character-by-character events while in insert mode, and also be notified when p or dd etc. commands are executed---any time the document changes.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

夏了南城 2024-11-14 16:48:14

在 Vim 8 中这要容易得多。只需监听这些 autocmd 事件:

TextChanged
TextChangedI

In Vim 8 this is much easier. Just listen to these to autocmd events:

TextChanged
TextChangedI
一身骄傲 2024-11-14 16:48:14

浏览事件列表,我选择了以下内容:

|BufFilePre|            before changing the name of the current buffer
|BufFilePost|           after changing the name of the current buffer

|FileChangedShell|      Vim notices that a file changed since editing started
|FileChangedShellPost|  After handling a file changed since editing started

|InsertEnter|           starting Insert mode
|InsertChange|          when typing <Insert> while in Insert or Replace mode
|InsertLeave|           when leaving Insert mode

|QuickFixCmdPre|        before a quickfix command is run
|QuickFixCmdPost|       after a quickfix command is run

虽然我没有尝试过,但我相信 Insert* 事件包括诸如 delete、p 之类的命令aste、change 等。您还应该在 |autocmd-事件|。

Going through the list of events I have selected the following:

|BufFilePre|            before changing the name of the current buffer
|BufFilePost|           after changing the name of the current buffer

|FileChangedShell|      Vim notices that a file changed since editing started
|FileChangedShellPost|  After handling a file changed since editing started

|InsertEnter|           starting Insert mode
|InsertChange|          when typing <Insert> while in Insert or Replace mode
|InsertLeave|           when leaving Insert mode

|QuickFixCmdPre|        before a quickfix command is run
|QuickFixCmdPost|       after a quickfix command is run

Although I have not tried, I believe that the Insert* events include such commands as delete, paste, change etc. You should also look for the 'Writing' events in |autocmd-events|.

窗影残 2024-11-14 16:48:14

一位朋友向我指出了 vim 中名称可怕的 netbeans 模块。这看起来像我想要的。

A friend pointed me at the terribly-named netbeans module within vim. This looks like what I want.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文