2

似乎我在 .vimrc 中的“设置粘贴”选项没有被选中。当我启动 vim 并进入插入模式时,我得到了预期的插入(粘贴)。但是,当我使用 apple-V 从剪贴板粘贴时,文本会在每一行逐渐缩进,就好像我没有打开粘贴模式一样。然后我手动输入 :set paste 再试一次,文本格式正确。

此外,即使它也被明确设置,自动缩进似乎也参差不齐。

这是 OSX Lion 上的 vim 7.3。谢谢!

set paste 
set autoindent
syntax on

colorscheme elflord

set tabstop=2
set softtabstop=2
set shiftwidth=2
4

2 回答 2

3

set paste has no business being in your ~/.vimrc as it conflicts with a number of useful options.

The only use for :set paste is to reset a bunch of indentation-related options to allow your text to be pasted "correctly" when you use the mouse or your system's "paste" facilities. It's probably a good idea to read :h pastetoggle.

In such a situation, you are supposed to do :set paste before you paste and :set nopaste afterwards.

If your Vim has clipboard support built-in (:echo has('clipboard') should return 1) and you work locally, I highly recommend you use "+y and "+p instead.

于 2013-03-08T19:54:58.123 回答
1

选项pasteautoindent不相处。我建议保留选项的切换autoindent并将其映射到功能键,例如:<F10>paste

:map <F10> :set invpaste<CR>
于 2013-03-08T18:55:45.357 回答