Home Download Buy Blog Forum Support

command 'close' should behave like clicking the 'X' on a tab

command 'close' should behave like clicking the 'X' on a tab

Postby nibblebot on Thu Sep 20, 2012 4:44 pm

clicking the X leaves me on the previous tab in the row
command 'close' pops the current tab off of the stack and leaves me on the previously selected tab.
I bind cmd-w to command 'close' and i'd like it to behave exactly like clicking the 'X' on the tab does.
the reference here doesn't mention any params i can pass to the command: http://docs.sublimetext.info/en/latest/ ... mands.html

Is it possible command 'close' could add optional params to achieve this?
nibblebot
 
Posts: 3
Joined: Thu Sep 20, 2012 4:39 pm

Re: command 'close' should behave like clicking the 'X' on a tab

Postby archagon on Tue Dec 04, 2012 1:26 am

Is there any way to do this? Closing and then going to some previous tab that I didn't want to see really bugs me, especially when I want to close a bunch of tabs in a row.
archagon
 
Posts: 1
Joined: Tue Dec 04, 2012 1:25 am

Re: command 'close' should behave like clicking the 'X' on a tab

Postby angus on Tue Jul 16, 2013 4:20 pm

Hey, registered to request this but instead I'll bump this old thread. The stack-based closing is very unpredictable to me compared to always moving to the right, and is unhelpful when I'm trying to close a lot of my old tabs. Often I just end up closing all my tabs and manually re-opening the few I wanted to keep open :cry: I haven't seen an option or keybinding to change this, unlike with ctrl+tab which you can rebind from "next_view_in_stack" to "next_view". Thanks and take care!
angus
 
Posts: 2
Joined: Tue Jul 16, 2013 4:12 pm

Re: command 'close' should behave like clicking the 'X' on a tab

Postby skuroda on Tue Jul 16, 2013 9:00 pm

You could probably write a small plugin to do this. You could try using the on_close listener to grab the current view, and get the "next" view based on that.
skuroda
 
Posts: 685
Joined: Fri Oct 05, 2012 8:11 am

Re: command 'close' should behave like clicking the 'X' on a tab

Postby adzenith on Tue Jul 16, 2013 10:01 pm

angus wrote:I just end up closing all my tabs and manually re-opening the few I wanted to keep open :cry:

I do this too... it's really ****ing annoying. :(:(
adzenith
 
Posts: 1217
Joined: Mon Oct 19, 2009 9:12 pm

Re: command 'close' should behave like clicking the 'X' on a tab

Postby schlamar on Wed Jul 17, 2013 6:53 am

Save this as commands.py in your User package.

Code: Select all
import sublime_plugin


class PrevViewCloseCommand(sublime_plugin.WindowCommand):

    def run(self):
        view = self.window.active_view()
        group, index = self.window.get_view_index(view)
        if index == 0:
            new_index = 1
        else:
            new_index = index - 1
        views = self.window.views_in_group(group)
        self.window.run_command('close')
        try:
            self.window.focus_view(views[new_index])
        except IndexError:
            pass


And add this to your user keymap:
Code: Select all
{ "keys": ["ctrl+w"], "command": "prev_view_close" },
schlamar
 
Posts: 106
Joined: Tue Feb 19, 2013 2:11 pm

Re: command 'close' should behave like clicking the 'X' on a tab

Postby angus on Sat Aug 10, 2013 12:42 am

Hey schlamer, forgot to do this earlier but thanks a lot! Works great. I ended up changing it to:

Code: Select all
import sublime_plugin

class PrevViewCloseCommand(sublime_plugin.WindowCommand):
    def run(self):
        view = self.window.active_view()
        group, index = self.window.get_view_index(view)
        self.window.run_command('close')
        views = self.window.views_in_group(group)
        if index >= len(views):
            index = index - 1
        self.window.focus_view(views[index])
angus
 
Posts: 2
Joined: Tue Jul 16, 2013 4:12 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 15 guests