sponsor Vim development Vim logo Vim Book Ad

AutoAlign : Automatically align as you type (autoalign): bib c c++ html maple matlab tex vim

 script karma  Rating 110/35, Downloaded by 7206  Comments, bugs, improvements  Vim wiki

created by
Charles Campbell
script type
                               [AutoAlign also requires vimscript#294]

Note:  this plugin is not a right-margin justification tool; see vimscript#177 for that

AutoAlign is currently composed of one regular plugin and six ftplugins.  As you type statements such as (for vim)

let xyz= 1
let x= 2

the ftplugin/vim/AutoAlign script will call upon the Align command to line up those equal signs, resulting in aligned equal signs (which can't be usefully shown here due to browsers' use of proportional fonts).

Similarly the c ftplugin will do so for

x= 3;
xy[0]= 4;
abc->def= 5;

one= 2;

(it only applies to what you're currently typing, it doesn't take any previously existing lines into account).  For c++,
= signs, <<, and >> operators get aligned.  For maple, :=.  

Former Version Notes:
   5: AutoAlign maps and functions changed to allow use of "." to repeat entry of =... expressions.  Uses g:mapleader instead of a built-in backslash to access AlignMaps.  First release of AutoAlign using vim's user-help.
   4: Now supports: bib c cpp tex vim. AutoAlign now breaks the undo sequence at every align operation, so one undo undoes the entire AutoAlign.  Bugfix: (with virtual edit) has been fixed (when backspacing over ==).  Bugfix: unwanted beeping due to virtual edit being off fixed
   3: Now supported: bib c tex vim.  :AA toggles AutoAlign on and off. AutoAlign now auto-aligns only blocks of alignable text.  cecutil.vim included (SaveMark, SaveWinPosn, etc)

(alpha/beta version available at http://www.drchip.org/astronaut/vim/index.html#AUTOALIGN)
install details
1. Get vimball v18 or later (vimscript#1502) if you  haven't done so already.  Be sure to remove all vestiges of any older vimball versions, too.  (if you have vim 7.1a or later, you probably can skip this step)
2. vim AutoAlign.vba.gz
   :so %
3. AutoAlign uses vimscript#294 (Align, AlignMaps); you'll also need that if you haven't gotten it yet.

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
AutoAlign.vba.gz 14 2013-11-25 7.3 Charles Campbell various bugfixes
AutoAlign.vba.gz 13 2007-08-16 7.0 Charles Campbell AutoAlign leaves "." alone when it starts; thus, one can now insert "= 0", for example, and re-apply it with vim's "." operator.  Tnx to Antony Scriven!
Some bug fixes for C++'s > and < auto-aligning.
AutoAlign now passes the pluginkiller test. (vimscript#1489)
AutoAlign.vba.gz 12 2006-09-19 7.0 Charles Campbell Fixed a bug with ftplugin/bib/AutoAlign.vim (ie. for LaTeX *.bib files)
AutoAlign.tar.gz 11 2006-03-23 6.0 Charles Campbell I inadvertently left debugging on in AutoAlign v10; this one has debugging de-activated.
Plus some bugfixes.
AutoAlign.tar.gz 10 2006-03-20 6.0 Charles Campbell Works with ve= and ve=all.  Uses startinsert or startinsert!, depending on whether the cursor in inside the line or being used to append.
AutoAlign.tar.gz 7 2005-11-28 6.0 Charles Campbell AutoAlign now supports html
AutoAlign now has b:autoalign_suspend# for suspend-alignment patterns
An undefined b:autoalign_reqdpat# no longer causes an error
AutoAlign.tar.gz 6 2005-03-30 6.0 Charles Campbell AutoAlign is now split into a plugin containing the majority of vimscript; the supported ftplugins contain the invoking imaps and pattern definitions that the plugin uses.  Matlab support added.  Should be easy to add more languages should anyone wish to contribute the needed patterns!  Currently supported: bib c cpp maple matlab tex vim
ip used for rating:

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.