Visual-Block mode not working in Vim with C-v on WSL@Windows 10
Asked Answered
E

5

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?

Ezraezri answered 15/5, 2020 at 16:35 Comment(0)
C
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.

Camshaft answered 17/7, 2020 at 14:24 Comment(4)
This works like a charm, you do not even need to restart the terminal sessionTimon
Nice, gonna give this a try a year from now when Visual Studio finishes opening.Czarra
@JamesM.Lay if you drop the "sual Studio" part im sure wait times will decrease ;)Mouldon
The "Open JSON" menu entry is no longer there on that menu - at least on my WSL2 Ubuntu system.Djokjakarta
H
17

try Ctrl-q in VISUAL BLOCK mode.

Hogwash answered 24/3, 2023 at 1:45 Comment(0)
R
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"
},
Redmond answered 25/1, 2022 at 10:47 Comment(2)
works for me. If you do not want the ctrl-c and Ctrl-v behavior, you can also delete these two.Tailpipe
settings.json is in %LocalAppData%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState by the way.Djokjakarta
K
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)

Kepi answered 17/7, 2023 at 11:24 Comment(0)
L
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.

Lexie answered 6/6 at 2:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.