将代码粘贴到 Mac OS X 上的 vim 终端窗口中 [英] Pasting code into terminal window into vim on Mac OS X

查看:39
本文介绍了将代码粘贴到 Mac OS X 上的 vim 终端窗口中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我将代码粘贴到我的 Mac OS X 终端窗口到 vim 时,它会缩进每一行.对于每一行,它添加一个缩进,因此文本看起来像这样...

"ut laboure et dolore magna aliqua. Ut enim ad minim veniam, quis nostrudullamco labouris nisi ut aliquip ex ea commodo consequat.Duis aute irure dolor inreprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.例外 sint occaecat cupidatat non proident,sunt in culpa qui offciadeserunt mollit anim id est labourum."

我目前的解决方法是先将文本粘贴到保持正确格式的 textmate 文本编辑器中.然后我保存该文件并在 vim 中打开它.然后我用 vim yank 来粘贴它.
我的 .vimrc 中是否有可以改变这种行为的设置?或者这是终端问题?

解决方案

在 vim 中:

:设置粘贴

<块引用>

将 Vim 置于粘贴模式.如果您想剪切或复制,这很有用一个窗口中的一些文本并将其粘贴到 Vim 中.这将避免意想不到的效果.

When I paste code into my Mac OS X terminal window into vim it indents each line. For each line it adds an indent so the text looks like this...

"ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud        
   ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
        reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
             Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia
                    deserunt mollit anim id est laborum."

My current workaround is I paste the text first into textmate text editor which keeps the correct formatting. Then I save that file and open it up in vim. Then I use vim yank to paste it.
Is there a setting in my .vimrc that could change this behavior? Or is this a terminal issue?

解决方案

Within vim:

:set paste

Put Vim in Paste mode. This is useful if you want to cut or copy some text from one window and paste it in Vim. This will avoid unexpected effects.

这篇关于将代码粘贴到 Mac OS X 上的 vim 终端窗口中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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