复制远程连接到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输入和更多提示
相关推荐
嘿嘿嘿x38 分钟前
Linux记录过程
linux·开发语言
handsomestWei8 分钟前
claude-code在win环境安装使用
windows·ai编程·claude·安装配置·cc-switch
秦时明月之君临天下36 分钟前
Windows如何删除任务管理器中的某个服务?
windows
麦田里的守望者_zhg1 小时前
Windows 执行 wsl --update 报错 1603:注册表权限导致 WSL 安装损坏问题排查与修复
windows
程序猿编码1 小时前
一个授予普通进程ROOT权限的Linux内核级后门:原理与实现深度解析
linux·运维·服务器·内核·root权限
小夏子_riotous1 小时前
openstack的使用——9. 密钥管理服务Barbican
linux·运维·服务器·系统架构·centos·云计算·openstack
六点的晨曦3 小时前
VMware安装Ubuntu的记录
linux·ubuntu
❆VE❆3 小时前
Claude Code 安装与配置完整指南(Windows)
windows·claude code
w6100104663 小时前
CKA-2026-Service
linux·服务器·网络·service·cka
HXQ_晴天3 小时前
castor什么时候已有的 .cdh 数据可以直接用,不需要重新从 root 转换?
linux