1

I am trying to set 'foldtext', but it seems I misunderstand expressions, types, etc. of Vim fundamentally.

Why does the following refuse to work?

set foldtext=v:folddashes."TEST"

Whereas this works?

func Test()
    return "TEST"
endfunc
set foldtext=v:folddashes.Test()

I assume the . is not string concatenation in this context, but what is it instead?

Furthermore, why does Vim don't "recover" if 'foldtext' is restored to default (or any other valid value)?

3
  • I further assume, that the value stored in 'foldtext' is evaluated later on, but still don't see the point why a string does not work whereas a function returning a string works.
    – doak
    Feb 24, 2020 at 10:14
  • It does get more confusing, it has to be related to how the stuff is evaluated: set foldtext=v:folddashes.'TEST' does work.
    – doak
    Feb 24, 2020 at 10:27
  • From :h expr6: For String concatenation ".." is preferred, since "." is ambiguous, it is also used for |Dict| member access and floating point numbers. So always use either v:folddashes . Test(), or v:folddashes..Test() instead.
    – Matt
    Feb 24, 2020 at 12:17

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.