当我粘贴到Vim中时如何避免出现多余的括号

当我粘贴到Vim中时如何避免出现多余的括号

问题描述:

我在编码时使用一些地图:

I use some maps while I code :

imap ( ()<C-[>i
imap [ []<C-[>i
imap { {}<C-[>i

这样,当我放入("时,它会写成()"(与[[和"{"相同). 问题是当我将某些东西粘贴到Vim中时:

so that when I put "(" , it writes "()" (same thing for "[" and "{" ). The problem is that when i paste something into Vim :

for (i = 0; i < count; i++) {
tab[i] = something()
}  

我知道

for (i = 0; i < count; i++) {
tab[i] = something()
}  
)]})

是否可以避免使用多余的括号?

Is it possible to avoid the extra brackets?

您需要'paste'选项;用:set paste进行设置.它将禁用插入模式映射,缩写和其他自动格式化选项.

You want the 'paste' option; set it with :set paste. It disables insert mode mappings, abbreviations, and other autoformatting options.

另一件事是有多种粘贴方式:

The other thing is that there are multiple ways to paste:

  • "+p
  • :set mouse=a,然后单击鼠标中键
  • 插入模式,<C-R>+
  • :a!,然后使用终端的粘贴命令
  • "+p
  • :set mouse=a and then middle-click
  • insert mode, <C-R>+
  • :a! and then use your terminal's paste command

所有这些都将正确粘贴.唯一使vim混乱的是,您在没有事先警告的情况下使用终端的粘贴"命令.

All of these will correctly paste. The only one that confuses vim is when you use your terminal's "paste" command without first warning it.