Vim: run code every time the buffer changes

I want to catch all events that change the vim buffer, so I can write them and send them to the server. I want to catch character-by-character events in insert mode, and also receive notifications when commands are executed, por ddso on. - at any time when the document changes.

+3
source share
3 answers

A friend pointed me to the badly named netbeans module inside vim. It looks like what I want.

0
source

Looking through the list of events, I chose 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

, , Insert* , d elete, p aste, c hange .. "" | autocmd-events |.

+2

In Vim 8, this is much simpler. Just listen to autocmd events:

TextChanged
TextChangedI
+2
source

All Articles