Home Download Buy Blog Forum Support

Multi-Selection Alignment

Re: Multi-Selection Alignment

Postby floriancargoet on Fri Jul 15, 2011 7:34 pm

I love that plugin!
I really like having my "="s aligned.
As senzo said, ":" alignment would be great for JavaScript and JSON.
floriancargoet
 
Posts: 1
Joined: Fri Jul 15, 2011 7:31 pm

Re: Multi-Selection Alignment

Postby senzo on Tue Jul 19, 2011 2:48 pm

A quick modification for ":" alignment

Replace
Code: Select all
equal_pt = view.find('=', pt).a

with
Code: Select all
import re
if re.search("=", view.substr(view.line(pt))):
  equal_pt = view.find('=', pt).a
elif re.search(":", view.substr(view.line(pt))):
  equal_pt = view.find(':', pt).a
senzo
 
Posts: 106
Joined: Tue May 24, 2011 9:17 am

Re: Multi-Selection Alignment

Postby rdougan on Wed Jul 20, 2011 10:02 pm

I made it work with this syntax below:

Code: Select all
        var test      = "sadsad",
            asd       = "Asdasd",
            asdasdasd = "asdasd";


Buy commenting out this part of the code:

Code: Select all
            # for pt in points:
            #   pt += adjustment
            #   length = max_col - view.rowcol(pt)[1]
            #   max_length = max([max_length, length])
            #   adjustment += length
            #   view.insert(edit, pt, (' ' if use_spaces else '\t') * length)
rdougan
 
Posts: 44
Joined: Sat Apr 09, 2011 2:37 am

Re: Multi-Selection Alignment

Postby bizoo on Thu Jul 21, 2011 6:30 am

rdougan wrote:I made it work with this syntax below:

Code: Select all
        var test      = "sadsad",
            asd       = "Asdasd",
            asdasdasd = "asdasd";


Buy commenting out this part of the code:

Code: Select all
            # for pt in points:
            #   pt += adjustment
            #   length = max_col - view.rowcol(pt)[1]
            #   max_length = max([max_length, length])
            #   adjustment += length
            #   view.insert(edit, pt, (' ' if use_spaces else '\t') * length)

You don't use this plugin the way it was designed, take a look at the documentation from wbond: https://github.com/wbond/sublime_alignment
The code you commented remove the left alignment and only keep the alignment of "=", what you probably want.
This plugin must probably be splitted in 2 commands, one for the left alignment and one for the "=" (or ":") alignment.
bizoo
 
Posts: 879
Joined: Wed Dec 08, 2010 6:53 am
Location: Switzerland

Re: Multi-Selection Alignment

Postby wbond on Thu Jul 21, 2011 7:43 pm

I should hopefully be able to add some options for alignment characters and disabling left alignment in the next day or so.

Hopefully I will also figure out how to create a .sublime-package file for those who are so inclined.
wbond
 
Posts: 528
Joined: Mon Feb 28, 2011 5:33 am

Re: Multi-Selection Alignment

Postby xavi on Sat Jul 30, 2011 12:46 am

I've got this error under Ubuntu 11.04 x86_64 kernel 2.6.38-10-generic

Code: Select all
Traceback (most recent call last):
  File "./sublime_plugin.py", line 255, in run_
  File "./Alignment.py", line 65, in run
AttributeError: 'NoneType' object has no attribute 'a'
xavi
 
Posts: 24
Joined: Sat Jul 30, 2011 12:00 am

Re: Multi-Selection Alignment

Postby wbond on Mon Aug 15, 2011 2:45 am

Over the past few days I added settings to the plugin for more customization. I also fixed some bugs.

The best way to get the newest version, and to automatically stay up to date with the latest version is to use the Package Control package manager I've been working on. Once you manually update Alignment through Package Control, it will automatically check for and install updates whenever Sublime Text 2 starts. You can learn more at http://wbond.net/sublime_packages/package_control.

@rdougan

The newest version allows disabling indentation alignment on a per-filetype basis.

@xavi

The newest version fixed that bug.
wbond
 
Posts: 528
Joined: Mon Feb 28, 2011 5:33 am

Re: Multi-Selection Alignment

Postby iamntz on Mon Aug 15, 2011 3:48 am

@wbond: thanks for this awesome plugin, my code never looked that good!
There is a way of changing space indent to tab?

Thanks!
iamntz
 
Posts: 909
Joined: Fri Apr 29, 2011 8:52 am
Location: Romania

Re: Multi-Selection Alignment

Postby wbond on Mon Aug 15, 2011 12:34 pm

@iamntz

The left indent should automatically use tabs or spaces based on the current settings. In terms of mid-line indenting, unfortunately I was not able to figure out last night how to measure the actual displayed width of a tab character via the API. I can get the row and column, but the column is just the number of characters from the beginning of the line. I know ST2 can get the real column number since it is displayed in the status bar, I just couldn't find a method to translate to that. Without being able to tell how wide each tab is being displayed, I wouldn't be able to do mid-line tab spacing.
wbond
 
Posts: 528
Joined: Mon Feb 28, 2011 5:33 am

Re: Multi-Selection Alignment

Postby bizoo on Mon Aug 15, 2011 3:17 pm

To get the 'visual' column of a point, you could replace
Code: Select all
view.rowcol(pt)

by
Code: Select all
import indentation
indentation.line_and_normed_pt(view, pt)

Row is always the same for both.

An addition to the API for it would be nice.

Thanks for your work wbond.
bizoo
 
Posts: 879
Joined: Wed Dec 08, 2010 6:53 am
Location: Switzerland

PreviousNext

Return to Plugin Announcements

Who is online

Users browsing this forum: No registered users and 6 guests