Thursday, September 28, 2023

Re: Replace spaces with underscore after some pattern in line

Hi,

I hope I won't say a stupidity…

Le 28-09-2023, à 14:18:22 +0800, wenxin Wang a écrit :

>>:%s/\(XXX[^ ]*\) /\1_/g
>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?

It's not the '_1' that is important here, it the '\1', which is a back
reference to what is in between the (). So everything in there will be
used in the substitution and to that you add '_'.

--
--
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/ZRVijnJ025/BTiSe%40paros.lan.

No comments: