复制远程连接到Linux使用VIM打开的内容到Windows
我们经常是使用SSH工具远程连接到Linux服务器上进行工作,有时候需要将Linux下使用VIM打开的文件内容复制到Windows上来,默认情况下,可能会复制不了,因为VIM默认情况下是使用的set mouse=a
的设置,它会让鼠标选中的时候进入VIM的可视化模式,而不能复制。使用y
命令也只是VIM内部的复制,不能复制到外部,所以需要将VIM的鼠标模式暂时关闭掉,使用set mouse=
关闭掉即可复制,复制完成后,如果想回到原来的模式,则使用set mouse=a
命令即可恢复。
VIM的鼠标模式可以参见帮助,在VIM中输入命令help mouse
即可查看:
1'mouse' string (default "", "a" for GUI and Win32,
2 set to "a" or "nvi" in defaults.vim)
3 global
4 Enable the use of the mouse. Works for most terminals (xterm, Win32
5 win32-mouse, QNX pterm, *BSD console with sysmouse and Linux console
6 with gpm). For using the mouse in the GUI, see gui-mouse. The
7 mouse can be enabled for different modes:
8 n Normal mode and Terminal modes
9 v Visual mode
10 i Insert mode
11 c Command-line mode
12 h all previous modes when editing a help file
13 a all previous modes
14 r for hit-enter and more-prompt prompt
15 Normally you would enable the mouse in all five modes with:
16 :set mouse=a
17 If your terminal can't overrule the mouse events going to the
18 application, use:
19 :set mouse=nvi
20 Then you can press ":", select text for the system, and press Esc to go
21 back to Vim using the mouse events.
22 In defaults.vim "nvi" is used if the 'term' option is not matching
23 "xterm".
24
25 When the mouse is not enabled, the GUI will still use the mouse for
26 modeless selection. This doesn't move the text cursor.
27
28 See mouse-using. Also see 'clipboard'.
29
30 Note: When enabling the mouse in a terminal, copy/paste will use the
31 "* register if there is access to an X-server. The xterm handling of
32 the mouse buttons can still be used by keeping the shift key pressed.
33 Also see the 'clipboard' option.
即:
- n 普通模式和终端模式
- v 可视模式
- i 插入模式
- c 命令行模式
- h 当使用帮助文件时为所有前面所列模式
- a 所有前面所列模式
- r hit输入和更多提示
- 原文作者:Witton
- 原文链接:https://wittonbell.github.io/posts/2023/2023-09-15-复制远程连接到Linux使用VIM打开的内容到Windows/
- 版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议. 进行许可,非商业转载请注明出处(作者,原文链接),商业转载请联系作者获得授权。