在这里将一些 VM 服务器升级到 Debian 9。
现在使用 时ssh
,我们无法在远程终端之间复制和粘贴。
光标似乎正在移动,并标记文本,尽管以比平常更有趣/不同的方式,但在执行 command-C / command-V 或复制并粘贴到相应菜单中时,不会将其他任何内容复制到剪贴板.
我们还尝试使用 Shift 和其他键盘组合进行鼠标移动,但没有积极的结果。
这发生在 OS/X 中,即 Sierra 和 El Capitan,以及在 Windows 中,也使用 mobaXterm 终端。
这种情况是由于 vim 意识到拥有鼠标。
按照 Stack Overflow 中的其他问题,我创建/etc/vim/vimrc.local
了set mouse="r"
和set mouse="v
;效果不佳。
最后set mouse=""
在同一个文件中进行设置,取得了一定的成功。
但是,它也不能 100% 地正常工作。还能做什么?
小智 45
解决方案:更改mouse=a
为mouse=r
在您的本地.vimrc
.
/usr/share/vim/vim80/defaults.vim
正如接受的答案所说,设置它的问题是它会在每次更新时被覆盖。我搜索了很长时间,最终找到了这个:https :
//bugs.debian.org/cgi-bin/bugreport.cgi?bug=864074
本地解决方案(有缺陷):
第一个解决方案是使用本地 .vimrc 文件并将其设置在那里。
所以你可以~/.vimrc
为每个用户创建一个本地 .vimrc ( ) 并在那里设置你的选项。或者在其中创建一个,/etc/skel
以便为您创建的每个新用户自动创建。
但是当您使用本地.vimrc
文件时,您必须在那里设置所有选项,因为如果有本地文件.vimrc
,则defaults.vim
根本不会加载!如果没有本地,.vimrc
您的所有设置都将从defaults.vim
.
全局解决方案(首选):
我想要一个适用于所有用户的全局配置,它加载默认选项,然后使用我的个人设置添加或覆盖默认值。幸运的是,Debian 中有一个选项:/etc/vim/vimrc.local
将在/etc/vim/vimrc
. 所以你可以创建这个文件并加载默认值,防止它们再次加载(最后),然后添加你的个人选项:
请创建以下文件: /etc/vim/vimrc.local
" This file loads the default vim options at the beginning and prevents
" that they are being loaded again later. All other options that will be set,
" are added, or overwrite the default settings. Add as many options as you
" whish at the end of this file.
" Load the defaults
source $VIMRUNTIME/defaults.vim
" Prevent the defaults from being loaded again later, if the user doesn't
" have a local vimrc (~/.vimrc)
let skip_defaults_vim = 1
" Set more options (overwrites settings from /usr/share/vim/vim80/defaults.vim)
" Add as many options as you whish
" Set the mouse mode to 'r'
if has('mouse')
set mouse=r
endif
Run Code Online (Sandbox Code Playgroud)
(请注意,$VIMRUNTIME
在上面的代码片段中使用的值类似于/usr/share/vim/vim80/defaults.vim
。)
如果您还想启用“旧的复制/粘贴行为”,请在该文件的末尾添加以下几行:
" Toggle paste/nopaste automatically when copy/paste with right click in insert mode:
let &t_SI .= "\<Esc>[?2004h"
let &t_EI .= "\<Esc>[?2004l"
inoremap <special> <expr> <Esc>[200~ XTermPasteBegin()
function! XTermPasteBegin()
set pastetoggle=<Esc>[201~
set paste
return ""
endfunction
Run Code Online (Sandbox Code Playgroud)
Rui*_*iro 26
从鼠标感知中去除 vim 的一种方法似乎是注释掉有关鼠标的配置。
在/usr/share/vim/vim80/defaults.vim
我注释掉鼠标特定检测如下:
" In many terminal emulators the mouse works just fine. By enabling it you
" can position the cursor, Visually select and scroll with the mouse.
"if has('mouse')
" set mouse=r
"endif
Run Code Online (Sandbox Code Playgroud)
(在那些 vim 配置文件中, " 正在启动注释)。
更改使我们可以毫无问题地再次复制和粘贴。
我同意评论这不是理想的解决方案,因为除非配置文件受到保护(或转移),否则确实会被覆盖到任何更新中。当时,由于软件包版本或我曾经工作的服务器配置的细节,它是唯一有效的。因此,我将这个答案留在这里,它只能用作最后的解决方案。
归档时间: |
|
查看次数: |
51465 次 |
最近记录: |