Sublime Forum

Open Tab Rightmost

#1

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]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)[/code]
  1. 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

0 Likes

#2

Just cross-referencing here: sublimetext.userecho.com/topic/122224

0 Likes