├── .github └── workflows │ └── test.yaml ├── AlignTab.sublime-settings ├── Context.sublime-menu ├── Default.sublime-commands ├── Default.sublime-keymap ├── LICENSE.txt ├── Main.sublime-menu ├── README.md ├── aligner.py ├── aligntab.py ├── hist.py ├── parser.py ├── table.py ├── utils.py └── wclen.py /.github/workflows/test.yaml: -------------------------------------------------------------------------------- 1 | name: test 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | run-tests: 7 | strategy: 8 | fail-fast: false 9 | matrix: 10 | st-version: [3, 4] 11 | runs-on: "ubuntu-latest" 12 | steps: 13 | - uses: actions/checkout@v2 14 | - uses: SublimeText/UnitTesting/actions/setup@master 15 | with: 16 | sublime-text-version: ${{ matrix.st-version }} 17 | - uses: SublimeText/UnitTesting/actions/run-tests@master 18 | with: 19 | coverage: true 20 | codecov-upload: true 21 | -------------------------------------------------------------------------------- /AlignTab.sublime-settings: -------------------------------------------------------------------------------- 1 | { 2 | // To make it easier to remember complex patterns, you can save them in a 3 | // dictionary in the settings file. To edit the patterns, launch 4 | // Preferences: AlignTab Settings. Use the name as key and the regex as 5 | // value. define your own patterns 6 | "named_patterns": { 7 | // "eq" : "=/f", 8 | // right hand side could also be an array of inputs 9 | // "ifthen" : ["=/f", "\\?/f", ":/f"] 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Context.sublime-menu: -------------------------------------------------------------------------------- 1 | [ 2 | {"caption" : "-"}, 3 | { 4 | "id": "aligntab", 5 | "caption": "AlignTab", 6 | "children": [ 7 | { 8 | "caption": "First Equal =", 9 | "command": "align_tab", 10 | "args": {"user_input" : "=/f"} 11 | }, 12 | { 13 | "caption" : "First Colon :", 14 | "command" : "align_tab", 15 | "args" : {"user_input" : ":/f"} 16 | }, 17 | { 18 | "caption": "Fat Arrow =>", 19 | "command": "align_tab", 20 | "args": {"user_input" : "=>"} 21 | }, 22 | { 23 | "caption" : "Ampersands &", 24 | "command" : "align_tab", 25 | "args" : {"user_input" : "&"} 26 | }, 27 | { 28 | "caption" : "Vertical Bars |", 29 | "command" : "align_tab", 30 | "args" : {"user_input" : "\\|"} 31 | }, 32 | { 33 | "caption" : "Spaces", 34 | "command" : "align_tab", 35 | "args" : {"user_input" : "\\s*/l1l0"} 36 | }, 37 | { 38 | "caption": "Exit Table Mode", 39 | "command": "align_tab_clear_mode" 40 | } 41 | ] 42 | } 43 | ] 44 | -------------------------------------------------------------------------------- /Default.sublime-commands: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "caption": "AlignTab", 4 | "command": "align_tab" 5 | }, 6 | { 7 | "caption": "AlignTab: Table Mode", 8 | "command": "align_tab", 9 | "args": {"mode" : true} 10 | }, 11 | { 12 | "caption": "AlignTab: Live Preview Mode", 13 | "command": "align_tab", 14 | "args": {"live_preview" : true} 15 | }, 16 | { 17 | "caption": "AlignTab: Exit Table Mode", 18 | "command": "align_tab_clear_mode" 19 | }, 20 | { 21 | "caption": "Preferences: AlignTab Settings", 22 | "command": "edit_settings", 23 | "args": 24 | { 25 | "base_file": "${packages}/AlignTab/AlignTab.sublime-settings", 26 | "default": "{\n\t$0\n}\n" 27 | } 28 | }, 29 | { 30 | "caption": "Preferences: AlignTab Context Menu", 31 | "command": "align_tab_edit_settings", 32 | "args": 33 | { 34 | "user_file": "${packages}/User/AlignTab/Context.sublime-menu", 35 | "base_file": "${packages}/AlignTab/Context.sublime-menu", 36 | "default": "[\n\t$0\n]\n" 37 | } 38 | } 39 | ] 40 | -------------------------------------------------------------------------------- /Default.sublime-keymap: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "keys": ["up"], "command": "align_tab_history", 4 | "args": { 5 | "backwards": true 6 | }, 7 | "context": 8 | [ 9 | { "key": "setting.AlignTabInputPanel", "operator": "equal", "operand": true } 10 | ] 11 | }, 12 | 13 | { 14 | "keys": ["down"], "command": "align_tab_history", 15 | "context": 16 | [ 17 | { "key": "setting.AlignTabInputPanel", "operator": "equal", "operand": true } 18 | ] 19 | }, 20 | 21 | { 22 | "keys": ["escape"], "command": "align_tab_clear_mode", 23 | "context": 24 | [ 25 | { "key": "setting.AlignTabTableMode", "operator": "equal", "operand": true } 26 | ] 27 | } 28 | 29 | ] 30 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 Randy Lai 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. -------------------------------------------------------------------------------- /Main.sublime-menu: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "caption": "Preferences", 4 | "mnemonic": "n", 5 | "id": "preferences", 6 | "children": 7 | [ 8 | { 9 | "caption": "Package Settings", 10 | "mnemonic": "P", 11 | "id": "package-settings", 12 | "children": 13 | [ 14 | { 15 | "caption": "AlignTab", 16 | "children": 17 | [ 18 | { 19 | "caption": "Settings", 20 | "command": "edit_settings", 21 | "args": { 22 | "base_file": "${packages}/AlignTab/AlignTab.sublime-settings" 23 | } 24 | }, 25 | { 26 | "caption": "Context Menu", 27 | "command": "align_tab_edit_settings", 28 | "args": 29 | { 30 | "user_file": "${packages}/User/AlignTab/Context.sublime-menu", 31 | "base_file": "${packages}/AlignTab/Context.sublime-menu", 32 | "default": "[\n\t$0\n]\n" 33 | } 34 | } 35 | ] 36 | } 37 | ] 38 | } 39 | ] 40 | } 41 | 42 | 43 | ] 44 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AlignTab 2 | 3 | 4 | [![test](https://github.com/randy3k/AlignTab/actions/workflows/test.yaml/badge.svg)](https://github.com/randy3k/AlignTab/actions/workflows/test.yaml) 5 | [![codecov](https://codecov.io/gh/randy3k/AlignTab/branch/master/graph/badge.svg)](https://codecov.io/gh/randy3k/AlignTab) 6 | 7 | 8 | 9 | 10 | The most flexible alignment plugin for Sublime Text 3. This plugin is inspired by the excellent VIM plugin, [tabular](https://github.com/godlygeek/tabular). 11 | 12 | ST2 support is deprecated but however, it is still possible to install AlignTab on ST2 via Package Control. 13 | 14 | 15 | ## Features 16 | - Align using regular expression 17 | - Custom spacing, padding and justification. 18 | - Smart detection for alignment if no lines are selected 19 | - Multiple cursors support 20 | - Table mode and Live preview mode 21 | 22 | ## Getting started 23 | 24 | - If you only want simple and quick alignment, the predefined alignment will help. 25 | 26 | 27 | 28 | ## More complicated usage 29 | 30 | - Open `AlignTab` in Command Palette `C+Shift+p` and enter the input in the form of `/