How to make vim paste from (and copy to) the system clipboard?

This article was translated from: How to make vim paste from (and copy to) system's clipboard?

Unlike other editors, vim stores copied text in its own clipboard. Unlike other editors, vim stores copy text to their own clipboard. So, it's very hard for me to copy some text from a webpage and paste it into the current working file. Therefore, it is difficult for me to copy some text from the webpage and paste it into the current working file . It so happens I have to either open gedit or type it manually. It happens that I have to open gedit or type it manually .

Can I make vim paste from and to the system's clipboard? Can I make vim paste on the system's clipboard ?


#1st Floor

Reference: https://stackoom.com/question/mCvM/ How to make vim paste from-and copy to-system clipboard


#2nd Floor

The "*and "+registers are for the system's clipboard ( :help registers). "*And "+:help registers registers are for the system's clipboard ( ). Depending on your system, they may do different things. Depending on your system, they may do different things . For instance, on systems that don't use X11 like OSX or Windows, the "*register is used to read and write to the system clipboard. On X11 systems both registers can be used. See :help x11-selectionfor more details, but basically the "*is analogous to X11's PRIMARY selection (which usually copies things you select with the mouse and pastes with the middle mouse button) and "+is analogous to X11's CLIPBOARD selection (which is the clipboard proper). For example, on systems that do not use X11 (such as OSX or Windows) ,"*The registers are used to read and write to the system clipboard. On X11 systems, two registers can be used. For details, please refer to :help x11-selection, but it is basically "*similar to X11's PRIMARY selection (usually copy what you select with the mouse and paste with the middle mouse button), "+similar to X11's CLIPBOARD selection (this is the clipboard itself).

All that Wentworth over your IF head, a using the try "*yyor "+yyto Copy A Line to your System's Clipboard. If all of these are over your head, try to use "*yyor "+yyto copy to the clipboard line system. Assuming you have the appropriate compile options, one or the other should work. Assuming you have the appropriate compile options, then one or the other should work . You might like to remap this to something more convenient for you. You may want to remap it to a more convenient place. For example, you could put vnoremap <Cc> "*yin your ~ / .vimrc so that you can visually select and press Ctrl+ cto yank to your system's clipboard. For example, you can put vnoremap <Cc> "*yin ~ / .vimrc so you can intuitively select and press Ctrl+ cTo drag to the system clipboard.

Be aware that copying / pasting from the system clipboard will not work if :echo has('clipboard')returns 0. In this case, vim is not compiled with the +clipboardfeature and you'll have to install a different version or recompile it. Please note that if it :echo has('clipboard')returns 0, then Copy / paste from the system clipboard will not work. In this case, vim does not use the +clipboardfunction to compile, you must install a different version or recompile it. Some linux distros supply a minimal vim installation by default, but generally if you install the vim-gtkor vim-gtk3package you can get the extra features. By default, some Linux distributions provide a minimal vim installation, but usually if you install vim-gtkor vim-gtk3package , You can get extra features.

Also May want to have have by You A look at The AT 'clipboard'the Option Described AT :help cb. You can also view the below 'clipboard'options :help cb. In this case you can :set clipboard=unnamedor :set clipboard=unnamedplusto make all yanking / deleting operations automatically copy to the system clipboard. In this case, you can :set clipboard=unnamedor :set clipboard=unnamedplusto make all :set clipboard=unnamedplus/ :set clipboard=unnamedplusoperation automatically copy to the system clipboard. This could be an inconvenience in some cases where you are storing something else in the clipboard as it will override it. In some cases, if you store other content in the clipboard because it will overwrite it, this may bring Inconvenient.

Paste you CAN use the To "+por "*p(Again, DEPENDING ON your System and / or Desired Selection) or the Map you CAN THESE something to the else. To paste, you can use "+por "*p(Again, depending on your system or the desired selection and / ), Or you can map these to other content. I type them explicitly, but I often find myself in insert mode. I type them explicitly, but I often find myself in insert mode . If you're in insert mode you can still paste them with proper indentation by using <Cr><Cp>*or <Cr><Cp>+. If you are in insert mode, you can still use them <Cr><Cp>*or <Cr><Cp>+paste them into the appropriate indentation. See :help i_CTRL-R_CTRL-P. See :help i_CTRL-R_CTRL-P.

It's also worth mentioning vim's pasteoption ( :help paste). It is also worth mentioning vim's pasteoption ( :help paste). This puts vim into a special "paste mode" that disables several other options, allowing you to easily paste into vim using your terminal emulator or multiplexer's familiar paste shortcut. This makes vim enter a special "paste mode" that disables several others The option allows you to easily paste into vim using the familiar terminal shortcuts of emulators or multiplexers. Simply type :set pasteto enable it, paste your content and then type :set nopasteto disable it. Just type :set pasteto enable it, paste your content, and type :set nopasteto disable it. Alternatively, you at The CAN use pastetogglethe Option to the SET A Toggles at The keyCode that the MODE ( :help pastetoggle). Alternatively, you can use the pastetogglekey code option to set the mode switch ( :help pastetoggle). I recommend using registers instead of these options, but if they are still too scary this can be a convenient workaround while you're perfecting your vim chops. I recommend using registers instead of these options, but if they are still too scary , then when you This might be a convenient solution when perfecting your vim seal.

See :help clipboardfor the Detailed More Information. See :help clipboardfor more details


#3rd floor

Linux Linux

On my Linux system, the +and *registers map to an X11 selection, which can be pasted with the middle mouse button. On my Linux system, +and *registers are mapped to X11 selection, you can use the middle mouse button to paste. When :set clipboard=unnamedand :set clipboard=unnamedplusare used, then the registers map to the clipboard, and can be pasted with CTRL-V. When and are used, registers are mapped to the clipboard and can be pasted with CTRL-V .:set clipboard=unnamed:set clipboard=unnamedplus

The specifics seem to be somewhat configuration and system dependent, so your mileage will definitely vary. The specific details seem to be related to the configuration and system, so your mileage will definitely be different. It should definitely get you pointed in the right direction, though. However, it will definitely get you pointed in the right direction .

See Also can also look at

http://vim.wikia.com/wiki/Accessing_the_system_clipboard http://vim.wikia.com/wiki/Accessing_the_system_clipboard


#4th floor

You can copy into vim by gnome-terminal's shortcut for paste. You can copy into vim by gnome-terminal shortcut to paste. Make the file in insert mode and use the file in insert mode and use

Ctrl + Shift + v . Ctrl + Shift + v

Remember beforehand to advance to remember

 :set paste 

to avoid messing with the indentation .


#5th Floor

This would be the lines you need in your vimrc for this purpose: This would be the lines you need in your vimrc for this purpose :

set clipboard+=unnamed  " use the clipboards of vim and win
set paste               " Paste from a windows or from vim
set go+=a               " Visual selection automatically copied to the clipboard

#6th floor

For my that configuration works for copying and pasting

" copy and paste
vmap <C-c> "+yi
vmap <C-x> "+c
vmap <C-v> c<ESC>"+p
imap <C-v> <ESC>"+pa
Published 0 original articles · praised 75 · 560,000 views +

Guess you like

Origin blog.csdn.net/w36680130/article/details/105485300