In applications like Firefox Ctrl-Insert and Shift-Insert work like Ctrl-c and Ctrl-v (modifying the secondary clipboard), but in XTerm they do not work like the common Ctrl-Shift-c and Ctrl-Shift-v:

  1. Ctrl-Insert does not change the clipboards, and instead prints literally ;5~ on the current prompt.
  2. Shift-Insert pastes the primary clipboard instead of the secondary.

Can I fix this in .inputrc or otherwise? It would be nice to have two-stroke cross-platform cut and paste shortcuts everywhere.


xterm, whose conventions were established many years before Firefox, and even the web, was invented, is controlled by application resources. These are merged from several places, including files like /usr/share/X11/app-defaults/XTerm, and also information held by the X11 server seen with xrdb -q. You can override these resources by placing, for example, things like the following in the file ~/.Xdefaults:

XTerm*VT100.Translations:       #override\n\
 Shift Ctrl <KeyPress> v: insert-selection(CLIPBOARD)\n\
 Shift Ctrl <KeyPress> c: copy-selection(CLIPBOARD)\n

This binds ctrl-shift-v to inserting the clipboard contents. I'm not clear exactly what you wanted, so check the man page for the functions and the PRIMARY, SECONDARY and CUT_BUFFER0 selections.

You can presumably add (don't forget the backslash on preceding lines):

Shift <Key>Insert: insert-selection(SECONDARY)\n\
Ctrl  <Key>Insert: copy-selection(SECONDARY)\n

This is similar to How can I copy text from xterm (Awesome, Debian, VirtualBox)?, including part of the suggested answer.

However: by way of background, xterm receives X events (which you can see using xev), and handles those in different ways:

  • for controlinsert, xterm sees the events for the control- and insert-keys, and constructs a sequence of characters to send to your application, e.g., ^[[28;5~
  • shiftinsert is handled differently because it is part of the default translations resource for xterm. That is a feature of the X Toolkit library which comes before xterm can see the events. In the translations resource, that is this line:
      Shift  Insert:insert-selection(SELECT, CUT_BUFFER0) \n\

The SELECT keyword in this resource is interpreted by xterm to be either PRIMARY or CLIPBOARD, depending on the selectToClipboard resource (or the Select to Clipboard menu entry). By the way, CLIPBOARD is not the secondary selection. See The SECONDARY Selection in the ICCM for a description of the secondary selection.

You can enable the selectToClipboard resource by adding this to your $HOME/.Xdefaults file (or other resource file, even using xrdb):

xterm*selectToClipboard: true

You can also add translations using control and shift modifiers (in either order), and the insert key. Adapting my answer in the other question:

xterm*VT100.Translations: #override \
                 Shift <Key>Insert:    insert-selection(SELECT) \n\
                 Ctrl <Key>Insert:     copy-selection(SELECT) \n\
                 Ctrl Shift <Key>V:    insert-selection(SELECT) \n\
                 Ctrl Shift <Key>C:    copy-selection(SELECT)

The translations parser in X Toolkit recognizes a variety of spellings for the keywords. Thus Key is the same as KeyPress and KeyDown. But Ctrl is the only way it knows for the control key.

While you could add controlC and controlV, this is generally not recommended because those control keys are useful (by default) in your terminal:

$ stty -a
speed 38400 baud; rows 40; columns 80; line = 0;
intr = ^C; quit = ^\; erase = ^H; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 -hupcl -cstopb cread -clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff
-iuclc -ixany -imaxbel -iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke

Further reading:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.