I have the following mappings in my .vimrc:
map <C-S-Tab> :tabprevious<CR>
nmap <C-S-Tab> :tabprevious<CR>
imap <C-S-Tab> <Esc>:tabprevious<CR>i
map <C-Tab> :tabnext<CR>
nmap <C-Tab> :tabnext<CR>
imap <C-Tab> <Esc>:tabnext<CR>i
I want to switch the tabs with Strg+Tab forward and with Strg+Shift+Tab backward. Why does this mapping not work?
Bind Tab+Ctrl+Ansi (or non-ANSI equivalent) to \E[27;5;9~ . In your . vimrc add your bindings in the form of: nnoremap <C-Tab> :tabn<CR> and nnoremap <C-S-Tab> :tabp<CR>
To directly move to first tab or last tab, you can enter the following in command mode: :tabfirst or :tablast for first or last tab respectively. To move back and forth : :tabn for next tab and :tabp for previous tab. You can list all the open tabs using : :tabs. To open multiple files in tabs: $ vim -p source.
Rearranging tabs If you're really meticulous and want to position tabs just so in Vim, you can move the tabs to a specific spot in the tab order using :tabm n , where n is the position number that you want to use. If you don't give the :tabm command an argument, then the current tab will be moved to the last spot.
Are you using xterm
? If so, you can't map ctrl-tab
without a lot of hackery. xterm
and many other terminal emulators don't recognise ctrl-tab
and simply send a tab
character.
See my answer here for more details: Mapping <C-Tab> in my vimrc fails in Ubuntu
Or you can just use gvim
if that is suitable - it should work without any mucking around.
Something is probably blocking vim from seeing the C-Tab. This could be your terminal or your window manager.
On some OSes/WMs you can set exceptions to the window manager shortcuts, but how you do this varies crazily between the WMs.
I'm not sure if there is a solution if it is your terminal blocking the key presses.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With