如何在sublime(ST2)中按字母顺序对侧栏进行排序?

bar*_*lop 9 sublimetext2

我认为没有选择在Sublime中对侧边栏进行排序,我该怎么办呢?如果能够做到这一点,我想对其进行排序.

Ili*_*sev 8

有一个Sublime 插件,称为SortTabs.它适用于Sublime Text 2和3.

您可以使用Sublime Package Manger以下任何方法对选项卡进行安装,然后使用以下任

  • 按文件名对选项卡排序
  • 按文件类型对选项卡排序
  • 按文件路径对选项卡排序
  • 按修改日期对选项卡排序
  • 按上次激活对标签进行排序


bar*_*lop 3

我找到了这个答案

如果您对选项卡进行排序,它会对侧边栏进行排序,这会对选项卡进行排序

我修改了类名,但没有更好。以前的类名可能更好。

{ "keys": ["ctrl+alt+b"], "command": "sorttsortsidebar" }
Run Code Online (Sandbox Code Playgroud)

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)
Run Code Online (Sandbox Code Playgroud)