KGardevoir
KGardevoir

Reputation: 455

Make Vim perform action when entering or exiting insert

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?

Upvotes: 3

Views: 253

Answers (1)

qqx
qqx

Reputation: 19495

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.

Upvotes: 5

Related Questions