------------------------------------------------------------------------
15 hi ErrorMsg ctermfg=9 cterm=none ctermfg=red etc...
16 hi Visual ctermbg=61 cterm=none ctermfg=bg
17 hi VisualNOS ctermbg=61 cterm=none ctermfg=bg
18 hi Underlined ctermfg=fg ctermbg=bg term=underline
------------------------------------------------------------------------
I wanted to end up with this:
------------------------------------------------------------------------
15 hi ErrorMsg ctermfg=9 cterm=none ctermfg=red
16 hi Visual ctermbg=61 cterm=none ctermfg=bg
17 hi VisualNOS ctermbg=61 cterm=none ctermfg=bg
18 hi Underlined ctermfg=fg ctermbg=bg term=underline
------------------------------------------------------------------------
I gave the Align plugin a shot and eventually did the following:
15,18s/\ \ \+/@/g
15,18s/\ /@/g
15,18Align @
15,18s/@/\ /g
Is there a more 'standard' way to do this?
Thanks,
CJ
:help alignmap-tsp
might help.
Regards,
Chip Campbell
I had already read this, and experimented with it.
I selected the text via a Ctrl-V and issued a: ":Align \tsp" and nothing
happened.
Since I had tried many other things to get the plugin to align on white
spaces before I found alignmap-tsp, I did it again just to make sure and
saw the same result: the buffer is not modified.
I read (again) the intro at :h align-maps, sourced AlignMaps.vim to be
on the safe side, repeated the experience a couple of times, once with a
different test file containing:
------------------------------------------------------------------------
a b c d
a b c d
a b c d
------------------------------------------------------------------------
.. and still nothing happens.
I'm running Vim 7.1 on a debian lenny system and the plugin was
installed like so:
# vim-addons -v -w install align
In other words, it's the version of the plugin that ships with Vim,
installed by root, system-wide.
Thank you for your comments,
CJ
That's odd -- because it works for me, with your example as given
below. Now, although the Align command itself works with visually
selected blocks, the maps don't work with ctrl-v selected blocks (ie.
such visual blocks are treated as visually selected line ranges, like
"V"). One way to get the maps to work with visual blocks is with
vis.vim; you can get vis.vim from:
http://vim.sourceforge.net/scripts/script.php?script_id=1195 (stable)
http://mysite.verizon.net/astronaut/vim/index.html#VIS
(cutting edge)
With it, use ctrl-v to select the visual block and then :B \tsp (for
example).
> Since I had tried many other things to get the plugin to align on white
> spaces before I found alignmap-tsp, I did it again just to make sure and
> saw the same result: the buffer is not modified.
>
> I read (again) the intro at :h align-maps, sourced AlignMaps.vim to be
> on the safe side, repeated the experience a couple of times, once with a
> different test file containing:
>
> ------------------------------------------------------------------------
> a b c d
> a b c d
> a b c d
> ------------------------------------------------------------------------
>
> .. and still nothing happens.
>
> I'm running Vim 7.1 on a debian lenny system and the plugin was
> installed like so:
>
> # vim-addons -v -w install align
>
> In other words, it's the version of the plugin that ships with Vim,
> installed by root, system-wide.
>
>
Well, align/alignmaps doesn't come with vim, although it appears that
debian lenny adds it in on their own. That install procedure is also
not the standard way to install align/alignmaps, its a debian-lenny
"thing", and so I'm not familiar with it (I use fedora, myself). So to
determine why the alignmaps aren't working will take some investigation
(are plugin/AlignMapsPlugin.vim, autoload/AlignMaps.vim, etc in the
proper places, what is the result of :verbose map \tsp? etc), or
perhaps you could simply get the latest version
(http://mysite.verizon.net/astronaut/vim/index.html#ALIGN) and install it:
vim align.vba.gz
:so %
:q
Regards,
Chip Campbell
[..]
> > I selected the text via a Ctrl-V and issued a: ":Align \tsp" and
> > nothing happened.
------------------------------------------------------------------------
15 hi ErrorMsg ctermfg=9 cterm=none ctermfg=red etc...
16 hi Visual ctermbg=61 cterm=none ctermfg=bg
17 hi VisualNOS ctermbg=61 cterm=none ctermfg=bg
18 hi Underlined ctermfg=fg ctermbg=bg term=underline
------------------------------------------------------------------------
Actually, when I indent a few lines such as l. 15 and l. 17 above, the
plugin realigns them, so to speak.
------------------------------------------------------------------------
15 hi ErrorMsg ctermfg=9 cterm=none ctermfg=red etc...
16 hi Visual ctermbg=61 cterm=none ctermfg=bg
17 hi VisualNOS ctermbg=61 cterm=none ctermfg=bg
18 hi Underlined ctermfg=fg ctermbg=bg term=underline
------------------------------------------------------------------------
So it looks like it's doing something but it's limited to aligning the
each line's leading white space?
Or am I misunderstanding what the plugin does or can do when the
separator is white space?
If you take line 15 above for instance, there are seven spaces after
ErrorMSg, while line 16 has fourteen between Visual and ctermbg=61.
What's the plugin supposed to do?
The right thing to do as I see it would be to collapse all contiguous
spaces so that there is only one space separating fields, and then
expand them so that field1, field2, field3, etc. on each line starts in
the same column.
But then that's because that's what _I_ want the plugin to do for me in
this particular case.. :-)
> That's odd -- because it works for me, with your example as given
> below.
Never underestimate the creative powers of the User.
> Now, although the Align command itself works with visually selected
> blocks, the maps don't work with ctrl-v selected blocks (ie. such
> visual blocks are treated as visually selected line ranges, like "V").
> One way to get the maps to work with visual blocks is with vis.vim;
> you can get vis.vim from:
> http://vim.sourceforge.net/scripts/script.php?script_id=1195 (stable)
> http://mysite.verizon.net/astronaut/vim/index.html#VIS (cutting edge)
> With it, use ctrl-v to select the visual block and then :B \tsp (for
> example).
Yes, but I'm not using any kind of selection - I'm using the syntax as
defined in the help file:
:[range]Align \tsp
:[range]Align \Tsp
:[Range]Align \tsq ... etc.
[..]
> So to determine why the alignmaps aren't working will take some
> investigation (are plugin/AlignMapsPlugin.vim, autoload/AlignMaps.vim,
> etc in the proper places, what is the result of :verbose map \tsp?
> etc), or perhaps you could simply get the latest version
> (http://mysite.verizon.net/astronaut/vim/index.html#ALIGN)
> and install it:
>
> vim align.vba.gz
> :so %
> :q
Had done that just in case, but it gets me a screenful of messages where
all the <leader>xx's installed by the plugin are already mapped. I had
removed the 'lenny' version, and started a fresh instance of Vim, so I
don't know.
Anyway the version from your web site does exactly the same, just
removes leading blanks on every line that happens to have them.
The more I think about it, it's probably me misunderstanding what the
plugin should be doing when spaces are used as separators.
Thanks,
CJ
------------------------------------------------------------------------
15 hi ErrorMsg ctermfg=9 cterm=none ctermfg=red etc...
16 hi Visual ctermbg=61 cterm=none ctermfg=bg
17 hi VisualNOS ctermbg=61 cterm=none ctermfg=bg 18 hi Underlined ctermfg=fg ctermbg=bg term=underline -----------------------------------------------------------------------
-----------------------------------------------------------------------
15 hi ErrorMsg ctermfg=9 cterm=none ctermfg=red etc... 16 hi Visual ctermbg=61 cterm=none ctermfg=bg 17 hi VisualNOS ctermbg=61 cterm=none ctermfg=bg 18 hi Underlined ctermfg=fg ctermbg=bg term=underline ------------------------------------------------------------------------ So it looks like it's doing something but it's limited to aligning the each line's leading white space?
Or am I misunderstanding what the plugin does or can do when the separator is white space?
Yes, but I'm not using any kind of selection - I'm using the syntax as defined in the help file: :[range]Align \tsp :[range]Align \Tsp :[Range]Align \tsq ... etc. [..]
So to determine why the alignmaps aren't working will take some investigation (are plugin/AlignMapsPlugin.vim, autoload/AlignMaps.vim, etc in the proper places, what is the result of :verbose map \tsp? etc), or perhaps you could simply get the latest version(http://mysite.verizon.net/astronaut/vim/index.html#ALIGN)and install it: vim align.vba.gz :so % :qHad done that just in case, but it gets me a screenful of messages where all the <leader>xx's installed by the plugin are already mapped. I had removed the 'lenny' version, and started a fresh instance of Vim, so I don't know.
Anyway the version from your web site does exactly the same, just removes leading blanks on every line that happens to have them. The more I think about it, it's probably me misunderstanding what the plugin should be doing when spaces are used as separators.
[..]
> Again, what does
>
> :verbose map \tsp?
>
> show (that question mark needs to be there)?
v \tsp :<BS><BS><BS><CR>ma'>\tsp
Last set from ~/.vim/plugin/AlignMaps.vim
no \tsp <SNR>11_WS:'a,.s/^\(\s*\)\(.*\)/\=submatch(1).escape(substitute(submatch(2),'\s\+','@','g'),'\')/<CR>:AlignCtrl mI=lp0P0 @<CR>:'a,.Align<CR>:'y+1,'z-1s/@/ /g<CR><SNR>11_WE
Last set from ~/.vim/plugin/AlignMaps.vim
Thanks,
CJ