Sharing of VIM clipboard and system clipboard (Linux)

Source: Internet
Author: User

No, when you get used to vim and bring fun to your programming, you will enjoy it more and more!

In the past, when we started using vim, the mouse in VIM didn't provide the same functionality as other editors, and we couldn't control the cursor movement under vim, at that time, I was not familiar with vim's mobile commands, so every time I moved, I had a great deal of effort. Later, we found that Vim can also be moved with the mouse. To implement this function, you only need to simply add a command in vimrc:

Set mouse =

It wasn't long before you found a new problem: After you set mouse = A, the content in VIM could not be copied, copy From Vim to the clipboard of the system.

At that time, I was very upset. Sometimes, I don't even look at the content in Vim, And then I beat it manually.

After a few times, this is definitely not the case, and how can the clever Vim not even think of such a thing.

After searching for some information, I finally found the solution:

In fact, VIM supports sharing with the system clipboard, only because some systems are not installed.

Like my system: ubuntu9.10 is not installed. Install it now:

Sudo apt-Get install vim-gnome

Sudo apt-Get install vim-Gui-common

Sudo aptitude install vim-full

 

After installation:

Copy From Vim to system clipboard:

In the V mode, select the content to be copied (that is, in visual mode, if you do not understand Google), and then in the command mode, "+ Y

In this way, the selected content is copied to the clipboard of the system.

It is easy to copy the content on the system clipboard to VIM. In command mode, "+ P

In this way, the content on the system clipboard is pasted into vim.

 

In vim, the system clipboard is associated with the vim register +. Therefore, any copy and paste of register ++ directly affects the system clipboard.

There are more than 10 registers in VIM for you to use. The usage is the same as "+ Y," + P. To view the content of all registers, you only need to: Reg in command mode.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.