I'm not sure what information you're missing. No, I didn't read all
the references. As I understand it, you have patched PuTTY to emit
unique character sequences for each of Tab, Ctrl+Tab and
Ctrl+Shift+Tab. The next step is to run vim in that PuTTY, enter
insert mode, type Ctrl-V, then type Tab, then Enter. Repeat this
for Ctrl+Tab, Ctrl+Shift+Tab, and for my own curiosity, Shift+Tab.
The result should be four lines of character sequences. You may
need to ":set list" to see the Tab in the first line. The four
lines should contain unique sequences. If they're not unique, vim
will have no way to distinguish among them. That problem would have
to be fixed within PuTTY.
The terminal I'm using at the moment generates the following
sequence when I type Ctrl-V followed by Shift-Tab:
^[[Z
where the leading ^[ pair represents the single character Escape and
appears in blue on my terminal.
Assuming at this point that PuTTY does generate sequences of
characters when Ctrl+Tab and Ctrl+Shift+Tab are typed and that these
sequences are different from those generated by any other key
combination you care about, here's how you would map the first to
the :tabnext command. First type
:nnoremap
followed by a space, then Ctrl-V, then Ctrl+Tab, another space, then
:tabnext<CR>
That should do it. Mapping Ctrl+Shift+Tab is done the same way.
HTH,
Gary
> My other question though I am still wondering about. What is the
> "correct" escape sequence to duplicate those keyboard commands. I
> mean, Vim already has representations for <C-Tab> and <C-S-Tab>, but
> how do I figure out what those are? Although not necessary, I'd like
> to be able to send the keybindings that vim is actually expecting.
That I don't know. I thought that
:set termcap
might show it, but it doesn't. Using helpgrep didn't turn up
anything useful in the Vim documentation, either. I looked in the
source code and found various definitions for <S-Tab> in the
builtin_termcaps[] array in term.c, but nothing for <C-Tab> or
<C-S-Tab>. You might find a "standard" sequence for those keys in
the documentation for ncurses or xterm (e.g., ctlseqs.txt in the
xterm source directory), but I didn't find anything explicit in the
little bit of searching that I did and I didn't take the time to
read any of it thoroughly.
> Thanks.
You're welcome.
BTW, the convention on this list is to bottom post.
Regards,
Gary
Hm. One comment would be that using a mapping for this isn't such
a good idea; it would be much better to use the method mentioned at
:help :set-termcap
The examples here might be very helpful for that:
http://vim.wikia.com/wiki/VimTip1272
> Yup, those suggestions helped! Thanks for the guidance there, I had
> the pieces I just wasn't connecting them together properly. I was
> having difficulty with the fact that the scnr.net link used "^
> [[27;5;9~" as an escape sequence. As far as I know Vim was only
> recognizing up to the first set of digits. Changing it to something
> like "^[[1337" works.
>
> 1 ^I$ #tab
> 2 ^[[Z$ #shift-tab
> 3 ^[[1337$ #ctrl-tab
> 4 ^[[1334$ #ctrl-shift-tab
No such limitation exists. Vim has no problem reading past a semicolon,
in fact, lots of well-recognized keycodes will have semicolons in them.
For instance, ^[[1;5D is ctrl-left.
> My other question though I am still wondering about. What is the
> "correct" escape sequence to duplicate those keyboard commands. I
> mean, Vim already has representations for <C-Tab> and <C-S-Tab>, but
> how do I figure out what those are? Although not necessary, I'd like
> to be able to send the keybindings that vim is actually expecting.
Terminal vim doesn't necessarily expect the right thing. That being
said, for <Tab>, only ^I is correct. For <S-Tab>, either ^[[Z or
^[[27;2;9~ is correct. For <C-Tab>, only ^[[27;5;9~ is correct, and for
<C-S-Tab>, only ^[[27;6;9~ is correct (vim recognizes neither of these).
In general, the most robust method for representing any keystroke is
CSI 27 ; (modifier mask + 1) ; (decimal number of modified key) ~
where the modifier mask is +1 for shift, +2 for alt, +4 for ctrl - but
vim can't understand keycodes of that type.
~Matt