Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make Vim perform action when entering or exiting insert

Tags:

vim

I am attempting to disable my touchpad whenever I enter "insert" mode. I believe this can be done with map and can be done by using a command like:

map i     :silent !synclient TouchpadOff=1 <i> <CR>
map <ESC> :silent !synclient TouchpadOff=0 <ESC> <CR>

But this obviously doesn't work because map is not going to recurse to a previous definition, rather it just ignores it. How would one go about doing this?

like image 351
KGardevoir Avatar asked Jul 07 '26 06:07

KGardevoir


1 Answers

You can setup autocommands using the events fired when insert mode is entered or left:

auto InsertEnter * :silent !synclient TouchpadOff=1
auto InsertLeave * :silent !synclient TouchpadOff=0

There may be other events you want to act upon, as well you can get a list of the known events with :help autocmd-events.

like image 54
qqx Avatar answered Jul 10 '26 21:07

qqx



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!