How to copy the value of a vim option to a register

vim

Solution

You have `:put`

:put=&spellfile

You have `i_CTRL-R_=`

blabla in insertmode ^R=&spellfile^M

(with ^R being CTRL-R typed in insert-mode, and ^M the carriage return you'll type to validate the input given to CTRL-R=)

If you want to put it into a register -> `:let @a = &spellfile` (or any other register name -> `:h registers`)

Problem

In vim you can set option with `:set`. For example :set spell to enable spell control. And :set spellfile=/home/custom_spell.txt to set the location of the custom spell file. You can print the value of an option with echo. For example echo &spellfile Now I would like to copy the value of the option spellfile to a buffer. How can I do that?

Original source