Sunday, January 26, 2014

Re: Replacing a string which is in a line and not in the beginning?

Hi Niels!

On So, 26 Jan 2014, Niels Kobschätzki wrote:

> On 26 Jan 2014, at 5:59, Marc Weber wrote:
>
> > Excerpts from Niels Kobschaetzki's message of Sat Jan 25 11:37:24 +0100 2014:
> >> And I want to replace all occurrences of "- " when they are not at the
> >> beginning of the line. So the above mentioned file should look like:
> >
> > There are always two ways to cope with this "if they are not". Fastest:
> >
> > (This assumses " - " is still meant to be beginnig of the line, thus
> > even if there are leading spaces)
> > :%s/^(\s*)- /\1DONT_REPLACE_THIS/
> > :%s/- //
> > # substitute DONT_REPLACE_THIS back:
> > :%s/^(\s*)DONT_REPLACE_THIS/\1- /
> >
> > second way is looking up all that "no match" magic in :h regexp
> > Eg: |/\@!| \@! \@! nothing, requires NO match |/zero-width| (*)
>
> Good to know, I have to save this somewhere. Thanks.

It is already in the help

Best,
Christian
--
Wir nähern uns immer mehr der Entdeckung Gottes durch die
Wissenschaft. Ich bange um sein Schicksal.
-- Stanislaw Jerzy Lec (eig. S. J. de Tusch-Letz)

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: