tabpage: track last-used tabpage #11626

In a multi-window scenario, it is possible to return focus to the last
accessed window via n_CTRL-W_p.  However, in the case of a multi-tab
scenario, there was previously no way to return focus to the last
accessed *tab*.  Here, that ability is added via n_g<tab>.

Additionally, the index of the previous tab is exposed via
tabpagenr('#'), mirroring the existing functionality of winnr('#').
This commit is contained in:
butwerenotthereyet
2020-01-02 06:06:11 -08:00
committed by Justin M. Keyes
parent 2c62b2fc56
commit cbc8d72fde
7 changed files with 502 additions and 9 deletions

View File

@@ -8591,8 +8591,12 @@ tabpagebuflist([{arg}]) *tabpagebuflist()*
tabpagenr([{arg}]) *tabpagenr()*
The result is a Number, which is the number of the current
tab page. The first tab page has number 1.
When the optional argument is "$", the number of the last tab
page is returned (the tab page count).
The optional argument {arg} supports the following values:
$ the number of the last tab page (the tab page
count).
# the number of the last accessed tab page (where
|g<Tab>| goes to). If there is no previous
tab page, 0 is returned.
The number can be used with the |:tab| command.

View File

@@ -222,6 +222,8 @@ tag char note action in Normal mode ~
|CTRL-]| CTRL-] :ta to ident under cursor
|CTRL-^| CTRL-^ edit Nth alternate file (equivalent to
":e #N")
|CTRL-<Tab>| CTRL-<Tab> same as `g<Tab>` : go to last accessed tab
page
CTRL-_ not used
|<Space>| <Space> 1 same as "l"
@@ -570,6 +572,8 @@ tag command action in Normal mode ~
following the file name.
|CTRL-W_gt| CTRL-W g t same as `gt`: go to next tab page
|CTRL-W_gT| CTRL-W g T same as `gT`: go to previous tab page
|CTRL-W_g<Tab>| CTRL-W g <Tab> same as `g<Tab>` : go to last accessed tab
page
|CTRL-W_h| CTRL-W h go to Nth left window (stop at first window)
|CTRL-W_i| CTRL-W i split window and jump to declaration of
identifier under the cursor
@@ -788,6 +792,7 @@ tag char note action in Normal mode ~
|g<LeftMouse>| g<LeftMouse> same as <C-LeftMouse>
g<MiddleMouse> same as <C-MiddleMouse>
|g<RightMouse>| g<RightMouse> same as <C-RightMouse>
|g<Tab>| g<Tab> go to last accessed tab page
|g<Up>| g<Up> 1 same as "gk"
==============================================================================