[
  {
    "path": ".gitignore",
    "content": "*.pyc\n*.sublime-project\n*.sublime-workspace"
  },
  {
    "path": "Alignment.py",
    "content": "import sublime\r\nimport sublime_plugin\r\nimport re\r\nimport math\r\nimport os\r\nimport sys\r\n\r\ntry:\r\n    from Default.indentation import line_and_normed_pt as normed_rowcol\r\nexcept ImportError:\r\n    # This is necessary due to load order of packages in Sublime Text 2\r\n    sys.path.append(os.path.join(sublime.packages_path(), 'Default'))\r\n    indentation = __import__('indentation')\r\n    reload(indentation)\r\n    del sys.path[-1]\r\n    normed_rowcol = indentation.line_and_normed_pt\r\n\r\ndef convert_to_mid_line_tabs(view, edit, tab_size, pt, length):\r\n    spaces_end = pt + length\r\n    spaces_start = spaces_end\r\n    while view.substr(spaces_start-1) == ' ':\r\n        spaces_start -= 1\r\n    spaces_len = spaces_end - spaces_start\r\n    normed_start = normed_rowcol(view, spaces_start)[1]\r\n    normed_mod = normed_start % tab_size\r\n    tabs_len = 0\r\n    diff = 0\r\n    if normed_mod != 0:\r\n        diff = tab_size - normed_mod\r\n        tabs_len += 1\r\n    tabs_len += int(math.ceil(float(spaces_len - diff)\r\n        / float(tab_size)))\r\n    view.replace(edit, sublime.Region(spaces_start,\r\n        spaces_end), '\\t' * tabs_len)\r\n    return tabs_len - spaces_len\r\n\r\n\r\nclass AlignmentCommand(sublime_plugin.TextCommand):\r\n    def run(self, edit):\r\n        view = self.view\r\n        sel = view.sel()\r\n        max_col = 0\r\n\r\n        settings = view.settings()\r\n        tab_size = int(settings.get('tab_size', 8))\r\n        use_spaces = settings.get('translate_tabs_to_spaces')\r\n\r\n        # This handles aligning single multi-line selections\r\n        if len(sel) == 1:\r\n            points = []\r\n            line_nums = [view.rowcol(line.a)[0] for line in view.lines(sel[0])]\r\n\r\n            trim_trailing_white_space = \\\r\n                settings.get('trim_trailing_white_space_on_save')\r\n\r\n            if settings.get('align_indent'):\r\n                # Align the left edges by first finding the left edge\r\n                for row in line_nums:\r\n                    pt = view.text_point(row, 0)\r\n\r\n                    # Skip blank lines when the user times trailing whitespace\r\n                    line = view.line(pt)\r\n                    if trim_trailing_white_space and line.a == line.b:\r\n                        continue\r\n\r\n                    char = view.substr(pt)\r\n                    while char == ' ' or char == '\\t':\r\n                        # Turn tabs into spaces when the preference is spaces\r\n                        if use_spaces and char == '\\t':\r\n                            view.replace(edit, sublime.Region(pt, pt+1), ' ' *\r\n                                tab_size)\r\n\r\n                        # Turn spaces into tabs when tabs are the preference\r\n                        if not use_spaces and char == ' ':\r\n                            max_pt = pt + tab_size\r\n                            end_pt = pt\r\n                            while view.substr(end_pt) == ' ' and end_pt < \\\r\n                                    max_pt:\r\n                                end_pt += 1\r\n                            view.replace(edit, sublime.Region(pt, end_pt),\r\n                                '\\t')\r\n\r\n                        pt += 1\r\n\r\n                        # Rollback if the left edge wraps to the next line\r\n                        if view.rowcol(pt)[0] != row:\r\n                            pt -= 1\r\n                            break\r\n\r\n                        char = view.substr(pt)\r\n\r\n                    points.append(pt)\r\n                    max_col = max([max_col, view.rowcol(pt)[1]])\r\n\r\n                # Adjust the left edges based on the maximum that was found\r\n                adjustment = 0\r\n                max_length = 0\r\n                for pt in points:\r\n                    pt += adjustment\r\n                    length = max_col - view.rowcol(pt)[1]\r\n                    max_length = max([max_length, length])\r\n                    adjustment += length\r\n                    view.insert(edit, pt, (' ' if use_spaces else '\\t') *\r\n                        length)\r\n\r\n                perform_mid_line = max_length == 0\r\n\r\n            else:\r\n                perform_mid_line = True\r\n\r\n            alignment_chars = settings.get('alignment_chars')\r\n            if alignment_chars == None:\r\n                alignment_chars = []\r\n            alignment_prefix_chars = settings.get('alignment_prefix_chars')\r\n            if alignment_prefix_chars == None:\r\n                alignment_prefix_chars = []\r\n            alignment_space_chars = settings.get('alignment_space_chars')\r\n            if alignment_space_chars == None:\r\n                alignment_space_chars = []\r\n\r\n            alignment_pattern = '|'.join([re.escape(ch) for ch in\r\n                alignment_chars])\r\n\r\n            if perform_mid_line and alignment_chars:\r\n                points = []\r\n                max_col = 0\r\n                for row in line_nums:\r\n                    pt = view.text_point(row, 0)\r\n                    matching_region = view.find(alignment_pattern, pt)\r\n                    if not matching_region:\r\n                        continue\r\n                    matching_char_pt = matching_region.a\r\n\r\n                    insert_pt = matching_char_pt\r\n                    # If the equal sign is part of a multi-character\r\n                    # operator, bring the first character forward also\r\n                    if view.substr(insert_pt-1) in alignment_prefix_chars:\r\n                        insert_pt -= 1\r\n\r\n                    space_pt = insert_pt\r\n                    while view.substr(space_pt-1) in [' ', '\\t']:\r\n                        space_pt -= 1\r\n                        # Replace tabs with spaces for consistent indenting\r\n                        if view.substr(space_pt) == '\\t':\r\n                            view.replace(edit, sublime.Region(space_pt,\r\n                                space_pt+1), ' ' * tab_size)\r\n                            matching_char_pt += tab_size - 1\r\n                            insert_pt += tab_size - 1\r\n\r\n                    if view.substr(matching_char_pt) in alignment_space_chars:\r\n                        space_pt += 1\r\n\r\n                    # If the next equal sign is not on this line, skip the line\r\n                    if view.rowcol(matching_char_pt)[0] != row:\r\n                        continue\r\n\r\n                    points.append(insert_pt)\r\n                    max_col = max([max_col, normed_rowcol(view, space_pt)[1]])\r\n\r\n                # The adjustment takes care of correcting point positions\r\n                # since spaces are being inserted, which changes the points\r\n                adjustment = 0\r\n                for pt in points:\r\n                    pt += adjustment\r\n                    length = max_col - normed_rowcol(view, pt)[1]\r\n                    adjustment += length\r\n                    if length >= 0:\r\n                        view.insert(edit, pt, ' ' * length)\r\n                    else:\r\n                        view.erase(edit, sublime.Region(pt + length, pt))\r\n\r\n                    if settings.get('mid_line_tabs') and not use_spaces:\r\n                        adjustment += convert_to_mid_line_tabs(view, edit,\r\n                            tab_size, pt, length)\r\n\r\n\r\n        # This handles aligning multiple selections\r\n        else:\r\n            max_col = max([normed_rowcol(view, region.b)[1] for region in sel])\r\n\r\n            for region in sel:\r\n                length = max_col - normed_rowcol(view, region.b)[1]\r\n                view.insert(edit, region.b, ' ' * length)\r\n                if settings.get('mid_line_tabs') and not use_spaces:\r\n                    convert_to_mid_line_tabs(view, edit, tab_size, region.b,\r\n                        length)\r\n"
  },
  {
    "path": "Base File.sublime-settings",
    "content": "{\n\t// If the indent level of a multi-line selection should be aligned\n\t\"align_indent\": true,\n\n\t// If indentation is done via tabs, set this to true to also align\n\t// mid-line characters via tabs. This may cause alignment issues when\n\t// viewing the file in an editor with different tab width settings. This\n\t// will also cause multi-character operators to be left-aligned to the\n\t// first character in the operator instead of the character from the\n\t// \"alignment_chars\" setting.\n\t\"mid_line_tabs\": false,\n\n\t// The mid-line characters to align in a multi-line selection, changing\n\t// this to an empty array will disable mid-line alignment\n\t\"alignment_chars\": [\"=\"],\n\n\t// If the following character is matched for alignment, insert a space\n\t// before it in the final alignment\n\t\"alignment_space_chars\": [\"=\"],\n\n\t// The characters to align along with \"alignment_chars\"\n\t// For instance if the = is to be aligned, there are a number of\n\t// symbols that can be combined with the = to make an operator, and all\n\t// of those must be kept next to the = for the operator to be parsed\n\t\"alignment_prefix_chars\": [\n\t\t\"+\", \"-\", \"&\", \"|\", \"<\", \">\", \"!\", \"~\", \"%\", \"/\", \"*\", \".\"\n\t]\n}"
  },
  {
    "path": "CSS.sublime-settings",
    "content": "{\n\t\"alignment_chars\": [\"=\", \":\"]\n}"
  },
  {
    "path": "Default (Linux).sublime-keymap",
    "content": "[\r\n\t{ \"keys\": [\"ctrl+alt+a\"], \"command\": \"alignment\" }\r\n]"
  },
  {
    "path": "Default (OSX).sublime-keymap",
    "content": "[\r\n\t{ \"keys\": [\"super+ctrl+a\"], \"command\": \"alignment\" }\r\n]"
  },
  {
    "path": "Default (Windows).sublime-keymap",
    "content": "[\r\n\t{ \"keys\": [\"ctrl+alt+a\"], \"command\": \"alignment\" }\r\n]"
  },
  {
    "path": "Default.sublime-commands",
    "content": "[\n    {\n        \"caption\": \"Preferences: Alignment File Settings – Default\",\n        \"command\": \"open_file\",\n        \"args\": {\n            \"file\": \"${packages}/Terminal/Base File.sublime-settings\"\n        }\n    },\n    {\n        \"caption\": \"Preferences: Alignment File Settings – User\",\n        \"command\": \"open_file\",\n        \"args\": {\n            \"file\": \"${packages}/User/Base File.sublime-settings\"\n        }\n    },\n    {\n        \"caption\": \"Preferences: Alignment File Settings – Syntax Specific – User\",\n        \"command\": \"open_file_settings\"\n    },\n    {\n        \"caption\": \"Preferences: Alignment Key Bindings – Default\",\n        \"command\": \"open_file\",\n        \"args\": {\n            \"file\": \"${packages}/Alignment/Default (Windows).sublime-keymap\",\n            \"platform\": \"Windows\"\n        }\n    },\n    {\n        \"caption\": \"Preferences: Alignment Key Bindings – Default\",\n        \"command\": \"open_file\",\n        \"args\": {\n            \"file\": \"${packages}/Alignment/Default (OSX).sublime-keymap\",\n            \"platform\": \"OSX\"\n        }\n    },\n    {\n        \"caption\": \"Preferences: Alignment Key Bindings – Default\",\n        \"command\": \"open_file\",\n        \"args\": {\n            \"file\": \"${packages}/Alignment/Default (Linux).sublime-keymap\",\n            \"platform\": \"Linux\"\n        }\n    },\n    {\n        \"caption\": \"Preferences: Alignment Key Bindings – User\",\n        \"command\": \"open_file\",\n        \"args\": {\n            \"file\": \"${packages}/User/Default (Windows).sublime-keymap\",\n            \"platform\": \"Windows\"\n        }\n    },\n    {\n        \"caption\": \"Preferences: Alignment Key Bindings – User\",\n        \"command\": \"open_file\",\n        \"args\": {\n            \"file\": \"${packages}/User/Default (OSX).sublime-keymap\",\n            \"platform\": \"OSX\"\n        }\n    },\n    {\n        \"caption\": \"Preferences: Alignment Key Bindings – User\",\n        \"command\": \"open_file\",\n        \"args\": {\n            \"file\": \"${packages}/User/Default (Linux).sublime-keymap\",\n            \"platform\": \"Linux\"\n        }\n    }\n]"
  },
  {
    "path": "JSON.sublime-settings",
    "content": "{\n\t\"alignment_chars\": [\"=\", \":\"]\n}"
  },
  {
    "path": "Javascript.sublime-settings",
    "content": "{\n\t\"alignment_chars\": [\"=\", \":\"]\n}"
  },
  {
    "path": "Main.sublime-menu",
    "content": "[\n    {\n        \"caption\": \"Preferences\",\n        \"mnemonic\": \"n\",\n        \"id\": \"preferences\",\n        \"children\":\n        [\n            {\n                \"caption\": \"Package Settings\",\n                \"mnemonic\": \"P\",\n                \"id\": \"package-settings\",\n                \"children\":\n                [\n                    {\n                        \"caption\": \"Alignment\",\n                        \"children\":\n                        [\n                            {\n                                \"command\": \"open_file\", \n                                \"args\": {\"file\": \"${packages}/Alignment/Base File.sublime-settings\"},\n                                \"caption\": \"Settings – Default\"\n                            },\n                            {\n                                \"command\": \"open_file\", \n                                \"args\": {\"file\": \"${packages}/User/Base File.sublime-settings\"},\n                                \"caption\": \"Settings – User\"\n                            },\n                            {\n                                \"command\": \"open_file_settings\", \n                                \"caption\": \"Settings – Syntax Specific – User\"\n                            },\n                            {\n                                \"command\": \"open_file\",\n                                \"args\": {\n                                    \"file\": \"${packages}/Alignment/Default (Windows).sublime-keymap\",\n                                    \"platform\": \"Windows\"\n                                },\n                                \"caption\": \"Key Bindings – Default\"\n                            },\n                            {\n                                \"command\": \"open_file\",\n                                \"args\": {\n                                    \"file\": \"${packages}/Alignment/Default (OSX).sublime-keymap\",\n                                    \"platform\": \"OSX\"\n                                },\n                                \"caption\": \"Key Bindings – Default\"\n                            },\n                            {\n                                \"command\": \"open_file\",\n                                \"args\": {\n                                    \"file\": \"${packages}/Alignment/Default (Linux).sublime-keymap\",\n                                    \"platform\": \"Linux\"\n                                },\n                                \"caption\": \"Key Bindings – Default\"\n                            },\n                            {\n                                \"command\": \"open_file\",\n                                \"args\": {\n                                    \"file\": \"${packages}/User/Default (Windows).sublime-keymap\",\n                                    \"platform\": \"Windows\"\n                                },\n                                \"caption\": \"Key Bindings – User\"\n                            },\n                            {\n                                \"command\": \"open_file\",\n                                \"args\": {\n                                    \"file\": \"${packages}/User/Default (OSX).sublime-keymap\",\n                                    \"platform\": \"OSX\"\n                                },\n                                \"caption\": \"Key Bindings – User\"\n                            },\n                            {\n                                \"command\": \"open_file\",\n                                \"args\": {\n                                    \"file\": \"${packages}/User/Default (Linux).sublime-keymap\",\n                                    \"platform\": \"Linux\"\n                                },\n                                \"caption\": \"Key Bindings – User\"\n                            },\n                            { \"caption\": \"-\" }\n                        ]\n                    }\n                ]\n            }\n        ]\n    }\n]\n"
  },
  {
    "path": "messages/2.0.0.txt",
    "content": "Sublime Alignment 2.0.0 Changelog:\n- Removed the ctrl+shift+a shortcut on Windows/Linux and the cmd+shift+a\n  shortcut on OS X to prevent conflict with the shortcut for Expand to Tag.\n  The plugin is now triggered via ctrl+alt+a on Windows/Linux and ctrl+cmd+a\n  on OS X."
  },
  {
    "path": "messages/2.1.0.txt",
    "content": "Sublime Alignment 2.1.0 Changelog:\n- Added support for Sublime Text 3 thanks to kevinsperrine\n"
  },
  {
    "path": "messages.json",
    "content": "{\n\t\"2.1.0\": \"messages/2.1.0.txt\",\n\t\"2.0.0\": \"messages/2.0.0.txt\"\n}"
  },
  {
    "path": "readme.creole",
    "content": "= Sublime Alignment\r\n\r\nA simple key-binding for aligning multi-line and multiple selections in\r\n[[http://sublimetext.com/2|Sublime Text 2]].\r\n\r\nPlease see http://wbond.net/sublime_packages/alignment for install instructions,\r\nscreenshots and documentation.\r\n\r\n== License\r\n\r\nAll of Sublime Alignment is licensed under the MIT license.\r\n\r\n  Copyright (c) 2011 Will Bond <will@wbond.net>\r\n\r\n  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n  of this software and associated documentation files (the \"Software\"), to deal\r\n  in the Software without restriction, including without limitation the rights\r\n  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n  copies of the Software, and to permit persons to whom the Software is\r\n  furnished to do so, subject to the following conditions:\r\n\r\n  The above copyright notice and this permission notice shall be included in\r\n  all copies or substantial portions of the Software.\r\n\r\n  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n  THE SOFTWARE."
  }
]