1

With the newly released Windows 10 update 2004, we can run native Windows Subsystem for Linux (WSL) 2 and install Ubuntu 20.04 on it. Then we can run native bash inside the latest Windows Terminal. However, when I run vim in it, I have trouble with vim's visual block selection: :

  1. In this environment, both <c-v> and <c-V> are used for Windows Copy;
  2. Since this vim is running in a "pure" linux environment, it has nothing to do with mswin.vim;
  3. I tried <c-q> and it doesn't work;

What's the most organic solution for resolving this issue? Is mapping a different key, like <c-q> acting as visual block selection the only one?

Thanks!

3
  • Welcome to Vi and Vim!
    – filbranden
    May 29, 2020 at 4:50
  • (P.S. <C-v> and <C-V> are probably the same if the environment faithfully replicates terminal handling; the two are indistinguishable as key 0x16.) What happens when you press <C-q>? If you haven't disabled control flow, it may not get to vim to start visual-block mode (:help CTRL-V-alternative)
    – D. Ben Knoble
    May 29, 2020 at 13:38
  • Hi Ben Knoble, nothing happens when I press <C-q> in normal mode. How can I disable the control flow then and what's the side effects of it? Thanks!
    – Kevin Wang
    Jun 3, 2020 at 17:39

1 Answer 1

2

The solution I found to this problem is to comment out the lines in the Windows Terminal settings.json binding copy and paste to Ctrl+C and Ctrl+V respectively. By default, they are bound to Ctrl+Shift+C and Ctrl+Shift+V.

 "keybindings":
    [
        // Copy and paste are bound to Ctrl+Shift+C and Ctrl+Shift+V in your defaults.json.
        // These two lines additionally bind them to Ctrl+C and Ctrl+V.
        // To learn more about selection, visit https://aka.ms/terminal-selection
        // { "command": {"action": "copy", "singleLine": false }, "keys": "ctrl+c" },
        // { "command": "paste", "keys": "ctrl+v" },     

    ]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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