Is there a way to copy a block of text to the system clipboard, so I can paste it in another program?
How can I copy text to the system clipboard from Vim?
cut copy paste;os clipboard
For X11-based systems (ie. Linux and most other UNIX-like systems)there are two clipboards which are independent of each other:PRIMARY - This is copy-on-select, and can be pasted with the middle mousebutton.CLIPBOARD - This is copied with (usually) ^C, and pasted with ^V (It'slike MS Windows).OS X and Windows systems only have 1 clipboard.For X11 systems there are also number of tools that synchronize these clipboardsfor you; so if they appear to be the same, you may have one of them running.Vim has 2 special registers corresponding to these clipboards:* uses PRIMARY; mnemonic: star is select (for copy-on-select)+ uses CLIPBOARD; mnemonic: CTRL + C (for the common keybind)On Windows & OS X there is no difference between + and *, since these systemsonly have a single clipboard, and both registers refer to the same thing (itdoesn't matter which one you use).You can use these registers as any register. For example, using the PRIMARYclipboard * with the y and p commands:*yy*pYou could maybe use this as more convenient keybinds:noremap <Leader>y *ynoremap <Leader>p *pnoremap <Leader>Y +ynoremap <Leader>P +pIf you want to automatically interface with the system's clipboard instead ofreferring to it manually all the time, you can set the clipboard variable:Set it to unnamed to use * (PRIMARY, on select)Set it to unnamedplus to use + (CLIPBOARD, ^C)Now, just using yy will go to the system's clipboard, instead of Vim's unnamedregister, and p will paste the system's clipboard.You can also assign to these registers just like any register with let::let @+=42:let @*=42The clipboard setting has some more options (such as exclude filters); butthese are the basics. See :help 'clipboard' for the full story ;-)gVimIf you use gVim, you can get copy-on-select behaviour when using:set guioptions+=a.This is enabled by default on X11 systems (copies to PRIMARY), but not on MSWindows & OSX (as selecting any text would override your clipboard).No +clipboard?Vim requires the +clipboard feature flag for any of this to work; you cancheck if your Vim has this by using :echo has('clipboard') from within Vim (if theoutput is 0, it not present, if it's 1, it is), or checking the output ofvim --version.Most Linux distributions ship with a minimal Vim build by default, whichdoesn't have +clipboard, but you can usually install it:Debian & Ubuntu: Install vim-gtk or vim-gnome.Fedora: install vim-X11, and run vimx instead of vim (more info).Arch Linux: install gvim (this will enable +clipboard for normal vim as well).You could also use xclip, xcopy, or xsel to copy text to the clipboard;see the following questions for solutions:Define custom commands for the * and + registersHow can I copy over an ssh session without +clipboard?SSHYou can also use a clipboard on remote machines if you enable X11 forwardingover SSH. This is especially useful with the above tip since you can then usexclip to access your desktop's clipboard. The Vim on the machine you'ressh-ing to will still need the +clipboard feature.This requires the ForwardX11Trusted setting, and should only bedone with trusted servers, as this gives the server almost complete controlover your X11 session:$ ssh -XY myhostTo make these settings persistent (so you don't need to add -XY every time),you could  do something like this in your ~/.ssh/config:# Do **NOT** set this globally; it gives the server complete control over# your X11 session.Host myhost    ForwardX11 yes    ForwardX11Trusted yesNeovimNeovim revamped the clipboard support. The built-in interface was removed andreplaced with a system that call an external utility such as xclip, xsel, orpbcopy/pbpaste.It should automatically pick up these utilities and use them. On OS X pbcopyand pbpaste should be available by default, on Linux you probably want toinstall xclip, as that's the most widely available (there are actually twoversions of xsel with incompatible flags. This is really stupid).Also see :help nvim-clipboard.