Session management is provided by tpope/vim-obsession. Tab rename function is provided by gcmt/taboo.vim.
In ~/.vimrc:
" Customize tabline
hi TabLineFill term=bold cterm=bold ctermbg=0
hi TabLine ctermfg=Yellow
" Taboo
set sessionoptions+=tabpages,globals
cabbrev tr TabooRename
" tab switching shortcuts
noremap <leader>1 1gt
noremap <leader>2 2gt
noremap <leader>3 3gt
noremap <leader>4 4gt
noremap <leader>5 5gt
noremap <leader>6 6gt
noremap <leader>7 7gt
noremap <leader>8 8gt
noremap <leader>9 9gt
noremap <leader>0 :tablast<cr>
" Add these into Vundle section
Plugin 'gcmt/taboo.vim'
Plugin 'tpope/vim-obsession'
Now open file in a new tab with: Ctrl-P
, select a file and Ctrl-O, t
.
Open file in a virtical split window with: Ctrl-P
, select a file and Ctrl-O, v
.
Rename tab with: :tr<Space>new name<Enter>
.
Jump to the 3rd window with ,3
.
Note:
I also tried xolox/vim-session, but it can't persist tab name created by Taboo.
For tab easy switch, I've tried noremap <unique> <C-1> 1gt
based on
Switching to a particular tab in VIM,
where changes M-Num to C-Num, because M-Num is assigned to tmux window switch.
However C-Num can't work,
see .vimrc mapping for control key not working
for explanations.
So I adopted noremap <leader>1 1gt
style based on
In vim, how can I quickly switch between tabs?.
Mapping long Ex commands with cabbrev
is a very useful for convenient.
Use cabbrev
.
See :h :ca
, Can I (re-) map commands in vim?
and Aliasing a command in vim
for details.
With cabbrev tr TabooRename
, you can use :tr<Space>1:tests
to rename current tab into "1:tests".
Here you have to add tab index manually to make <leader><number>
style switching more convenient.
To make tabline more readable, I customized the color of it. See How do you change the background color of the empty tab space in vim? and Customising the colours of vim's tab bar for details.