如何在vim中全选并复制? [英] How to select all and copy in vim?

查看:48
本文介绍了如何在vim中全选并复制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在vim插入模式下全选并复制?有没有其他方法可以在正常模式下做到这一点?

how to select all and copy in vim insert mode? and is there another way to do it in normal mode?

我尝试过使用视觉模式和 gg 和 shift + gg 来全选然后猛拉,但这并不能将其传输到剪贴板以便能够将其粘贴到其他应用程序(如 Skype 或 Chrome 浏览器)中.

I have tried visual mode and gg and shift + gg to select all and then yank, however that doesn't transfer it to the clipboard to be able to paste it in another application like skype or chrome browser.

我相信这是一项常见的任务,有很多比我更聪明的人的品种,请随时分享你的.

I am sure this is a common task, and there are a lot of varieties by smarter ppl than me out there, please feel free to share yours.

推荐答案

您的问题中遗漏了一些重要信息:

There are a few important informations missing from your question:

  • $ vim --version 的输出?
  • 操作系统?
  • CLI 还是 GUI?
  • 本地还是远程?
  • 你使用 tmux 吗?屏幕?

如果你的 Vim 是用剪贴板支持构建的,你应该像这样在正常模式下使用剪贴板寄存器:

If your Vim was built with clipboard support, you are supposed to use the clipboard register like this, in normal mode:

gg"+yG

如果您的 Vim 不支持剪贴板,您可以设法通过其他程序将文本从 Vim 复制到您的操作系统剪贴板.这在很大程度上取决于您的操作系统,但您没有说明它是什么,因此我们无法真正提供帮助.

If your Vim doesn't have clipboard support, you can manage to copy text from Vim to your OS clipboard via other programs. This pretty much depends on your OS but you didn't say what it is so we can't really help.

但是,如果您的 Vim 瘫痪,最好的办法是安装具有剪贴板支持的正确版本,但我也无法告诉您如何操作,因为我不知道您使用的是什么操作系统.

However, if your Vim is crippled, the best thing to do is to install a proper build with clipboard support but I can't tell you how either because I don't know what OS you use.

编辑

在基于 debian 的系统上,以下命令将安装具有剪贴板、ruby、python...支持的正确 Vim.

On debian based systems, the following command will install a proper Vim with clipboard, ruby, python… support.

$ sudo apt-get install vim-gnome

这篇关于如何在vim中全选并复制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆