Last active
November 11, 2018 09:59
-
-
Save tyru/7f252720c80574152d0103a9598cf62b to your computer and use it in GitHub Desktop.
Bizarre <SID> and <SNR> conversion (https://github.com/vim-jp/issues/issues/1201)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! s:get_next_tab(n) abort | |
let last = tabpagenr('$') | |
let i = (tabpagenr() - 1 + a:n) % last | |
let i = i < 0 ? last + i : i | |
return i ==# 0 || i + 2 ==# tabpagenr() ? i : i + 1 | |
endfunction | |
" =============== Error =============== | |
" E121: Undefined variable: SNR | |
" E15: Invalid expression: 'tabmove' <SNR>279_get_next_tab(+v:count1) | |
" | |
" But ':echo <SNR>276_get_next_tab(-v:count1)' can successfully call it with no errors... | |
nnoremap <silent> <Left> :<C-u>execute 'tabmove' <SID>get_next_tab(-v:count1)<CR> | |
nnoremap <silent> <Right> :<C-u>execute 'tabmove' <SID>get_next_tab(+v:count1)<CR> | |
" =============== Success =============== | |
nnoremap <silent> <Left> :<C-u>call <SID>f(-v:count1)<CR> | |
nnoremap <silent> <Right> :<C-u>call <SID>f(+v:count1)<CR> | |
function! s:f(n) abort | |
execute 'tabmove' s:get_next_tab(a:n) | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Vim version: 8.1.513