【问题标题】:Vim: Cannot use Control+Shift+(Left or Right) to select wordVim:无法使用 Control+Shift+(左或右)选择单词
【发布时间】:2018-04-25 13:44:39
【问题描述】:

在 Windows 上,在 Vim 的图形版本中,我使用 Control+Shift+Left(或 Right)在插入模式下选择一个单词。

为了确保没有任何原因导致它失败,我首先停止加载任何初始化文件:

vim -u NONE

然后,在 Vim 中,:behave mswin 设置所有这些班次选择等。

为什么它在gvim 中有效,而在vim 中无效。我可以确保它在我的计算机上没有任何内容,因为我已经停止了所有脚本,在 vanilla 命令提示符下运行 vim 等,但它仍然无法正常工作。我也在另一台电脑上重现了这个问题。

谁能给点建议?

【问题讨论】:

    标签: vim


    【解决方案1】:

    要让Ctrl+Shift+LeftCtrl+Shift+Right 的行为与您的问题中描述的一样,您可以尝试:

    if has('gui_running')                                                           
        ;                                                                           
    else                                                                            
        inoremap <c-s-left> <c-o>db                                                 
        inoremap <c-s-right> <c-o>de                                                
    endif      
    

    这个问题的答案:How to map Ctrl+A and Ctrl+Shift+A differently?解释为什么Ctrl-Shift-Key在某些终端上不起作用。

    【讨论】:

    • 嗨。感谢您提供该问题的链接。我尝试了您的解决方案,但没有奏效。在 Windows 中,Control+Shift+&lt;Key&gt; 可以发送到终端。否则 PSReadline(PowerShell 模块)将无法工作。我相信 Vim 在 Windows 平台上使用控制台 vim 时根本不允许 Control+Shift+&lt;Key&gt; ——它可能是这样编译的,没有配置可以启用它。
    • 也许你是对的。正如 Ingo Karkat 在上面提供的同一链接中所解释的,Ctrl-Shift-&lt;Key&gt; 似乎是一个已知问题,目前没有解决方案。
    【解决方案2】:

    我发现当在控制台 Vim 中使用:behave mswin 时,可以使用Shift-Right 选择单个字符,然后使用Control-Right(即没有Shift)选择下一个单词。

    但是,我有使用Control-Shift 选择单词的习惯,因此我编写了以下 AutoHotkey 脚本来启用它:

    SetTitleMatchMode 2 ; for partial matching of Window Title
    
    #If WinActive("ahk_exe vim.exe") or ((WinActive("ahk_exe cmd.exe") or WinActive("ahk_exe powershell.exe") or WinActive("ahk_exe ConEmu64.exe")) and WinActive("- VIM"))
    
    <^<+Left::
        SendInput +{Left}
        SendInput +{Right}
        SendInput ^{Left}
    return 
    
    <^<+Right::
        SendInput +{Right}
        SendInput +{Left}
        SendInput ^{Right}
    return 
    
    #If
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-03-09
      • 1970-01-01
      • 2020-04-05
      • 1970-01-01
      • 2011-01-08
      • 2014-11-06
      • 2019-04-16
      • 2015-02-02
      相关资源
      最近更新 更多