43

I use WSL Ubuntu and Vim inside the new Windows Terminal, but if I have to enter the visual-block mode with C-v, I can't since it acts as paste.

I am okay with rebinding it to something else but I don't happen to have found the command that I have to add to .vimrc, I think it has something to do with inoremap.

Any advice?

5 Answers 5

61

CTRL+v is bound to paste in Windows Terminal by default. As of now, the only thing that's working is to disable that behaviour in the settings.json. You can do that by pressing CTRL+SHIFT+,.

From version 1.4

  "actions": [
    ...
    // { "command": {"action": "paste", ...}, "keys": "ctrl+v" }, <------ THIS LINE

Pre version 1.4

  "keybindings": [
    ...
    // { "command": "paste", "keys": "ctrl+v" }, <------ THIS LINE

After doing this, you can switch to visual block mode as usual and paste with CTRL+SHIFT+v.

I've found these issues on the project's GitHub about this problem:

https://github.com/microsoft/terminal/issues/5790

https://github.com/microsoft/terminal/issues/5641

Info about the keybindings/actions change: https://learn.microsoft.com/en-us/windows/terminal/customize-settings/actions

As of Windows Terminal version 1.4, the keybindings array has been renamed to actions inside the settings.json file. Support for the keybindings array still exists for backward compatibility, however the terminal will not automatically rename keybindings to actions inside your settings.json file.

4
  • 4
    This works like a charm, you do not even need to restart the terminal session Commented Dec 21, 2020 at 13:09
  • 1
    Nice, gonna give this a try a year from now when Visual Studio finishes opening. Commented Apr 1, 2021 at 3:19
  • 4
    @JamesM.Lay if you drop the "sual Studio" part im sure wait times will decrease ;)
    – Panki
    Commented Oct 8, 2021 at 18:46
  • The "Open JSON" menu entry is no longer there on that menu - at least on my WSL2 Ubuntu system. Commented Jun 22, 2023 at 13:17
16

try Ctrl-q in VISUAL BLOCK mode.

6

You can just change the default "settings.json"

Orignal :

{
    "command": 
    {
        "action": "copy",
        "singleLine": false
    },
    "keys": "ctrl+c" 
},
{
    "command": "paste",
    "keys": "ctrl+v"
},

Modified :

{
    "command": 
    {
        "action": "copy",
        "singleLine": false
    },
    "keys": "ctrl+shift+c"
},
{
    "command": "paste",
    "keys": "ctrl+shift+v"
},
2
  • works for me. If you do not want the ctrl-c and Ctrl-v behavior, you can also delete these two.
    – jdhao
    Commented Sep 1, 2022 at 9:24
  • settings.json is in %LocalAppData%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState by the way. Commented Jun 22, 2023 at 13:24
2

ctrl+v is also important for ":g/pattern/norm". You don't need to change settings.json in order to delete the "ctrl+v" binding, now you can also click on "Actions", scroll to the "paste" binding and delete it (shift+insert will still be available)

0

ctrl-v may be bound to "paste" by Windows Terminal, if you don't want to change configurations, you can simulate key presses by vim commands, such as the following:

:execute "normal \<c-v>"

Note that \<c-v> means Ctrl-V, and it is literally thease chars, no need to press ctrl key.

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