Saturday, January 25, 2014

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

> I'm fairly new to Vim myself, but I just tried this.
>
> I entered this into a new buffer --
>
> - This is a te- st
> - foo bar
> - This is another - test I mean
>
> and ran this from the command line (using "x" as the replacement text) --
>
> :%s/\v^(.+)\- /\1x/g
>
> and I got this:
>
> - This is a texst
> - foo bar
> - This is another xtest I mean
>
> Note that I used "\v" (very magic) to make Vim use regular expressions that
> the rest of the world understands. :-)

Not as easy. According to the documentation only alphanumeric characters, underscore and non-ASCII are guaranteed not to have special meaning in this mode. I.e. you must escape the space just as you escaped hyphenminus. Both though *currently* have no special meaning.

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

Post a Comment