lnk3
lnk3

Reputation: 653

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

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?

Upvotes: 47

Views: 27011

Answers (5)

kalopseeia
kalopseeia

Reputation: 83

You can just change the default "settings.json" as below. To find it, enter the following (credit: @user2023370) in an explorer window:

%LocalAppData%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState

Original :

{
    "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"
},

Upvotes: 6

user2204107
user2204107

Reputation: 190

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.

Upvotes: 1

uriya
uriya

Reputation: 21

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)

Upvotes: 2

Andras Hegedus
Andras Hegedus

Reputation: 910

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.

Upvotes: 68

Professor哥
Professor哥

Reputation: 397

try Ctrl-q in VISUAL BLOCK mode.

Upvotes: 28

Related Questions