> - there might be a succession of double bars (e.g. ||||||), in which
> case X must not be inserted.
>
>> For #1, that would be something like either of these:
>>
>> s/||\_$\@<!/& X/g
>
> works beautifully!
I think this fails your last test about "||||||", but as this is
a new detail, I claim leniency :)
To meet your "||||||" test, it should work with
s/||\(|\|\_$\)\...@!/& X/g
(I've shifted to the "\...@!" which seems to work where the "\@<!"
doesn't...kinda surprised me that didn't work). I tried it on a
line that looked like
|| abc || def |||||| ghi ||
that changed it into
|| X abc || X def |||||| X ghi ||
which I understand was what you wanted.
> Presumably, \_$\@<! means "anything but end of line" ?
close...it means "an EOL can't match here" (the subtle difference
being in the case of nothing..."anything" requires a "something"
and fails on a "nothing"; whereas "nothing" can be satisfied by
the negative "no-EOL-here" assertion) You can read more about it at
:help /\@<!
:help /\...@!
> I can envisage the need for operating this substitution on every other
> line of a selected range!
>
> ||X dfjdfjd ||X dfjdkfjsd ||X sds ||
> || dfjdfjd || dfjdkfjsd || sds ||
> ||X dfjdfjd ||X dfjdkfjsd ||X sds ||
> || dfjdfjd || dfjdkfjsd || sds ||
Doing things on odd/even lines requires reaching into Vim's
control structures, something like
:g/^/if line('.') % 2 | s/||\(|\|\_$\)\...@!/& X/g | endif
(":g/^/" is a common notation for "do the following set of Ex
commands on every line" because every line has a
"beginning-of-line" and thus matches) It can be generalized with
any arbitrary modulo:
:g/^/if line('.') % n == 1 | actions_on_nth_line | endif
where the "n" is the number of lines you want to skip.
-tim
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---