Friday, May 21, 2021

Re: using a variable in a substitute command

On Fri, May 21, 2021 at 02:23:56PM EDT, Gary Johnson wrote:
> On 2021-05-20, Chris Jones wrote:
>
> > And as to doubling the textit slash it's needed because vim gobbles up
> > the initial 't' of 'textit' otherwise .. not sure why.
>
> In many contexts, Vim interprets '\t' as a tab character. See
>
> :help /\t

Yes. Actually in my final effort:

| :bufdo :g /^# \(.*\)$/let g:c = g:c + 1 | s//\='# \textit{' . g:c . ': ' . submatch(1) . '}'

... probably because it's already 'escaped' due to the fact that's in
single quotes, I found that vim left the \textit backslash alone.

As expected Tim's solution does exactly what I needed.

Thanks,

CJ

--
--
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/YKgAzezb34a%2Bn7zD%40turki.local.

No comments: