sublime text 另一种对齐
效果如下:
http://sublime-text-unofficial-documentation.readthedocs.org/en/latest/extensibility/plugins.html
1 #coding=utf-8 2 import sublime, sublime_plugin 3 4 class AutoAlignmentCommand(sublime_plugin.TextCommand): 5 def auto_align(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 -1 13 pre_row = row 14 point_begin = region.begin() 15 vec_pos = self.view.text_to_layout(point_begin) 16 if vec_pos[0] > pos_max_x: 17 print (vec_pos[0]) 18 pos_max_x = vec_pos[0] 19 20 is_finished = True 21 for region in self.view.sel(): 22 pos_cur_x = self.view.text_to_layout(region.begin())[0] 23 print ("pos_cur_x:", pos_cur_x) 24 if pos_cur_x < pos_max_x: 25 self.view.insert(edit, region.begin(), "\t") 26 is_finished = False 27 28 return is_finished 29 30 def run(self, edit): 31 count = 0 32 while True: 33 # 防止死循环,最多循环50次 34 count = count + 1 35 ret = self.auto_align(edit) 36 if count > 50 or ret == -1 or ret == True: 37 return
http://www.sublimetext.com/docs/2/api_reference.html
+V why_null 请备注:from博客园
分类:
sublime
标签:
sublime
, sublime text
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通