Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 964
lnk3 Avatar asked May 15 '20 16:05

lnk3


People also ask

How do I enable visual blocks in Vim?

To enable the Visual block mode in Vim, you have to try out the “Ctrl+V” command within the normal mode.

How do I copy and paste in Vim WSL?

In that case, I had to get used to use right click as copy and paste, also change the default property of the WSL terminal to use Ctrl+Shift+C and Ctrl+Shift+V as the key combo to copy paste. As a Python developer, I copy and paste code into Vim quite a lot.

Why my WSL is not working?

Ensure that you have the Windows Subsystem for Linux enabled, and that you're using Windows Build version 18362 or later. To enable WSL run this command in a PowerShell prompt with admin privileges: Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux .

How do I run a WSL shell?

To start using WSL, open up a PowerShell terminal and type wsl . If you've set up WSL correctly, you'll enter a bash terminal running on the WSL distro of choice. From here, you can run any Linux commands you wish. Below you will find a reference to all of the options the wsl.exe provides when starting up.


2 Answers

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+, or select Settings in this menu and commenting out the line:

  "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

like image 109
Andras Hegedus Avatar answered Sep 16 '22 19:09

Andras Hegedus


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"
},
like image 36
kalopseeia Avatar answered Sep 17 '22 19:09

kalopseeia