Deviating from the behaviour for gT
, the above answers won't handle g<Tab>
nicely, as it will appear to vim as if one separately asked to go to the next tab page multiple times. Calculating the jump destination directly solves the problem.
One more subtlety is to prepend the mapping with @_
. Execution of a black hole macro does nothing, but consumes the count passed to the mapping, so that we may pass another count from our mapping, in our case, giving the calculated destination tab page as a count to gt
.
nnoremap <expr> g<C-t>gt '@_' . (1 + ((tabpagenr () - 1 + v:count1) % tabpagenr ('$'))) . 'gt'