Home Download Buy Blog Forum Support

Open Tab Rightmost

Open Tab Rightmost

Postby Scully on Mon Apr 01, 2013 10:43 pm

Hello

The following plug-in makes new tabs (from opening or creating new files) be place to the rightmost of all open tabs. Thanks to FichteFoll for assisting in getting this working by demonstrating how to work round a bug in Sublime. Here goes:

1) Go to Preferences->Browse Packages... and create a directory called 'OpenTabRightmost'.
2) Create a file call OpenTabRightmost.py and add the following code:

Code: Select all
import sublime, sublime_plugin 
 
class OpenTabRightmost(sublime_plugin.EventListener): 

   def on_new(self, view):
      self.view = view
      sublime.set_timeout(self.on_post_new, 200)


   def on_post_new(self):
      view = self.view
      w = view.window() or sublime.active_window()
      w.set_view_index(view, w.active_group(), len(w.views_in_group(w.active_group())) - 1)

   def on_load(self, view):
      w = view.window()
      w.set_view_index(view, w.active_group(), len(w.views_in_group(w.active_group())) - 1)


3) Save the file and you're done!

Now, all new tabs should open rightmost, despite the currently active tab. If you want leftmost opening, simply replace the two occurrences of 'len(w.views_in_group(w.active_group())) - 1' with '0'. If something doesn't work, pay attention to the indentation of the code as a stray space or tab could cause it to fail.

Regards
Aaron
Scully
 
Posts: 3
Joined: Sat Aug 11, 2012 1:27 am

Re: Open Tab Rightmost

Postby FichteFoll on Wed Apr 03, 2013 5:18 pm

FichteFoll
 
Posts: 388
Joined: Fri Mar 16, 2012 11:49 pm
Location: Germany


Return to Plugin Announcements

Who is online

Users browsing this forum: No registered users and 9 guests