I have written a vimscript function. I want to use autocmd to call this function when a character is deleted with the x key. But autocmd requires an event name. Which event is triggered when a character is deleted with the x key?


There is no such event.

There is TextChanged event that is generally called when text was changed in normal mode (including x I guess). I am not sure this what you need though...

Why not remap x key to delete a character and call your function?

func! MyFunc()
    echo printf("You have just deleted '%s'", getreg(v:register))
noremap x x:call MyFunc()<CR>
  • Thank you. Remapping x works exactly as expected!
    – aks
    Feb 8 '20 at 18:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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