开发者

How to map Shift-Tab in vim? (Cygwin, Windows cmd.exe)

开发者 https://www.devze.com 2023-03-08 04:20 出处:网络
I see a few entries here about making Shift-Tab work in vim, but none of them addresses the failure when it\'s in Cygwin, running at a Windows command prompt. In that environment, Shift-Tab works for

I see a few entries here about making Shift-Tab work in vim, but none of them addresses the failure when it's in Cygwin, running at a Windows command prompt. In that environment, Shift-Tab works for me exactly like an unshifted tab, and my attempts at remapping have failed:

  • :imap <S-Tab> ^D [ this is a real Ctrl-D, entered with Ctrl-V before it ]
  • :imap [ typed Ctrl-V, Shift-Tab here; got a Tab character inserted ]开发者_JAVA百科

So it seems that the Shift modifier is being ignored. Any thoughts about how to proceed? Thanks.


That won't work in the Cygwin console because it sends the same keycode for both Tab and Shift+Tab: ^I.

You might want to install Cygwin's mintty terminal emulator, which sends the standard keycode for Shift+Tab: \e[Z.


Instead of messing with the Cygwin version, I suggest you remove it and install the native version instead. With that, you can map Shift-Tab without issues, even when starting Vim from a bash shell.


I don't have windows right here now, but look whether your vimrc contains

behave mswin
source ...\mswin.vim

In that case,

:e +g/mswin/norm!\ 0i" $MYVIMRC

should automatically comment these out. Relaunch vim, and inspect whether there are existing mappings:

:verbose map <S-Tab>

will show you any existing mappings, and where it was last defined, so you can find the script/plugin that is causing this (:he :verbose-cmd)

HTH


Update to the comment:

Well - blimey, turns out that Shift-Tab is magically impossible with Win32 Consoles. Never noticed.

Perhaps it is because I

  • use mintty these days, to provide a much better experience (Unix like copy pasting, real alternative terminals, more performance, and re-attaching screen sessions, e.g.)
  • might have tweaked the CompletionChar setting although this seems like a loose fodder even to me

Could you try with mintty? I'd think I'd have noticed such a hairy incompatibility over the years. But, you never know :)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号