Wednesday, September 27, 2023

Re: Replace spaces with underscore after some pattern in line

On Wed, 27 Sep 2023, "'c.willis111' via vim_use" wrote:
> --
> Hi
>
> to my slight surprise this works:
>
>
> :%s/\(XXX[^ ]*\) /\1_/g
>
>
> The reason I had doubts is that the successive replacements start at the beginning of the earlier replacement.
>
>
> (Sorry about layout. I'm not into this add at the end bit).
>
>
> regards - Chris
>
>
> Oh no it doesn't. One needs to repeat until all done. The g is pointless. - Chris

I am a newbie to vim, but would like to learn it . Please tell me what
exactly does 1_ do in your command ? I knew that you wanted to substitute by underscore, but why
1 was there?

--
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/281db617-1c2f-1a4b-c58f-82a0fc74864%40126.com.

No comments: