Sublime Forum

Command to focus on the rightmost tab

#1

Hi everyone,

I using ST3 in Windows 10. The key binding alt + 1 focuses on first open tab, alt + 2 on the second tab, and so on. Is there a command to focus on the rightmost tab? This would be similar to Ctrl + 9 in Google Chrome. I look forward to hearing from you.

0 Likes

#2

It’s trivial to create a command via the plugin API

import sublime
import sublime_plugin

class FocusLastViewCommand(sublime_plugin.WindowCommand):

    def run(self):
        views = self.window.views_in_group(self.window.active_group())
        self.window.focus_view(views[-1])
{
	"keys": ["ctrl+9"],
	"command": "focus_last_view",
},

It looks like the built in select_by_index (the command behind the alt + n) doesn’t take negative args. Something like the following doesn’t work.

{
	"keys": ["ctrl+9"],
	"command": "select_by_index",
	"args": {
		"index": -1
	},
},

So maybe the plugin approach is the only way unless I am missing something (or there is some other way through builtin commands).

2 Likes

#3

Works like a charm! Thank you so much for the quick reply!

0 Likes