Dead-simple alignment of multi-line selections and multiple selections for
Sublime Text 2.
Features
Align multiple selections to the same column by inserting spaces (or tabs)
Align all lines in a multi-line selection to the same indent level
Align the first = on each line of a multi-line selection to the same column
See the screenshots below for examples of the plugin in action.
Works On
Screenshots
Installation
Download Package Control
and use the Package Control: Install Package command from the
command palette. Using Package Control ensures Alignment will stay up to
date automatically.
Usage
Make a multi-line selection, or multiple selections
Press ctrl+alt+a on Windows and Linux,
or cmd+ctrl+a on OS X
When using with a multi-line selection, the lines will be indented
consistently first. If the selected lines are consistently indented,
the first = on each line will be aligned. The character to
align to for mid-line alignment can be configured via the settings.
Package Settings
The default settings can be viewed by accessing the Preferences
> Package Settings > Alignment > Settings – Default
menu entry. To ensure settings are not lost when the package is upgraded,
make sure all edits are saved to Settings – User.
align_indent
A boolean (true or false) setting that controls
if a multi-line selection should have its indent level aligned. Default: true
mid_line_tabs
A boolean (true or false) setting that controls
if mid-line alignment should be done using tabs if the current
file is set to use tabs for indentation. Please note that this
settings may cause the file to look incorrect in others editors
that have a different tab size set. It will also cause
multi-character operators to be aligned to the first character
instead of the character from alignment_chars. Default: false
alignment_chars
A list of characters to align mid-line when executing on a
multi-line selection. Default: ["="]
alignment_space_chars
The characters from alignment_chars that should have at
least once space before them. Default: ["="]
alignment_prefix_chars
Characters that should be aligned with alignment_chars. Default: ["+", "-", "&", "|", "<", ">", "!", "~",
"%", "/", "*", "."]
It is also possible to change settings on a per-syntax basis. For
example, by default Alignment adds the : character to the
alignment_chars setting for Javascript and JSON files.
Changelog
v2.0.0
Removed the old ctrl+shift+a key binding for Windows/Linux
and cmd+shift+a for OS X to prevent conflicts with the
Expand to Tag command key binding. ctrl+alt+a should be
used on Windows/Linux and ctrl+cmd+a on OS X.
v1.1.3
Added settings file for CSS to align on : characters also
v1.1.2
Fixed the indentation import to work when this package is loaded
before the Default package
v1.1.1
Fixed a math error when converting mid-line spaces to tabs
v1.1.0
Added mid_line_tabs settings
Fixed handling of mid-line alignment when
align_indent is false and indentation
is done via tabs
Added an additional key binding,
ctrl+alt+a (Windows, Linux) or cmd+ctrl+a
(OS X) that doesn't conflict with the new Expand Selection
to Tag command from Sublime Text b2102
v1.0.6
Fixed a bug with mid-line tabs causing incorrect
mid-line alignment
v1.0.5
Fixed a bug with multi-selection alignment
v1.0.4
Added align_indent, alignment_chars,
alignment_space_chars and alignment_prefix_chars
settings
Enhanced plugin to not indent blank lines when setting to
trim trailing white space is enabled
v1.0.3
Added Preferences menu entries and command palette
commands for preferences
v1.0.2
Enhanced plugin to remove extra whitespace not necessary for
alignment
Fixed handling of equal signs without whitespace before them
v1.0.1
Added multi-line alignment functionality
v1.0.0
Initial release
License
Sublime Alignment is licensed under the MIT license. Please see the
readme.creole file in the package directory for the text of
the license.
Source
The source code for Sublime Alignment is available on GitHub at
https://github.com/wbond/sublime_alignment.