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. Niels
signature.asc
Description: OpenPGP digital signature
