sponsor Vim development Vim logo Vim Book Ad

AlignFromCursor : Perform :left / :right only for the text part right of the cursor.

 script karma  Rating 5/2, Downloaded by 124    Comments, bugs, improvements  Vim wiki

created by
Ingo Karkat
 
script type
utility
 
description
DESCRIPTION
This plugin offers commands and mappings that align only the text to the right
of the cursor, and keep the text to the left unmodified, unlike the built-in
:left and :right, which always work on the entire line.
This is useful e.g. for right-aligning the "-- Author" attribution in a
fortune, the help tags definitions in this help file, or to left-align a
comment to a particular column.
The alignment width defaults to 'textwidth', can be passed as a [count] to the
mappings, and there are mappings that take the actual width from adjacent
previous / next lines.

RELATED WORKS
- The Align plugin (vimscript #294) offers a general-purpose :Align command
  and many mappings for text alignment along various characters, but those are
  more specialized for certain syntax fragments and do not consider the
  current cursor position like this plugin.
- The Tabular plugin (https://github.com/godlygeek/tabular) is similar to the
  Align plugin.


USAGE
[width]<Leader>le
:[range]LeftAlignFromCursor [width]
                        Left-align the text part right of the cursor to
                        [width] columns (default 'textwidth' or 80 when
                        'textwidth' is 0). Cp. :left.
                        Applies to all lines in [range], based on the current
                        cursor position.

[count]<Leader>lp       Left-align the text part right of the cursor to the
[count]<Leader>ln       indent of the [count]'th previous / next line.


[width]<Leader>ri
:[range]RightAlignFromCursor [width]
                        Right-align the text part right of the cursor to
                        [width] columns (default 'textwidth' or 80 when
                        'textwidth' is 0). Cp. :right.
                        Applies to all lines in [range], based on the current
                        cursor position.

[count]<Leader>rp       Right-align the text part right of the cursor to the
[count]<Leader>rn       width of the [count]'th previous / next line.
 
install details
INSTALLATION
This script is packaged as a vimball. If you have the "gunzip" decompressor
in your PATH, simply edit the *.vmb.gz package in Vim; otherwise, decompress
the archive first, e.g. using WinZip. Inside Vim, install by sourcing the
vimball or via the :UseVimball command.
    vim AlignFromCursor*.vmb.gz
    :so %
To uninstall, use the :RmVimball command.

DEPENDENCIES
- Requires Vim 7.0 or higher.
- repeat.vim (vimscript #2136) plugin (optional)
 

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
AlignFromCursor-1.12.vmb.gz 1.12 2013-01-19 7.0 Ingo Karkat Fix slowness of :RightAlignFromCursor in connection with plugins like recover.vim, caused by the repeated triggers of InsertEnter / InsertLeave events inserting a single space.
AlignFromCursor-1.11.vmb.gz 1.11 2012-12-06 7.0 Ingo Karkat BUG: On repeat, the original [count] is overridden by the align commands, causing e.g. a toggling of right-align and align to column 1 on repeated <Leader>ri.
AlignFromCursor.vba.gz 1.10 2012-08-02 7.0 Ingo Karkat ENH: Do not :retab the entire line (which also affects leading indent and whitespace after the area, just render the modified whitespace around the cursor according to the buffer's indent settings.
AlignFromCursor.vba.gz 1.00 2012-08-01 7.0 Ingo Karkat Initial upload
ip used for rating: 54.235.20.17

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.
   
SourceForge.net Logo