diff --git a/Alignment.py b/Alignment.py index dfcb1ca..4a8096c 100644 --- a/Alignment.py +++ b/Alignment.py @@ -43,6 +43,9 @@ def run(self, edit): settings = view.settings() tab_size = int(settings.get('tab_size', 8)) use_spaces = settings.get('translate_tabs_to_spaces') + alignment_format = settings.get('alignment_format') + if alignment_format == None: + alignment_format = "key-varspace-separator-value" # This handles aligning single multi-line selections if len(sel) == 1: @@ -151,20 +154,33 @@ def run(self, edit): # If the next equal sign is not on this line, skip the line if view.rowcol(matching_char_pt)[0] != row: + points.append(-1) continue points.append(insert_pt) + max_col = max([max_col, normed_rowcol(view, space_pt)[1]]) # The adjustment takes care of correcting point positions # since spaces are being inserted, which changes the points adjustment = 0 + row = 0 for pt in points: + if pt == -1: + continue + + textStart = view.text_point(line_nums[row], 0) + row += 1 pt += adjustment length = max_col - normed_rowcol(view, pt)[1] adjustment += length if length >= 0: - view.insert(edit, pt, ' ' * length) + if alignment_format == "key-varspace-separator-value": + view.insert(edit, pt, ' ' * length) + elif alignment_format == "key-separator-varspace-value": + view.insert(edit, pt + 1, ' ' * length) + elif alignment_format == "varspace-key-separator-value": + view.insert(edit, textStart, ' ' * length) else: view.erase(edit, sublime.Region(pt + length, pt)) @@ -182,4 +198,4 @@ def run(self, edit): view.insert(edit, region.b, ' ' * length) if settings.get('mid_line_tabs') and not use_spaces: convert_to_mid_line_tabs(view, edit, tab_size, region.b, - length) \ No newline at end of file + length) diff --git a/Base File.sublime-settings b/Base File.sublime-settings index b3f02f7..e1808e1 100644 --- a/Base File.sublime-settings +++ b/Base File.sublime-settings @@ -24,5 +24,21 @@ // of those must be kept next to the = for the operator to be parsed "alignment_prefix_chars": [ "+", "-", "&", "|", "<", ">", "!", "~", "%", "/", "*", "." - ] -} \ No newline at end of file + ], + + // This plugin can align the selected lines in a number of ways. + // background-color: black; + // color: white; + // "alignment_format": "key-separator-varspace-value" + + // ... or ... + // background-color: black; + // color: white; + // "alignment_format": "varspace-key-separator-value" + + // ... or the default ... + // background-color: black; + // color : white; + "alignment_format": "key-varspace-separator-value" + +}