1

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?

2

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))
endfunc
noremap x x:call MyFunc()<CR>
| improve this answer | |
  • Thank you. Remapping x works exactly as expected! – aks Feb 8 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.