-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tabcloseleft option #5967
Comments
We do have tablocal variables and autocommands. Is such a feature really needed built into the core? I think this can be achieved by some Vimscript |
The choice to build such feature in the core is yours to do, but since I saw that someone proposed a patch that is listed in the todo I thought that internally the discussion was already settled for a yes but the patch was lost somewhere. I know that is something feasible with scripting but to me seems an option valuable to be configurable (99% of the time I open a tab via the NerdTree and I would like to close it and come back to the file listing to open another one, not to the tab on the right). |
function! OnQuit()
if winnr("$") == 1 && tabpagenr("$") > 1 && tabpagenr() > 1 && tabpagenr() < tabpagenr("$")
q | tabprev
else
q
endif
endfunction
cnoremap q<CR> :call OnQuit()<CR> It would kind of be nice to have an option to do this, since I think vim currently has the "wrong" default behavior. That said, since it can be done with scripts such as the one above, I can understand the hesitancy. EDIT: the above does not work as written, since it causes trouble when running the |
closing |
Then what about these lines in todo.txt? Lines 1839 to 1840 in 7325714
|
Whether you set the option or include the mentioned piece of Vim script, both require adding the change to your vimrc. The command only handles ":q" though, not other commands that close a tab page. Something using a WinClose autocommand should work better. |
It looks like the
The values in the quit handler make sense, but the values in the Furthermore, the Given this, I am having difficulty implementing this using the Now that I think about it, I think the behavior that most users would actually want by default is not necessarily to always go to the left or right tab after closing a tab, but instead to go to the last tab that was accessed (be it left or right). That way it would do the "right" thing for users whether they have tabs open on the left or right. But either way, the above strange values of the Can someone knowledgeable take a look at those numbers above and comment? |
Edit to one of my above comments: the vimscript snippet that I pasted actually does not work correctly (for multiple reasons), one of which is that it does not work when running the |
For anyone pondering on the issue, right now here's how I'm doing it. function! ShouldMoveToPreviousTab()
" In some scenarios one field has the correct information, in other scearios the other has it
let previousLastTabNr=max([g:TabLeave_TabsStatus.last, g:WinClosed_TabsStatus.last])
return tabpagenr('$') < previousLastTabNr && g:TabLeave_TabsStatus.current != previousLastTabNr
endfunction
let g:WinClosed_TabsStatus = { 'current': 1, 'last': 1 }
let g:TabLeave_TabsStatus = { 'current': 1, 'last': 1 }
augroup tabcloseleft
au!
au TabLeave * let g:TabLeave_TabsStatus = { 'current': tabpagenr(), 'last': tabpagenr('$') }
au WinClosed * let g:WinClosed_TabsStatus = { 'current': tabpagenr(), 'last': tabpagenr('$') }
au TabClosed * if ShouldMoveToPreviousTab() | tabprevious | endif
augroup end |
I found that some time ago someone proposed a patch about the option
tabcloseleft
in the mailing list and indeed into todo.txt there is the lineand I don't understand if it was dropped or if it needs more work on it in order to be merged or something else.
I think that is an option valuable to add, let me know if I can help, thank for your time.
The text was updated successfully, but these errors were encountered: