VIM Ctrl-V Conflict with Windows Paste

前端 未结 8 1666
忘了有多久
忘了有多久 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:04

    I'm not sure there is a lot you can do about that. You can use CtrlQ instead though.

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

    If this line in your _vimrc troubles you:

    behave mswin
    

    then delete that line.

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

    From the VIM documentation:

    Since CTRLV is used to paste, you can't use it to start a blockwise Visual selection. You can use CTRLQ instead. You can also use CTRLQ in Insert mode and Command-line mode to get the old meaning of CTRLV. But CTRLQ doesn't work for terminals when it's used for control flow.

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

    The combination of jop's advice (looking for mswin.vim in the default _vimrc file) and "Windows programmer's" advice (getting rid of the "behave mswin" line) worked like a charm for me.

    (my rep is too low to vote them up or combine them -- someone clean this up for me, or I'll come back once my rep is higher)

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

    Visual mode (and other stuff) working like in Unix requires both JOP's and Windows Programmer's suggestions.

    In GVim on Windows, go to the edit menu, click on startup settings, and comment out the windows-specific garbage (using the vimrc comment character, which is a double-quote). The mswin.vim file is where the ctrl-v override is specified, and the behave mswin option makes it so that the arrow keys don't just apply motion like you'd expect (it also changes the mouse selection behavior).

    "source $VIMRUNTIME/mswin.vim
    "behave mswin
    

    I like to add a black-background colorscheme in there as well, so it looks more like what I'd see in a terminal (and because a light background is great on paper, but awful on a backlit screen): colorscheme koehler

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

    I prefer the same keystrokes everywhere so I use this in my .vimrc to override mswin.vim:

    if has('win32')
      " Avoid mswin.vim making Ctrl-v act as paste
      noremap <C-V> <C-V>
    endif
    
    0 讨论(0)
提交回复
热议问题