Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vim mintty/putty mapping <C-Tab> <C-S-Tab>

Tags:

vim

tabs

mapping

Under my gvim I use <C-Tab> and <C-S-Tab> to switch buffers. However in my vim under cygwin/mintty these mapping don't work.

If I try the <C-V><C-Tab> with $vim -u NONE, I get this:

[1;5I for <C-Tab>

[1;6I for <C-S-Tab>

How can I make mappings for such key codes ?

Moreover, If I do :unmap <C-Tab> and press Ctrl+Tab in normal mode, I go to insert mode.

Any clue ?

like image 415
nowox Avatar asked Oct 17 '25 23:10

nowox


1 Answers

You can try to set the terminal's keycodes to vim's keycodes like this:

set <c-tab>=^[[1;5I

Or you may have to find an unusable key, like <f13>, and map it to the terminal code and then map that key to <c-tab>. Like so:

set <f13>=^[[1;5I
map <f13> <c-tab>
map! <f13> <c-tab>

Now I must warn you this approach may not work if your terminal does not send a unique key code to vim.

I personally would simply avoid such a mapping and use something like [b and ]b to move through buffers. Tim Pope's Unimpaired provides these exact mappings and a few more very handy mappings.

Alternatively I would suggest against moving through buffers one at a time. There are better ways to go directly to a buffer:

  • If you know you are returning then set a capital mark e.g. mA and return with 'A
  • Use <c-6> to go to the previous buffer (known as the alternative buffer)
  • Use ctags/cscope to jump directly to where you want to go via <c-]>
  • :b and :sb can take partial filenames and globs. e.g. :b foo and :b foo*bar
  • Use a plugin that helps find a buffer. CtrlP provides a fuzzy finder for buffers

For more help see:

:h tags-and-searches
:h cscope
:h ctrl-6
:h m
:h :b
like image 157
Peter Rincker Avatar answered Oct 19 '25 12:10

Peter Rincker