1

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.

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Let me quickly try this and update if it works or not. Thanks for the response.
Works perfectly and this is what I wanted. Thanks a lot. Pardon me, as i don't have reputation for an upvote

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.