Skip to main content
22 votes

I Have a Problem with Premature Yanking

The + and * registers can be used to access the clipboard; and you can assign values to registers with let @<register-name>. For example if you've pressed y to yank text to the "0 register: ...
Martin Tournoij's user avatar
15 votes

How can I copy text to the system clipboard from Vim?

If you can't figure out how to get +clipboard to work, which I couldn't for some reason, then you can do this. Assuming you only want to copy a section of the file, I do shift+v to go into visual ...
425nesp's user avatar
  • 576
15 votes
Accepted

I Have a Problem with Premature Yanking

I’m going to go ahead and infer from your use of the word “select”, that you yanked via visual mode. If that’s the case, then you can use gv to reselect the previous selection. You can then yank to ...
Rich's user avatar
  • 32.2k
14 votes
Accepted

Difference between "* and "+ registers in +clipboard VIM?

If you're on Mac or Windows, there's no difference. On Linux they are different. If you only work in Vim, you really don't need either of them (I mean that you can live without them), as they are ...
Enlico's user avatar
  • 2,224
13 votes

Vim on WSL: synchronize system clipboard? (set clipboard^=unnamed)?

I'm aware this is a very old question but I recently found a good solution. After much frustration, I came across these ways to access the windows system clipboard by copying and pasting. By copying, ...
questionmark's user avatar
12 votes
Accepted

Neovim Clipboard Selection

I got around the problem I posted. I am leaving the solution if and when anyone gets stuck in similar situations. Put this snippet into your init.nvim. Then install xclip. For easy manipulation you ...
3N4N's user avatar
  • 5,764
11 votes
Accepted

Copying From Vim to Ubuntu Bash on Windows

Thank you to @Christian Brabandt for linking this in the comments: https://www.reddit.com/r/vim/comments/7pmv3d/workflows_that_work/dskyram/ Works great. Just put the following in your vimrc and make ...
J-Win's user avatar
  • 369
10 votes
Accepted

How to prevent Vim from clearing the system clipboard (:reg +) on exit?

Solution Install a clipboard manager. For example, I use clipmenu. I start it whenever X is started by putting this CM_OWN_CLIPBOARD=1 clipmenud & in my ~/.xinitrc. Why Yours is a common ...
Quasímodo's user avatar
  • 2,466
9 votes

Paste link to image in clipboard when editing Markdown

The following solution should work on most Linux systems. It requires a relatively updated xclip tool. For a solution that works on MacOS/OSX, see @Rich's answer. I've proposed a solution that maps &...
Karl Yngve Lervåg's user avatar
9 votes

Clipboard is reset after first paste in Visual Mode

Use "0p to paste in Visual mode Note that the numbered register "0 can be really useful here, since a default yank also goes to the "0 register, but the text replaced with a put in visual mode only ...
filbranden's user avatar
  • 29k
8 votes
Accepted

Not able to copy from terminal when using vim from homebrew on macOS

There are few thing you can do to solve this. Homebrew compiled Huge version, while default Vim is in Normal version. Huge adds for example clipboard and more mouse/terminal support. This makes ...
grodzik's user avatar
  • 4,658
8 votes

How can I copy over an ssh session without +clipboard?

Depending on your terminal, doing one of the following will allow you to select text that's being displayed in the terminal: holding alt and dragging holding shift and dragging middle/right click ...
Tommy A's user avatar
  • 6,790
8 votes
Accepted

Clipboard is reset after first paste in Visual Mode

Is the clipboard overwritten in Visual Mode each time? Yes it is. How do I get "sane" behavior? That is make the clipboard persist after the first paste. To get "sane" behavior you can remap p ...
Maxim Kim's user avatar
  • 13.6k
7 votes

Difference between "* and "+ registers in +clipboard VIM?

The PRIMARY selection contains the currently selected text. You can paste it with the middle mouse button (or Shift+Insert in some terminals). The CLIPBOARD selection needs to be set explicitly with ...
Martin Tournoij's user avatar
7 votes
Accepted

How do registers + and * interact with suspending Vim via Ctrl-Z?

Note that this is only applicable to Vim on *nix systems with an X server. Let's reduce the test to this: vim -u NONE insert a line of text yank it into either the plus or star register suspend (Ctrl-...
B Layer's user avatar
  • 20k
6 votes

How do you paste what is in your highlight clipboard?

Note: This only applies in unix with X11 environments. The "highlighted text" clipboard is known as the PRIMARY X selection (vs SECONDARY or CLIPBOARD X selections). Vim, when built with X support, ...
John O'M.'s user avatar
  • 8,602
6 votes

How can I copy text to the system clipboard from Vim?

This is the behavior I wanted when it came to the system clipboard: Yanking a line with newline works Yanking a line without newline works Yanking whatever is visually selected works Cut works ...
mbigras's user avatar
  • 647
6 votes

Vim on WSL: synchronize system clipboard? (set clipboard^=unnamed)?

What about this? if system('uname -r') =~ "Microsoft" augroup Yank autocmd! autocmd TextYankPost * :call system('clip.exe ',@") augroup END endif uname is a Linux terminal command which ...
aohmusi's user avatar
  • 59
6 votes

Paste link to image in clipboard when editing Markdown

Based on answers above I've created a Plugin for vim solving my problem for macos and possibly for linux. Hope you'll find this plugin useful. I also appreciate any contributions and feature requests.
Maxim Kochurov's user avatar
6 votes
Accepted

Vi: * and + registers do not exist

I found the answer: Clipboards in linux are handled by the X server. Because I am using an AWS EC2 instance without the X server installed, there is no such thing as a "system clipboard" in Vim and ...
Cat's user avatar
  • 131
6 votes

Install Vim with +clipboard support but without Gvim?

Building Vim from the source with the right flags is the general solution. git clone https://github.com/vim/vim.git cd vim/src ./configure --with-x=yes --disable-gui The last command will probably ...
Quasímodo's user avatar
  • 2,466
5 votes
Accepted

Paste link to image in clipboard when editing Markdown

The usual terminal command for accessing the clipboard on Mac is pbpaste. However, this doesn't work for image data, so we have to resort to AppleScript: nnoremap <silent> <buffer> p :call ...
Rich's user avatar
  • 32.2k
5 votes

How can I copy text to the system clipboard from Vim?

I was struggling with the system clipboard and vim inside tmux. It was solved by using xsel or xclip, like in this example: 1.) visually select a block text in normal mode: V<motionkey> 2.a) ...
MacMartin's user avatar
  • 251
5 votes
Accepted

How to copy the current value of a `set` option into the clipboard?

Just like this let @+ = &statusline Or like this call setreg("+", getbufvar("%", "&statusline")) Or even like this... if has("nvim") call provider#...
Matt's user avatar
  • 20.8k
5 votes
Accepted

Copy vim messages into clipboard

You can typically see the error messages produced by plug-ins using the :messages command. If you'd like to put those messages into a Vim buffer, so that you can copy them to the clipboard from there, ...
filbranden's user avatar
  • 29k
4 votes

How do I copy and paste between two Vim instances - shared clipboard?

I usually end up using xsel to copy to/from the system clipboard: vmap <leader>y !xsel -i -b && xsel -b <CR> nmap <leader>p :r !xsel -b <CR>
Michael Krupp's user avatar
4 votes

Paste clipboard shortcut in vimrc

Assuming Vim has access to the clipboard, you can insert the clipboard contents (in Vim register +) via <C-R><C-R>+ (in insert mode) and via "+p in other modes. Thus, some mappings could ...
Ingo Karkat's user avatar
  • 17.9k
4 votes
Accepted

How can I get more features?

If you want more features (and something more up to date than whats in the apt packages), you have to compile it yourself. You say you are on Debian, and all these should work on that platform. You ...
DoYouEvenCodeBro's user avatar
4 votes
Accepted

How to transfer a register to the system clipboard?

you can try :let @*=@a to assign register a to register *. Same for @+ (depending on which clipboard you want)
Naumann's user avatar
  • 2,759
4 votes

How to transfer a register to the system clipboard?

While let @* and let @+ works, the recommended way to do it in the doc is to use setreg() like this: call setreg('+', @a) See :h setreg() which even contains an example of what you want to do: :...
statox's user avatar
  • 50.1k

Only top scored, non community-wiki answers of a minimum length are eligible