Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vim cant map <C-Tab> to :tabnext

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?

like image 744
f00860 Avatar asked Jun 04 '10 23:06

f00860


People also ask

How do I map Ctrl tab in Vim?

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>

How to change tabs in nvim?

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.

How do I move a tab in Vim?

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.


2 Answers

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.

like image 81
nfm Avatar answered Oct 01 '22 16:10

nfm


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.

like image 31
Michael Anderson Avatar answered Oct 01 '22 18:10

Michael Anderson