Singlestone
Singlestone

Reputation: 2099

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

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:

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

Upvotes: 1

Views: 1741

Answers (3)

sehe
sehe

Reputation: 392911

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 :)

Upvotes: 0

ak2
ak2

Reputation: 6778

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.

Upvotes: 2

Michael Madsen
Michael Madsen

Reputation: 55009

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.

Upvotes: 1

Related Questions