简体   繁体   English

从Linux命令行复制到Vim

[英]Copy from Linux command line to Vim

I want to copy an alias from my Ubuntu 14.04 command line to my .bashrc file (to make this alias always available). 我想将别名从Ubuntu 14.04命令行复制到我的.bashrc文件中(以使此别名始终可用)。

I have: 我有:

ubuntu@ip-172-31-22-65:~$ alias foo='cd /home/ubuntu/projects/tp; workon env1'

I performed Ctrl + U to copy it then 我执行了Ctrl + U来复制它

ubuntu@ip-172-31-22-65:~$ vim .bashrc

However when I use "p" in Vim I see: 但是,当我在Vim中使用“ p”时,我看到:

"Nothing in register"

How can I copy from the command line to my file? 如何从命令行复制到文件?

Mark the line with the mouse and press the middle mouse button (or right mouse button if you are on Windows using SSH to access the Linux machine) to paste it. 用鼠标标记该行,然后按鼠标中键(如果在Windows上使用SSH访问Linux计算机,则按鼠标右键)。 Or use "*p to paste from the system clipboard. 或使用“ * p”从系统剪贴板粘贴。

One of two ways: 两种方式之一:

Go into insert mode in Vim, then enter Ctrl + Shift + V . 在Vim中进入插入模式,然后输入Ctrl + Shift + V。

The other way is to use the unnamed register (either * or + ) and in command mode you would enter "+p or "*p . 另一种方法是使用未命名的寄存器( *+ ),并在命令模式下输入"+p"*p However I found that it just puts empty lines in my file (on CrunchBang Linux ). 但是我发现它只是在我的文件中放置了空行(在CrunchBang Linux上 )。

This link also describes a good mapping for Ctrl + V and ctrl + C for Vim. 链接还描述了Vim的Ctrl + Vctrl + C的良好映射。 But there are good reasons not to overload Ctrl + C on Linux. 但是有充分的理由不要在Linux上重载Ctrl + C

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM