简体   繁体   English

vim imap自动关闭报价的麻烦

[英]vim imap trouble for automatically closing quotations

I managed to get auto closing braces and parentheses right: 我设法让自动关闭括号和圆括号:

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

However, quotation can't be written like parentheses. 但是,引用不能写成括号。 If I write it like this: 如果我这样写:

imap " ""<Esc>i

it goes into an infinite loop. 它进入了无限循环。 Why does this happen? 为什么会这样?

I then wrote quotations like this: 然后我写了这样的引文:

imap " "<Esc>xPpi

This one too has a problem. 这个也有问题。 It eats up a character to the left of insertion. 它会占用插入左侧的字符。 I fiddled around with it, but could not work out how to get the mapping right. 我摆弄它,但无法弄清楚如何正确映射。 Can someone help please? 有人可以帮忙吗?

Try this: 试试这个:

inoremap " ""<Esc>i

This way it will not apply mappings to the result of mapping (no resursion) 这样它就不会将映射应用于映射的结果(没有重新生成)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM