tabline: simplify creation of maps

instead of typing all the mapping commands, create a loop that will
create the new maps.
This commit is contained in:
Christian Brabandt 2019-02-04 21:59:40 +01:00
parent 105e9daaf7
commit 999c40fcf3
No known key found for this signature in database
GPG Key ID: F3F92DA383FDDE09
2 changed files with 6 additions and 18 deletions

View File

@ -190,15 +190,9 @@ endfunction
function! s:map_keys()
if get(g:, 'airline#extensions#tabline#buffer_idx_mode', 1)
noremap <silent> <Plug>AirlineSelectTab1 :call <SID>select_tab(1)<CR>
noremap <silent> <Plug>AirlineSelectTab2 :call <SID>select_tab(2)<CR>
noremap <silent> <Plug>AirlineSelectTab3 :call <SID>select_tab(3)<CR>
noremap <silent> <Plug>AirlineSelectTab4 :call <SID>select_tab(4)<CR>
noremap <silent> <Plug>AirlineSelectTab5 :call <SID>select_tab(5)<CR>
noremap <silent> <Plug>AirlineSelectTab6 :call <SID>select_tab(6)<CR>
noremap <silent> <Plug>AirlineSelectTab7 :call <SID>select_tab(7)<CR>
noremap <silent> <Plug>AirlineSelectTab8 :call <SID>select_tab(8)<CR>
noremap <silent> <Plug>AirlineSelectTab9 :call <SID>select_tab(9)<CR>
for i in range(1, 9)
exe printf('noremap <silent> <Plug>AirlineSelectTab%d :call <SID>select_tab(%d)<CR>', i, i)
endfor
noremap <silent> <Plug>AirlineSelectPrevTab :<C-u>call <SID>jump_to_tab(-v:count1)<CR>
noremap <silent> <Plug>AirlineSelectNextTab :<C-u>call <SID>jump_to_tab(v:count1)<CR>
" Enable this for debugging

View File

@ -104,15 +104,9 @@ function! airline#extensions#tabline#tabs#map_keys()
if maparg('<Plug>AirlineSelectTab1', 'n') is# ':1tabn<CR>'
return
endif
noremap <silent> <Plug>AirlineSelectTab1 :1tabn<CR>
noremap <silent> <Plug>AirlineSelectTab2 :2tabn<CR>
noremap <silent> <Plug>AirlineSelectTab3 :3tabn<CR>
noremap <silent> <Plug>AirlineSelectTab4 :4tabn<CR>
noremap <silent> <Plug>AirlineSelectTab5 :5tabn<CR>
noremap <silent> <Plug>AirlineSelectTab6 :6tabn<CR>
noremap <silent> <Plug>AirlineSelectTab7 :7tabn<CR>
noremap <silent> <Plug>AirlineSelectTab8 :8tabn<CR>
noremap <silent> <Plug>AirlineSelectTab9 :9tabn<CR>
for i in range(1, 9)
exe printf('noremap <silent> <Plug>AirlineSelectTab%d :%dtabn<CR>', i, i)
endfor
noremap <silent> <Plug>AirlineSelectPrevTab gT
" tabn {count} goes to count tab does not go {count} tab pages forward!
noremap <silent> <Plug>AirlineSelectNextTab :<C-U>exe repeat(':tabn\|', v:count1)<cr>