wsl vim无法复制到系统剪贴板,解决方法

当在Windows Subsystem for Linux (WSL)中使用vim时,发现无法将内容复制到系统剪贴板。原因是默认安装的vim缺少clipboard支持。解决方法是通过安装vim-gtk3来获取完整功能。在安装后,vim便能正常与系统剪贴板交互,提升Linux在Windows环境下的使用体验。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

工作原因现在改用windows了,有些不习惯,又不想使用虚拟机,于是尝试使用wsl。不知道会有多少坑。现在的坑是vim无法复制到系统的剪贴板里。

具体可通过一下命令确认:

$ vim --version | grep "clipboard"
-clipboard         +keymap            +printer           +vertsplit
+emacs_tags        +mouse_gpm         -sun_workshop      -xterm_clipboard

科学上网稍微看了下,原因大概就是wsl里面装的是阉割版本的vim,想要使其支持系统剪贴板,需要

No +clipboard?
Vim requires the +clipboard feature flag for any of this to work; you can check if your Vim has this by using :echo has('clipboard') from within Vim (if the output is 0, it's not present, if it's 1, it is), or checking the output of vim --version for +clipboard.

Most Linux distributions ship with a "minimal" Vim build by default, which doesn't have +clipboard, but you can usually install it:

Debian & Ubuntu: Install vim-gtk3.

参考How can I copy text to the system clipboard from Vim?

安装vim-gtk3后,可以拷贝到系统剪贴板了。Great

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值