Linux – vim imap automatically turns off the hassle of quotes

vim imap automatically turns off the hassle of quotes… here is a solution to the problem.

vim imap automatically turns off the hassle of quotes

I managed to get the braces and parentheses that close automatically correctly :

imap { {<return><return>}<Esc>kcc
imap ( ()<Esc>i

However, quotation marks cannot be written like parentheses. If I write like this:

imap " ""<Esc>i

Enter an infinite loop. Why is this?

Then I wrote quotes like this:

imap " "<Esc>xPpi

There is also a problem with this. It eats a character inserted to the left. I fiddled with it a bit but couldn’t figure out how to map it correctly. Can someone help?

Solution

Try this :

inoremap " ""<Esc>i

This way it doesn’t apply the mapping to the mapping result (no resursion).

Related Problems and Solutions