Something that helps in text editing and proofreading is that for Insert mode, I have set an IMAP:

:imap zz ^[:w^M

and when I type zz I return to command mode and also write the current buffer. This makes latexmk reprocess my .tex.

However, I also make smaller changes like replacing single characters with r or daw for deleting a word or pasting a register. How can I tell Vim to write the current buffer every time I do such changes?

  • You can set a very low updatecount, so that Vim will write to the swap file very often. This obviously may cause slowdowns. Commented Jun 1, 2015 at 15:13

2 Answers 2


If your main motivation is updating an alternative (compiled) representation in another tool, you can use the FocusLost event (present in GVIM and some terminals), so updates will happen when you leave Vim (for the other tool).

:autocmd FocusLost * update

For certain filetypes / buffers, replace * with <buffer> and define in ~/.vim/after/ftplugin/{filetype}.vim.

You can add additional :help autocmd-events, e.g. CursorHold,CursorHoldI,InsertLeave. What you literally asked for is TextChanged,TextChangedI, but its :help explicitly warns:

Careful: This is triggered very often, don't do anything that the user does not expect or that is slow.

  • b:changedtick could also be useful in this context: it counts "[t]he total number of changes to the current buffer [...] incremented for each change. An undo command is also a change in this case". FWIW.
    – lcd047
    Commented Jun 1, 2015 at 17:32

Use event-based autocommands: I suggest TextChanged for normal mode, and InsertLeave for insert mode - which can also replace your zz mapping.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.