sauravkpaul
sauravkpaul

Reputation: 13

automate and attach a VIM script to an event

I have a small vim function say myFunc() defined in my .vimrc and have this function mapped to to keyword in normal mode say cl and i am successfully able to call this function whenever i type cl in normal mode, myFunc() is invoked.

Now I want to go one step further, I want this function myFunc automatically called whenever press i to go from normal mode to insert mode in vim

Please suggest how can I achieve that.

Upvotes: 1

Views: 72

Answers (1)

FDinoff
FDinoff

Reputation: 31469

I think you want to use an auto command on InsertEnter.

autocmd InsertEnter * call MyFunc()

Noter user defined functions must start with a capital letter.

Take a look at :help autocmd and :help InsertEnter.

Upvotes: 3

Related Questions