Last Updated: February 25, 2016
·
609
· dechimp

Simple vimrc setting to map leader-1 to "switch to tab 1", and so on

I use this when running console vim in tmux and iterm, because the command key is disabled (for cmd+}) and I don't like to type 3gt to switch tabs.

add to your vimrc:

" map <leader>1 to tab 1, <leader>2 to tab 2, etc
let i = 1
while i<=8
  exec "nnoremap <Leader>".i." ".i."gt"
  let i+=1
endwhile
" map leader-9 to the very last tab
nnoremap <leader>9 :tabl<CR>

1 Response
Add your response

I also added this to map <leader>] and <leader>[ to tab left and right

nnoremap <leader>[ :tabp<CR>
nnoremap <leader>] :tabn<CR>
over 1 year ago ·