vim - 如何从 Vim 命令行复制文本
问题描述
此处询问了如何粘贴到 vims 命令行中 。但是如何从 vim 命令行复制呢?
例如:
:python 导入系统;打印(sys.executable)
现在我想将该行复制到剪贴板,以便将其粘贴到其他编辑器中。
解决方案
You can assign to a register the content of another register:
:let @+ = @:
Will assign in the system clipboard (@+
) the last executed :
command (@:
).
However, this will become your last executed command. If you want to keep your python
command as the last one, you can do the following:
First open the command history:
q:
Go on the line of the command you want to copy, then yank it in the system register (visually selects the whole line and yanks it):
"+yy
This will copy the whole line with the new line character at the end, if you just want the command without the new line, you can do:
v$h"+y
Finally, close the command history:
:q
推荐阅读
- c# - 数据绑定 Pivot 控件,同时在每个 Pivot 项数据模板内进行数据绑定
- python - PyTorch - 被覆盖的变量是否留在图中?
- erlang - mnesia 表的大小(以 MB 为单位)
- ubuntu - 如何从特定目录中选择日志并在 Kibana 上显示
- java - Parcelable 对象通过通知接收到 null 但在活动之间工作
- android - 在 Activity 类中实现 Google Sign In
- assembly - 组装:什么系统返回?
- c# - 在选择新的实体框架 ASP.net 中使用定义到另一个对象的对象
- angular - 角度材料 - 手动输入错误地转换日期
- pdf - Portlet 应用程序/pdf 不是受支持的 mime 类型错误