19
# When I do just Shift-Insert, I get
~$ 2~
# When I do Ctrl-V, then Shift-Insert, I get
~$ ^[[2;2~

Shift-insert works well in other situations, like Windows CMD or Git-Bash

In wsl, I can use Ctrl-Shift-V to paste, but prefer shift-insert.

Is there any work-around ?

1
  • 1
    You can use wsltty; this supports Ctrl+Ins/Shift-Ins out of the box May 29, 2020 at 4:04

3 Answers 3

7

According to microsoft/WSL:

Note that WSL distro's launch in the Windows Console (unless you have taken steps to launch a 3rd party console/terminal). Therefore, please file UI/UX related issues in the Windows Console issue tracker.

But the given link for Windows Console points to Windows Terminal:

The new Windows Terminal and the original Windows console host, all in the same place!

There's no (usable) documentation, so your question has to be answered by pointing into its source-code.

The relevant chunk (which you'd like to exercise) is here, in windowio.cpp:

    // handle shift-ins paste
    if (inputKeyInfo.IsShiftOnly() && ShouldTakeOverKeyboardShortcuts())
    {
        if (!bKeyDown)
        {
            return;
        }
        else if (VirtualKeyCode == VK_INSERT && !(pSelection->IsInSelectingState() && pSelection->IsKeyboardMarkSelection()))
        {
            Clipboard::Instance().Paste();
            return;
        }
    }

Half of the conditions (to reach that Paste()) appear likely to be met (barring some bug in this program). The ones that aren't apparent:

  • ShouldTakeOverKeyboardShortcuts() — but this is used in the ctrl+shift+plus/minus code

  • pSelection->IsKeyboardMarkSelection() — we're assuming the mouse was used for selection.

But that's assuming that this HandleKeyEvent method is treating the two different key sequences equally. The ^[[2;2~ comes from another part of the program, in terminalInput.cpp, using a built-in table

// Sequences to send when a modifier is pressed with any of these keys
// Basically, the 'm' will be replaced with a character indicating which
//      modifier keys are pressed.
static constexpr std::array<TermKeyMap, 22> s_modifierKeyMapping{

and applied here:

// If a modifier key was pressed, then we need to try and send the modified sequence.
if (keyEvent.IsModifierPressed() && _searchWithModifier(keyEvent, senderFunc))
{
    return true;
}

From reading the code, it appears that this is all upstream from the windowio.cpp logic, so that combination will never be reached. The developers provided no way to override or modify this behavior.

As suggested in a comment by @Rody-Oldenhuis:

You can use wsltty; this supports Ctrl+Ins/Shift-Ins out of the box

(which is derived from mintty).

5

If you run WSL using Windows Terminal, Shift-Insert works out of the box for Paste. (And Ctrl-Insert also works for Copy, as you might expect)

4
  • not in all versions
    – CervEd
    Mar 2, 2023 at 11:27
  • @CervEd which versions don't work? I'll update my answer if you tell me
    – artbristol
    Mar 3, 2023 at 11:24
  • 1
    false alarm, turns out it's just the useless HP keyboard that pretends it has an insert key. If anyone wonders fn + e is insert 🤷‍♂️ h30434.www3.hp.com/t5/Business-Notebooks/…
    – CervEd
    Mar 5, 2023 at 8:21
  • Hard to believe one still needs to install another tool (Windows Terminal) and there is no working keyboard shortcut for Paste in the default WSL terminal (unless one activates the "Use Ctrl+Shift+C/V as Copy/Paste" in its options). Jul 22, 2023 at 14:51
-3

Not quite sure why you want to use shift+insert to paste or how to remap it, but default paste is as simple as a right mouse button click.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .