首页 > 其他 > 详细

sublime text 另一种对齐

时间:2014-09-29 20:19:12      阅读:254      评论:0      收藏:0      [点我收藏+]

 

 

 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                 return
13             pre_row = row
14             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_x
23             if pos_cur_x < pos_max_x:
24                 self.view.insert(edit, region.end(), "\t")

 

 

效果如下:

bubuko.com,布布扣

 

用两次之后

 

bubuko.com,布布扣

 

 

 

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

sublime text 另一种对齐

原文:http://www.cnblogs.com/hangj/p/4000823.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!