Quantcast

align columns

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

align columns

sinbadd
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.

cheers

--
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: align columns

Charles E Campbell Jr


On May 28, 2012, at 9:33 AM, sinbad <[hidden email]> 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

--
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: align columns

sinbadd
On May 28, 6:51 pm, Charles E Campbell <[hidden email]>
wrote:

> On May 28, 2012, at 9:33 AM, sinbad <[hidden email]> 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 ifhttp://www.drchip.org/astronaut/vim/index.html#ALIGNhelps (in particular, the \tsp mapping).
>
> Regards,
> C Campbell

while installing using tarball, i'm getting the following errors.
any idea why ?


***vimball*** Source this file to extract it! (:so %)
removed 6 files
Vimball Archive
extracted <plugin/AlignPlugin.vim>: 41 lines
Error detected while processing function vimball#Vimball:
line  131:
E474: Invalid argument: silent w! ++enc=1 /home/sinbad/.vim/plugin/
AlignPlugin.vim
wrote /home/sinbad/.vim/plugin/AlignPlugin.vim
extracted <plugin/AlignMapsPlugin.vim>: 242 lines
E474: Invalid argument: silent w! ++enc=2 /home/sinbad/.vim/plugin/
AlignMapsPlugin.vim
wrote /home/sinbad/.vim/plugin/AlignMapsPlugin.vim
extracted <plugin/cecutil.vim>: 510 lines
E474: Invalid argument: silent w! ++enc=0 /home/sinbad/.vim/plugin/
cecutil.vim
wrote /home/sinbad/.vim/plugin/cecutil.vim
extracted <doc/Align.txt>: 1469 lines
E474: Invalid argument: silent w! ++enc=9 /home/sinbad/.vim/doc/
Align.txt
wrote /home/sinbad/.vim/doc/Align.txt
extracted <autoload/Align.vim>: 1029 lines
E474: Invalid argument: silent w! ++enc=9 /home/sinbad/.vim/autoload/
Align.vim
wrote /home/sinbad/.vim/autoload/Align.vim
extracted <autoload/AlignMaps.vim>: 330 lines
E474: Invalid argument: silent w! ++enc=0 /home/sinbad/.vim/autoload/
AlignMaps.vim
wrote /home/sinbad/.vim/autoload/AlignMaps.vim
line  160:
E151: No match: /home/sinbad/.vim/doc/*
did helptags

--
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: align columns

Charlie Kester
In reply to this post by sinbadd
On 05/28/2012 06:33 AM, sinbad 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.

If you don't want to use the plugin, here's a little utility that does
the job:

http://www.cs.indiana.edu/~kinzler/align/

(Sometimes we get so enamored with vim's plugin model that we forget the
old-school Unix way of doing things with pipes and filters.)

--
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: align columns

Charles E Campbell Jr
In reply to this post by sinbadd
sinbad wrote:

> On May 28, 6:51 pm, Charles E Campbell<[hidden email]>
> wrote:
>    
>> On May 28, 2012, at 9:33 AM, sinbad<[hidden email]>  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 ifhttp://www.drchip.org/astronaut/vim/index.html#ALIGNhelps (in particular, the \tsp mapping).
>>
>> Regards,
>> C Campbell
>>      
> while installing using tarball, i'm getting the following errors.
> any idea why ?
>
>
> ***vimball*** Source this file to extract it! (:so %)
> removed 6 files
> Vimball Archive
> extracted<plugin/AlignPlugin.vim>: 41 lines
> Error detected while processing function vimball#Vimball:
> line  131:
> E474: Invalid argument: silent w! ++enc=1 /home/sinbad/.vim/plugin/
>    
Sounds like you have an old vimball; in v32 there's a note that says:

               * fenc extraction was erroneously picking up the
                 end of the line number when no file encoding
                 was present.  Fixed.

So you should update your vimball plugin; you can also get it from my
website:

  http://www.drchip.org/astronaut/vim/index.html#VIMBALL

Its up to v35 now.

Regards,
C 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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: align columns

sinbadd
On May 29, 7:48 am, Charles E Campbell Jr <[hidden email]>
wrote:

> sinbad wrote:
> > On May 28, 6:51 pm, Charles E Campbell<[hidden email]>
> > wrote:
>
> >> On May 28, 2012, at 9:33 AM, sinbad<[hidden email]>  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 ifhttp://www.drchip.org/astronaut/vim/index.html#ALIGNhelps(in particular, the \tsp mapping).
>
> >> Regards,
> >> C Campbell
>
> > while installing using tarball, i'm getting the following errors.
> > any idea why ?
>
> > ***vimball*** Source this file to extract it! (:so %)
> > removed 6 files
> > Vimball Archive
> > extracted<plugin/AlignPlugin.vim>: 41 lines
> > Error detected while processing function vimball#Vimball:
> > line  131:
> > E474: Invalid argument: silent w! ++enc=1 /home/sinbad/.vim/plugin/
>
> Sounds like you have an old vimball; in v32 there's a note that says:
>
>                * fenc extraction was erroneously picking up the
>                  end of the line number when no file encoding
>                  was present.  Fixed.
>
> So you should update your vimball plugin; you can also get it from my
> website:
>
>  http://www.drchip.org/astronaut/vim/index.html#VIMBALL
>
> Its up to v35 now.
>
> Regards,
> C Campbell

Yup you are right, vimball is old. it worked after updating the
vimball.
thanks for this nice script.

Thanks charlie for pointing to the utility.

--
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: align columns

Tony Mechelynck
On 29/05/12 06:46, sinbad wrote:

> On May 29, 7:48 am, Charles E Campbell Jr <[hidden email]>
> wrote:
>> sinbad wrote:
>>> On May 28, 6:51 pm, Charles E Campbell<[hidden email]>
>>> wrote:
>>
>>>> On May 28, 2012, at 9:33 AM, sinbad<[hidden email]>  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 ifhttp://www.drchip.org/astronaut/vim/index.html#ALIGNhelps(in particular, the \tsp mapping).
>>
>>>> Regards,
>>>> C Campbell
>>
>>> while installing using tarball, i'm getting the following errors.
>>> any idea why ?
>>
>>> ***vimball*** Source this file to extract it! (:so %)
>>> removed 6 files
>>> Vimball Archive
>>> extracted<plugin/AlignPlugin.vim>: 41 lines
>>> Error detected while processing function vimball#Vimball:
>>> line  131:
>>> E474: Invalid argument: silent w! ++enc=1 /home/sinbad/.vim/plugin/
>>
>> Sounds like you have an old vimball; in v32 there's a note that says:
>>
>>                 * fenc extraction was erroneously picking up the
>>                   end of the line number when no file encoding
>>                   was present.  Fixed.
>>
>> So you should update your vimball plugin; you can also get it from my
>> website:
>>
>>   http://www.drchip.org/astronaut/vim/index.html#VIMBALL
>>
>> Its up to v35 now.
>>
>> Regards,
>> C Campbell
>
> Yup you are right, vimball is old. it worked after updating the
> vimball.
> thanks for this nice script.
>
> Thanks charlie for pointing to the utility.
>


The current "official" Vim runtime files include Vimball v35. If your
$VIMRUNTIME/plugin/vimballPlugin.vim is recent enough you can uninstall
the Vimball scripts (there are several) under ~/.vim/plugin,
~/.vim/autoload and maybe others.


Best regards,
Tony.
--
America was discovered by Amerigo Vespucci and was named after him,
until people got tired of living in a place called "Vespuccia" and
changed its name to "America".
                -- Mike Harding, "The Armchair Anarchist's Almanac"

--
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: align columns

sinbadd
In reply to this post by Charles E Campbell Jr
On Monday, May 28, 2012 7:21:59 PM UTC+5:30, DrChip wrote:

> On May 28, 2012, at 9:33 AM, sinbad &lt;sinb**@gmail.com&gt; wrote:
>
> &gt; i have a text as follows.
> &gt;
> &gt; apple  banana
> &gt; cat   dog
> &gt; elephant fan
> &gt; goat hen
> &gt;
> &gt; i want to make the above text aligned as follows.
> &gt;
> &gt; apple      banana
> &gt; cat         dog
> &gt; elephant fan
> &gt; goat       hen
> &gt;
> &gt; 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.

tnx

--
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: align columns

Charles Campbell
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&lt;sinb**@gmail.com&gt; wrote:
>>
>> &gt; i have a text as follows.
>> &gt;
>> &gt; apple  banana
>> &gt; cat   dog
>> &gt; elephant fan
>> &gt; goat hen
>> &gt;
>> &gt; i want to make the above text aligned as follows.
>> &gt;
>> &gt; apple      banana
>> &gt; cat         dog
>> &gt; elephant fan
>> &gt; goat       hen
>> &gt;
>> &gt; 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
Loading...