> On Nov 4, 5:33 pm, "Benjamin R. Haskell" wrote:
>> On Thu, 4 Nov 2010, Benjamin R. Haskell wrote:
>>> On Thu, 4 Nov 2010, rameo wrote:
>>
>>>> I find myself often to align blocks of text and thought to create a
>>>> regex to remove all leading spaces in a block.
>>
>>>> p.e.
>>
>>>> text a
>>>> text b
>>>> text c
>>>> text d
>>
>>>> I would like to select a visual block around these 4 pieces of text
>>>> and remove all leading spaces, how can I do this?
>> [...]
>>
>> :'<,'>s/\%V\s*\%V//
>>
>> --
>> Best,
>> Ben
>
>
> It still moves the blocks at the right side of current block. (please
> see my previous message)
I was hoping the spaces-only lines were what you meant... I guess you
want something like this non-working example:
:'<,'>s/\%V\(\s*\)\(\%(\S\+\s*\)*\)\%V/\2\1/
replace:
1: as many leading spaces as present
2: followed by optional runs of non-spaces and optional spaces
with:
2: the non-leading-space content
1: the leading spaces
(essentially: move leading spaces to the end of the block)
It's not working though because something is 'greedy' where I'm not
expecting. Any other regexpers see what I'm doing wrong?
Another attempt fails for even weirder reasons:
:'<,'>s/\%V\(\s*\)\(\%[\S.*]\)\%V/\2\1/
E64: star follows nothing
E476: invalid command
Is \%[] compiled internally to something else? (Otherwise I see a \s*
and .*, in both cases the '*' follows something.)
--
Best,
Ben
--
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
No comments:
Post a Comment