复制远程连接到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即可查看:

text 复制代码
'mouse'                 string  (default "", "a" for GUI and Win32,
                                        set to "a" or "nvi" in defaults.vim)
                        global
        Enable the use of the mouse.  Works for most terminals (xterm, Win32
        win32-mouse, QNX pterm, *BSD console with sysmouse and Linux console
        with gpm).  For using the mouse in the GUI, see gui-mouse.  The
        mouse can be enabled for different modes:
                n       Normal mode and Terminal modes
                v       Visual mode
                i       Insert mode
                c       Command-line mode
                h       all previous modes when editing a help file
                a       all previous modes
                r       for hit-enter and more-prompt prompt
        Normally you would enable the mouse in all five modes with:
                :set mouse=a
        If your terminal can't overrule the mouse events going to the
        application, use:
                :set mouse=nvi
        Then you can press ":", select text for the system, and press Esc to go
        back to Vim using the mouse events.
        In defaults.vim "nvi" is used if the 'term' option is not matching
        "xterm".
        
        When the mouse is not enabled, the GUI will still use the mouse for
        modeless selection.  This doesn't move the text cursor.

        See mouse-using.  Also see 'clipboard'.

        Note: When enabling the mouse in a terminal, copy/paste will use the
        "* register if there is access to an X-server.  The xterm handling of
        the mouse buttons can still be used by keeping the shift key pressed.
        Also see the 'clipboard' option.

即:

  • n 普通模式和终端模式
  • v 可视模式
  • i 插入模式
  • c 命令行模式
  • h 当使用帮助文件时为所有前面所列模式
  • a 所有前面所列模式
  • r hit输入和更多提示
相关推荐
爱编程的鱼6 小时前
C# 枚举(Enum)声明与使用详解
java·windows·c#
程序猿(雷霆之王)6 小时前
Linux——进程间通信
linux·运维·服务器
riveting7 小时前
SD2351核心板:重构AI视觉产业价值链的“超级节点”
大数据·linux·图像处理·人工智能·重构·智能硬件
易保山8 小时前
MIT6.S081 - Lab10 mmap(文件&内存映射)
linux·操作系统·c
禅与Bug的修复艺术8 小时前
JAVA后端开发常用的LINUX命令总结
java·linux·面试·java面试·后端开发·java后端·面试经验
北冥有鱼被烹9 小时前
【微知】/proc中如何查看Linux内核是否允许加载内核模块?(/proc/sys/kernel/modules_disabled)
linux·服务器
qq_2739002310 小时前
CentOS系统防火墙服务介绍
linux·运维·centos
小余吃大鱼10 小时前
CentOS中在线安装Docker(超详细)
linux·docker·centos
程序员JerrySUN10 小时前
驱动开发硬核特训 · Day 19:字符设备驱动实战(控制 LED)
linux·驱动开发
小灰灰__10 小时前
Linux安装ffmpeg7.1操作说明
linux·运维·服务器