Emacs package that provides visual version of align-regexp
command.
This package is available from melpa, just do M-x package-install RET ialign RET
.
Bind the main function with:
(global-set-key (kbd "C-x l") #'ialign)
Put path to file ialign.el
somewhere in your load-path
, then
(require 'ialign)
(global-set-key (kbd "C-x l") #'ialign)
You can also bind it to different key ((kbd "your-key")
).
If you have an optional package - pcre2el - installed, you can use PCRE regexps for alignment.
To use it, mark a region and then call ialign
.
You can enter a regexp in the minibuffer that will be passed to align-regexp
command.
As the contents of minibuffer change, the region is realigned.
You can also specify other arguments to align-regexp
:
- Increment/decrement spacing (padding) with
C-c -
andC-c +
- Increment/decrement the parenthesis group which will be modified with
C-c [
andC-c ]
Negative parenthesis group means justify (prepend space to each group). - Repeat the alignment throughout the line with
C-c C-r
. - Toggle tabs with
C-c C-t
. - Toggle case sensitivity with
C-c M-c
. - Go to next/previous history element with
M-n
andM-p
.
Interactively align region BEG END using regexp read from minibuffer.
As characters are typed in the minibuffer, the region is aligned
using align-regexp
and the result is presented to the user.
In the minibuffer, ialign-minibuffer-keymap
is the active keymap.
Toggle repeat argument passed to align-regexp
.
When the repeat argument is non-nil, the alignment is repeated throughout the line.
Toggle tab usage during alignment.
Toggle case-fold searching on or off.
Toggle PCRE input mode. With that, the input is treated as a PCRE regexp, and is implicitly converted to elisp regexp implicitly during alignment. This requires the pcre2el library.
Set the parenthesis group argument for the align-regexp
command to GROUP.
Interactively, this will read GROUP from minibuffer.
Increment/decrement the parenthesis group argument passed to align-regexp
.
Set the spacing parameter passed to align-regexp
command to SPACING.
Interactively, this will read SPACING from minibuffer.
Increment/decrement the amount of spacing passed to align-regexp
command.
Align the region using the current regexp and commit change in the buffer.
The region is aligned using the current regexp only if it’s valid. Next alignments will use the newly aligned region.
Describe available keybindings to the user.
Keymap used in the minibuffer when ialign
command is executed.
Key | Command |
---|---|
C-c C-r | ialign-toggle-repeat |
C-c C-t | ialign-toggle-tabs |
C-c M-c | ialign-toggle-case-fold |
C-c C-p | ialign-toggle-pcre-mode |
C-c + | ialign-increment-spacing |
C-c - | ialign-decrement-spacing |
C-c [ | ialign-decrement-group |
C-c ] | ialign-increment-group |
C-c C-f | ialign-set-group |
C-c C-s | ialign-set-spacing |
C-c RET | ialign-commit |
C-c C-c | ialign-update |
C-c ? | ialign-show-help |
An integer that represents the default amount of padding to use.
The default value is the same as align-default-spacing
.
Alias: ialign-initial-spacing
.
A value that says when the region should be aligned with tabs.
- If it’s
nil
, never use tabs. - If it’s
t
, always use tabs. - If it’s the symbol ‘indent-tabs-mode, use value of variable
indent-tabs-mode
.
The dafault value is nil
.
A value that says when to align the region as the characters are typed.
- If it is
nil
, never update (you can manually update withialign-update
). - If it is
t
, always update. - If it is an integer, update if the number of lines in the region is less than or equal to this, otherwise do not update.
The default value is t
.
String, initial regexp to use when calling ialign
.
The default value is \\(\\s-+\\)
.
Initial group to use when calling ialign
.
The default value is 1.
Default state of repeat
argument passed to align-regexp
.
The default value is nil
.
String to prepend to the regexp, if the regex doesn’t have a subgroup.
Set this to \\(\\s-*\\)
to implicitly prepend that string to
the regexp, if the regexp doesn’t contain a subgroup expression.
The default value is nil
.
If non-nil, enable PCRE mode when calling ialign
, as if by
calling ialign-toggle-pcre-mode
.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.