VIM Ctrl-V Conflict with Windows Paste

前端 未结 8 1667
忘了有多久
忘了有多久 2020-12-12 11:27

I am using VIM in Windows. The problem is that I want to use CtrlV as a visual mode. However, this key has conflict with Windows paste. How can I reset

相关标签:
8条回答
  • 2020-12-12 12:21

    Check your _vimrc file and see if it sources mswin.vim. That script maps the ^v to the paste. You can either remove that line on your _vimrc file or disable the mapping commands directly on mswin.vim.

    Do a :help behave on vim for more info.

    0 讨论(0)
  • 2020-12-12 12:21

    Here's a modern day solution to this problem. It applies to the terminal version of Vim/Neovim, not the GUI version. If you use Microsoft's new-ish Windows Terminal (I highly recommend it.), you can redefine its key bindings to your advantage. The following section of the settings file is initially NOT commented out. If you comment it out, as I've shown, Ctrl+V becomes the rectangular visual select key in Vim we all know and love.

    // 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"
    //}
    

    Now here's the weird part. I'd expected this to change the behavior of Ctrl+V outside of Vim in the Terminal, so I checked. It still does a paste, but it's different than the Ctrl+Shift+V paste. Inside Vim, however, all is good: Ctrl+V for rectangular select; and "*P, Ctrl+Shift+V, or Right Mouse Button for pasting from the clipboard.

    0 讨论(0)
提交回复
热议问题