2013-12-23 52 views

回答

3

我發現這個答案

如果你的標籤進行排序,排序它的側邊欄,而這個排序選項卡

我修改了類名雖然沒有更好的東西。之前的類名可能更好。

{ "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) 
+0

你怎麼把這個變成崇高的? – Omar

+0

@Omar很久以前,但看看如何編寫一個非常基本的插件例如一個插入文本「hello world」的文本,然後獲得該文本的代碼時https://code.tutsplus.com/tutorials/how-to-create-a-sublime-text-2-plugin-net-22685,你知道如何安裝(該鏈接可能有幫助),那麼你可以嘗試用我的回答中的代碼替換 – barlop

8

沒有爲一個崇高plugin,叫SortTabs。它的工作原理都與崇高文字2和3

可以使用Sublime Package Manger安裝它,然後排序選項卡使用任何下列方法:

  • 排序選項卡按文件名按文件類型
  • 排序選項卡
  • 排序選項卡按文件路徑的修改日期
  • 排序選項卡
  • 排序選項卡由上次激活
+0

通過控制檯安裝包管理器,但在視圖菜單中看不到任何「按Tab ...排序選項」選項。它應該在別的地方嗎?我在ST3上。 –

+0

@管理你打開ST下拉(Ctrl + Shift + P)並輸入'sort' - 它會在那裏! ;) –

+1

這不排序文件夾,只有文件名。 – Omar

相關問題