On 2020-08-17, Gary Johnson wrote:
> On 2020-08-17, Anton Shepelev wrote:
> > Hello, all
> >
> > How can one prepend a Vim string option? I need to prepent
> > formatlistpat for Markdown. I have tried to combine `set'
> > and `execute()', but to no avail. `execute()' is documented
> > as returning the command output as a string, yet I can't
> > seem to call it as a function and use the return value in
> > `set':
> >
> > set formatlistpat=prepend|execute('set formatlistpat?')
> >
> > Also I fear I will lose escapes this way. Is it possible to
> > preserve them?
>
> Here are a couple of ways to do that.
>
> :execute 'set formatlistpat=' . 'patternprefix' . &formatlistpat
>
> :let &formatlist = 'patternprefix' . &formatlist
Oops. That second example should of course be:
:let &formatlistpat = 'patternprefix' . &formatlistpat
>
> where patternprefix is the string you wish to prepend to
> 'formatlistpat'.
>
> See:
>
> :help :execute
> :help :let-option
>
> Note that 'formatlistpat' is a single pattern, not a list of
> patterns, so you would not use :set^= to prepend a list element to
> it. If interested anyway, see:
>
> :set^=
HTH better,
Gary