当我粘贴到Vim中时如何避免出现多余的括号 [英] How to avoid extra brackets from appearing while I paste into Vim

查看:143
本文介绍了当我粘贴到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.

这篇关于当我粘贴到Vim中时如何避免出现多余的括号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆