I see no option to sort the sidebar in Sublime, how can I do it? I'd like to sort it alphabetically.
There is a Sublime plugin for that, called SortTabs. It works both with Sublime Text 2 and 3.
You can install it using Sublime Package Manger
and then sort tabs using any of the following methods:
I have found this answer
If you sort the tabs, it sorts the sidebar, and this sorts the tabs
I amended the classname though not to anything better. the classname was probably better before.
{ "keys": ["ctrl+alt+b"], "command": "sorttsortsidebar" }
http://www.sublimetext.com/forum/viewtopic.php?f=4&t=3876&start=20
import sublime_plugin
from os import path
from operator import itemgetter
# A simple command to sort current tabs alphabetically (returning focus to the
# original tab).
# Does not work with different groups or windows. Not catered for unsaved views
# (although it seems to work okay if there are any). It could be modified to
# work in these circumstances.
# { "keys": ["ctrl+alt+b"], "command": "sort_tabs" },
class SorttsortsidebarCommand(sublime_plugin.WindowCommand):
def run(self):
print("ddffd_sorttabs")
file_views = []
win = self.window
curr_view = win.active_view()
for vw in win.views():
_, tail = path.split(vw.file_name() or path.sep)
group, _ = win.get_view_index(vw)
file_views.append((tail.lower(), vw, group))
file_views.sort(key = itemgetter(2, 0))
moving_index = 0
for index, (_, vw, group) in enumerate(file_views):
if index == 0 or group > prev_group:
moving_index = 0
prev_group = group
else:
moving_index += 1
win.set_view_index(vw, group, moving_index)
win.focus_view(curr_view)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With