Copy vim selected text to system clipboard

vimxsel

My vim is not compiled with clipboard feature. So, i use xsel as suggested by Gilles to copy/paste the contents.

I use :.w !xsel -b for selecting the current line and, :w !xsel -b to select the entire document.

But sometimes, i need to move multiline selection done using V to clipboard. How can i do using xsel?

Note: i tried Ctrl-Shift-c, it didn't work. Anyways, i am not a great fan of Ctrl combo, since it breaks my fingers.

Best Answer

You can still do basically the same thing from visual mode. Once you have the area selected, hit the following1:

:'>,'> !tee >(xsel -b)

You need to pipe to tee so that the contents of your selected area isn't cleared.

1Adapted from here.

Related Question