Align : Provides commands and maps to help produce aligned text, eqns, declarations, etc
script karma |
Rating 198/57,
Downloaded by 717 |
created by |
Charles Campbell |
|
script type |
utility |
|
description |
Align and AlignMaps lets you align statements on their equal signs, make
comment boxes, align comments, align declarations, etc. There are two basic
commands provided by this package:
AlignCtrl options sep1 sep2 sep3 ...
[range]Align sep1 sep2 sep3 ...
The "sep#" are regular expressions which describe separators that delineate
fields; Align will line up the separators. The range may be any Vim range,
_including_ visual-blocks. Align works on lines of the form:
(ws==whitespace)
ws-field-ws-sep-ws-field-ws-sep-ws-field-...
ws-field-ws-sep-ws-field-ws-sep-ws-field-...
Note that white-space about separators is ignored.
There are several options to help with deciding what to do with initial white
space. Usually Align re-uses the first line's initial white space, but one
may use AlignCtrl to retain or remove each line's initial white space.
Align handles alignment on multiple separators, not just the first one, and
the separators may be the same across the line or different.
The <Align.vim> and <AlignMaps.vim> files are plugins and definitely require
vim 6.0 or higher.
Some examples of use:
:5,10Align =
Align on '=' signs
:'<,'>Align = + - \* /
Align on any of the five separator characters shown.
Note that visual block mode was used to fire off Align.
:AlignCtrl =lp1P1I
which means:
= all separators are equivalent
l use left-justification
p1 pad one space before each separator
P1 pad one space after each separator
I preserve and apply the first line's leading white space to all
Align'd lines
:help align
Gives help for Align
Alignment control allows for left or right justification or centering of
fields, cyclic (sequentially active) or equivalent (simultaneously active)
regular expressions to specify field separators, initial white space control,
optional visual-block use (ie. apply Alignment only within a block),
user-specified white-space padding about separators, and multiple separators.
AlignMaps.vim provides a number of maps which make using this package easy:
\t= \t| \t, etc.
AlignMaps also provides some internally complex maps for aligning C
declarations, Ansi C function arguments, html tables, LaTeX tabulars, and
trailing comments:
\adec \afnc \Htd \acom etc.
To see some examples of this, check out
http://www.erols.com/astronaut/vim/textab.html#Examples
(the proportional fonts used by most browsers in showing you this page
preclude showing the examples here). The help for Align and AlignCtrl also
contains many examples.
Sometimes one wants to align only a subset of text in a range, based on
patterns or column extents. Align supports both types of restrictions!
Visual-block selection may be used to restrict Align to operate only
within that visual block.
AlignCtrl supports "g" and "v" patterns that restrict Align to
operate on lines which match (or don't match, respectively) those
patterns.
New Stuff:
There's a number of new AlignCtrl options:
- allows one to skip a separator (treat it as part of a field)
+ repeat the last lrc justification (ex. lr+ == lrrrrrr... )
: treat the rest of the line as a field; acts as a modifier
to the last lrc.
< left-justify the separator
> right-justify the separator
| center the separator
These are, except for the ":", cyclic parameters. In other words, >< is
equivalent to ><><><><... . Thus separators can be of differing lengths (ex.
-\+ as a separator pattern can match -, --, ---, etc and the separators will
be left/right/center justified as you wish).
Alternative Aligners:
Gergely Kontra's vimscript#176
Johannes Zellner's http://www.zellner.org/vim/autoload/
Thank you for rating Align!
|
|
install details |
1. Put <Align.tar.gz> in your .vim or _vimfiles directory.
2. gunzip Align.tar.gz
3. tar -oxvf Align.tar
Result: plugin/Align.vim
plugin/AlignMaps.vim
doc/Align.txt
4. Fire up vim or gvim, then
:helptags ..path../.vim/doc
-or- : helptags ..path\_vimfiles\doc
|
|
script versions (upload new version)
Click on the package to download.
Align.tar.gz |
16 |
19-Sep-2002 |
6.0 |
Charles Campbell |
New: left/right/center justification for separators (AlignCtrl <>|)
AlignCtrl's : now modifies previous lrc
AlignMaps: <c-v> removed for <mswin.vim> compatibility
BugFixes: ignorecase and y,z marks restored
|
Align.tar.gz |
13 |
19-Aug-2002 |
6.0 |
Charles Campbell |
Bug fixes: zero-length g/v patterns accepted, now always ignores blank
lines, and "AlignCtrl default" now also clears g/v patterns. |
Align.tar.gz |
11 |
15-Jul-2002 |
6.0 |
Charles Campbell |
New -+: alignment control options, handles ignorecase, uses =~# instead of =~, prevents infinite looping on zero-length separator patterns.
|
Align.tar.gz |
9 |
25-Jun-2002 |
6.0 |
Charles Campbell |
padding can now be specified for each separator (cylic padding), bug fixes,
more documentation. |
Align.tar.gz |
5 |
15-May-2002 |
6.0 |
Charles Campbell |
Version 5 of <Align.vim> has been upgraded several ways:
* bug fixes such as allowing
ragged-right lines to remain ragged
right rather than padded out with
blanks
* AlignPush() and AlignPop() functions
to push/pop alignment control settings
* AlignCtrl itself now returns a
string which may be used to restore
alignment control settings
* The <Align.vim> script is shorter
because the two passes are now done
via a while loop rather than having
code duplication.
* The \"I\" AlignCtrl option is now
default (uses the first line's leading
white space for subsequent lines)
* AlignCtrl now has
AlignCtrl g pattern
AlignCtrl v pattern
which allows a pattern to (de)select
a line for alignment; useful for
aligning on lines which do (or do
not) match a pattern.
|
Align.tar.gz |
3 |
09-May-2002 |
6.0 |
Charles Campbell |
Initial upload |
|