diff --git a/autoload/airline/extensions/tabline/buffers.vim b/autoload/airline/extensions/tabline/buffers.vim index 4e575d1..df6c93d 100644 --- a/autoload/airline/extensions/tabline/buffers.vim +++ b/autoload/airline/extensions/tabline/buffers.vim @@ -45,6 +45,7 @@ function! airline#extensions#tabline#buffers#invalidate() endfunction function! airline#extensions#tabline#buffers#get() + call map_keys() let cur = bufnr('%') if cur == s:current_bufnr if !g:airline_detect_modified || getbufvar(cur, '&modified') == s:current_modified @@ -180,16 +181,18 @@ function! s:jump_to_tab(offset) endif endfunction -if s:buffer_idx_mode - noremap AirlineSelectTab1 :call select_tab(0) - noremap AirlineSelectTab2 :call select_tab(1) - noremap AirlineSelectTab3 :call select_tab(2) - noremap AirlineSelectTab4 :call select_tab(3) - noremap AirlineSelectTab5 :call select_tab(4) - noremap AirlineSelectTab6 :call select_tab(5) - noremap AirlineSelectTab7 :call select_tab(6) - noremap AirlineSelectTab8 :call select_tab(7) - noremap AirlineSelectTab9 :call select_tab(8) - noremap AirlineSelectPrevTab :call jump_to_tab(-v:count1) - noremap AirlineSelectNextTab :call jump_to_tab(v:count1) -endif +function s:map_keys() + if s:buffer_idx_mode + noremap AirlineSelectTab1 :call select_tab(0) + noremap AirlineSelectTab2 :call select_tab(1) + noremap AirlineSelectTab3 :call select_tab(2) + noremap AirlineSelectTab4 :call select_tab(3) + noremap AirlineSelectTab5 :call select_tab(4) + noremap AirlineSelectTab6 :call select_tab(5) + noremap AirlineSelectTab7 :call select_tab(6) + noremap AirlineSelectTab8 :call select_tab(7) + noremap AirlineSelectTab9 :call select_tab(8) + noremap AirlineSelectPrevTab :call jump_to_tab(-v:count1) + noremap AirlineSelectNextTab :call jump_to_tab(v:count1) + endif +endfunction diff --git a/autoload/airline/extensions/tabline/tabs.vim b/autoload/airline/extensions/tabline/tabs.vim index 81c2591..02e4dc9 100644 --- a/autoload/airline/extensions/tabline/tabs.vim +++ b/autoload/airline/extensions/tabline/tabs.vim @@ -31,6 +31,7 @@ endfunction function! airline#extensions#tabline#tabs#get() let curbuf = bufnr('%') let curtab = tabpagenr() + call s:map_keys() if curbuf == s:current_bufnr && curtab == s:current_tabnr if !g:airline_detect_modified || getbufvar(curbuf, '&modified') == s:current_modified return s:current_tabline @@ -80,3 +81,18 @@ function! airline#extensions#tabline#tabs#get() let s:current_tabline = b.build() return s:current_tabline endfunction + +function s:map_keys() + noremap AirlineSelectTab1 :1tabn + noremap AirlineSelectTab2 :2tabn + noremap AirlineSelectTab3 :3tabn + noremap AirlineSelectTab4 :4tabn + noremap AirlineSelectTab5 :5tabn + noremap AirlineSelectTab6 :6tabn + noremap AirlineSelectTab7 :7tabn + noremap AirlineSelectTab8 :8tabn + noremap AirlineSelectTab9 :9tabn + noremap AirlineSelectPrevTab gT + " tabn {count} goes to count tab does not go {count} tab pages forward! + noremap AirlineSelectNextTab :exe repeat(':tabn\|', v:count1) +endfunction diff --git a/doc/airline.txt b/doc/airline.txt index ba9349c..1f54e85 100644 --- a/doc/airline.txt +++ b/doc/airline.txt @@ -493,9 +493,16 @@ exposed. nmap 7 AirlineSelectTab7 nmap 8 AirlineSelectTab8 nmap 9 AirlineSelectTab9 + nmap - AirlineSelectPrevTab + nmap + AirlineSelectNextTab Note: Mappings will be ignored within a NERDTree buffer. + Note: In buffer_idx_mode these mappings won't change the + current tab, but switch to the buffer visible in that tab. + Use |gt| for switching tabs. + In tabmode, those mappings will switch to the specified tab. + * defines the name of a formatter for how buffer names are displayed. > let g:airline#extensions#tabline#formatter = 'default'