[英]Copy and paste issue with Mac OS X
当我从浏览器复制文本并将其粘贴到我在终端中使用vi
打开的文件时,我得到以下未格式化的文本。 为什么vi或终端忽略换行符?
而不是获得以下内容:
" Restore cursor position to where it was before
augroup JumpCursorOnEdit
au!
autocmd BufReadPost *
\ if expand("<afile>:p:h") !=? $TEMP |
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ let JumpCursorOnEdit_foo = line("'\"") |
\ let b:doopenfold = 1 |
\ if (foldlevel(JumpCursorOnEdit_foo) > foldlevel(JumpCursorOnEdit_foo - 1)) |
\ let JumpCursorOnEdit_foo = JumpCursorO
我明白了:
" Restore cursor position to where it was before
augroup JumpCursorOnEdit
au!
autocmd BufReadPost *
\ if expand("<afile>:p:h") !=? $TEMP |
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ let JumpCursorOnEdit_foo = line("'\"") |
\ let b:doopenfold = 1 |
\ if (foldlevel(JumpCursorOnEdit_foo) > foldlevel(JumpCursorOnEdit_foo - 1)) |
这是vi的错,而不是Mac OS X或终端。 Vi不会忽视换行符; 它只是在累积缩进。 您可以通过在粘贴之前关闭自动:set noai
( :set noai
)并在之后将其重新打开来解决此问题,或者,如果您正在使用Vim(我相信vi只是Mac OS X中的符号链接),您可以暂时关闭paste
选项打开,禁用自动注册以及粘贴文本时可能导致问题的其他几个功能。
甚至比:set paste
只是我们的mac剪贴板。
如果您使用的是vim 7.3,可以将其添加到~/.vimrc
文件中以获取yank( y
)和粘贴( p
)以使用Mac的剪切和粘贴缓冲区:
if has("macunix")
if v:version >= 703
" Default yank and paste go to Mac's clipboard
set clipboard=unnamed
endif
endif
即使你没有Vim 7.3,你也可以安全地将它放在.vimrc
- 它只是不起作用。
您可以使用自制软件和homebrew-alt存储库获取最新的vim。 我推荐它!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.