sinbad wrote:
On Monday, May 28, 2012 7:21:59 PM UTC+5:30, DrChip wrote:
On May 28, 2012, at 9:33 AM, sinbad<sinb**@gmail.com> wrote:
> i have a text as follows.
>
> apple banana
> cat dog
> elephant fan
> goat hen
>
> i want to make the above text aligned as follows.
>
> apple banana
> cat dog
> elephant fan
> goat hen
>
> is there any simple technique without doing to manually.
See if http://www.drchip.org/astronaut/vim/index.html#ALIGN helps (in
particular, the \tsp mapping).
Regards,
C Campbell
hi how can i do align only for the last column.
meaning if there are n columns first n-1 collumns
should be treated as one group and the last column should
be treated as another group.
for example if the text is as follows
one two three
four five six
even eight nine
ten eleven twelve
i want to be able to align as.
one two three
four five six
even eight nine
ten eleven twelve
how can this be done. i read through your documentation
couldn't readily figure out to do above. but i'm sure
it is explained in there. would be helpful if you can
quickly point it out.
Align doesn't really support "just the last column" in any direct
fashion. One may use the "-" to skip over aligning separators by making
Align consider them to be part of the field.
Things are slightly complicated by the fact that Align uses spaces as
its padding character.
First, I'll give an illustration of how to align your example:
* :%s/ /-/g
* :AlignCtrl -l
* :%Align -
* :%s/-/ /g
This changes the spaces to "-" characters; the second command informs
Align not to align on the first "-", but rather to treat them as part of
a field; Alignment is then done on "-"s, and then the "-"s are mapped
back to spaces. The result is what you wanted for the given example.
Now, to conform to your request to handle an arbitrary quantity of
skipping over "n-1" columns: use an appropriate substitute first, Align,
then revert the substitution.
* :%s/^\(.*\)\s\+\(\S\+\)$/\1X\2/
* :%Align X
* :%s/X/ /
(pick an "X" that doesn't appear in the text)
Of course, if you wish to do this often, then you might want to build a
macro to do this.
Regards,
Chip Campbell
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php