Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/vim/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
vim:每次缓冲区更改时运行一些代码_Vim - Fatal编程技术网

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

vim:每次缓冲区更改时运行一些代码,vim,Vim,我想捕获所有修改vim缓冲区的事件,以便记录它们并将它们发送到服务器。我希望在插入模式下捕获逐个字符的事件,并且在执行p或dd等命令时得到通知---文档随时更改。查看事件列表时,我选择了以下内容: |BufFilePre| before changing the name of the current buffer |BufFilePost| after changing the name of the current buffer |FileChan

我想捕获所有修改vim缓冲区的事件,以便记录它们并将它们发送到服务器。我希望在插入模式下捕获逐个字符的事件,并且在执行
p
dd
等命令时得到通知---文档随时更改。

查看事件列表时,我选择了以下内容:

|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
更改当前缓冲区的名称之前 |BufFilePost |更改当前缓冲区的名称后 |FileChangedShell | Vim注意到一个文件在编辑开始后发生了更改 |FileChangedShellPost |处理自编辑开始以来更改的文件后 |插入器插入器|开始插入模式 |InsertChange |在插入或替换模式下键入时 |InsertLeave |离开插入模式时 |QuickFixCmdPre |在运行quickfix命令之前 |QuickFixCmdPost |运行quickfix命令后
虽然我没有尝试过,但我相信
Insert*
事件包括诸如
d
elete、
p
aste、
c
hange等命令。您还应该在| |中查找“编写”事件。

一位朋友向我指出了vim中名称非常糟糕的模块。这看起来就像我想要的。

在Vim 8中,这要容易得多。只需收听以下自动MD事件:

TextChanged
TextChangedI

我现在很好奇是否可以重新映射默认的vim命令,例如所谓的'dd'和'p';)这是可能的,但需要付出巨大的努力。。。可能无法很好地与vimrc配合。也需要处理所有的变化。。例如,“2dd”、“vjjp”、“d3k”等。此外,当您在插入模式下输入文本时,不会触发任何插入*方法——仅当您进入或离开插入模式时才会触发。您试图实现什么?也许对你有帮助你在找工作吗?或者更多的东西?我想制作多人游戏vim(想想以太板)。