Sublime text alignment

Source: Internet
Author: User

 

 

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 "cannot select two locations in the same row !! ") 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 ")

 

 

The effect is as follows:

 

After twice

 

 

 

 

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

Sublime text alignment

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.