sublime text 另一種對齊

來源:互聯網
上載者:User

標籤:style   blog   http   color   io   os   for   sp   div   

 

 

 1 #coding=utf-8 2 import sublime, sublime_plugin 3  4 class AutoAlignmentCommand(sublime_plugin.TextCommand): 5     def run(self, edit): 6         pre_row = -1 7         pos_max_x = 0.0 8         for region in self.view.sel(): 9             (row,col) = self.view.rowcol(region.begin())10             if row == pre_row:11                 sublime.error_message(u"不能在同一行選中兩個位置!!")12                 return13             pre_row = row14             point_end = region.end()15             vec_pos = self.view.text_to_layout(point_end)16             if vec_pos[0] > pos_max_x:17                 print vec_pos[0]18                 pos_max_x = vec_pos[0]19 20         for region in self.view.sel():21             pos_cur_x = self.view.text_to_layout(region.end())[0]22             print "pos_cur_x", pos_cur_x23             if pos_cur_x < pos_max_x:24                 self.view.insert(edit, region.end(), "\t")

 

 

效果如下:

 

用兩次之後

 

 

 

 

http://www.sublimetext.com/docs/2/api_reference.html

sublime text 另一種對齊

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.