1

I get a bit confused as to when we access a variable value like this:

:echom &textwidth
" 120

And when it's done like this:

:let a
" a                     #4

And when it's done like this:

:set textwidth?
textwidth=120

What is the difference between those three ways of getting the variable value, and when should they be properly used?

1 Answer 1

3

A variable named &name is the Vim script representation of the option name.

So &textwidth is the Vim script representation of the option textwidth.

See :h :let-&.

The let a just prints the value of the variable a. I would prefer :echo a here.

Addon: You also might want to read :help internal-variables to understand the name spaces of variables.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.