0

On Windows, within the graphical version of Vim, I an use Control+Shift+Left (or Right) to select a word while in insert mode.

In order to make sure that nothing is causing it to fail, I first stopped any initialisation files from loading:

vim -u NONE

Then, within Vim, :behave mswin, which sets up all these shift selections etc.

Why does it work in gvim and not in vim. I can ensure that it is nothing on my computer, as I have stopped all scripts, run vim in vanilla command prompt, etc, and it still does not work. I have reproduced the problem on a different computer too.

Can anyone advise?

Tahir Hassan
  • 5,715
  • 6
  • 45
  • 65

2 Answers2

1

To have Ctrl+Shift+Left and Ctrl+Shift+Right behave as described in your question you could try:

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

The answers to this question: How to map Ctrl+A and Ctrl+Shift+A differently? explain why Ctrl-Shift-Key will not work in certain terminals.

builder-7000
  • 7,131
  • 3
  • 19
  • 43
  • 1
    Hi. Thank you for the link to that question. I tried your solution and it did not work. In Windows, `Control+Shift+` CAN be sent to the terminal. Otherwise PSReadline (PowerShell module) wouldn't work. I believe Vim simply does not allow `Control+Shift+` when using the console `vim` on the Windows platform -- it is probably compiled as such and no configuration can enable it. – Tahir Hassan Apr 26 '18 at 08:18
  • 1
    Perhaps you're right. As explained by Ingo Karkat in the same link provided above, `Ctrl-Shift-` seems to be a known problem with no present solution. – builder-7000 Apr 26 '18 at 09:10
0

What I have found is that when using :behave mswin in console Vim, you can use Shift-Right to select a single character, but then use Control-Right (i.e. no Shift) to select the next word.

However, I have the habit of using Control-Shift to select words, therefore I wrote the following AutoHotkey script to enable this:

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
Tahir Hassan
  • 5,715
  • 6
  • 45
  • 65