Ubuntu – Keyboard shortcut for pasting the primary selection

clipboardkeyboardshortcut-keys

Is there a standard or conventional keyboard shortcut for pasting the primary selection?

I'd like to select some text and go to another app to paste without trashing my clipboard contents. I'd rather keep my fingers on the keyboard than move to the mouse, find the pointer, position it where I want, and middle-click.

If there's nothing conventional, or if it's application-specific and unsupported by many, is there a workaround to get this working globally? (Or at least in more applications.)

Best Answer

Sending virtual keypresses doesn't work for me (see comments), but that answer inspired me to look for similar solutions. Sending a "text" event with xvkbd ignores the current state of your physical keyboard:

sh -c 'xsel | xvkbd -xsendevent -file - 2>/dev/null'

xvkbd -text uses a few backslash sequences, so rather than dance with escaping, -file works. Add -delay 0 to enter the text without delay between the “keystrokes”. xvkbd also outputs some warning text about modifiers, but it appears to be irrelevant to this use (but I didn't want to see it in ~/.xsession-errors).

I bound this to a shortcut using System > Preferences > Keyboard Shortcuts.

Note that you need to have xsel and xvkbd packages installed:

sudo apt-get install xsel xvkbd