Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

vim

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?

like image 419
sjdh Avatar asked May 12 '14 08:05

sjdh


People also ask

How do I yank to a register in Vim?

2.2. Vim is a powerful editor. First, in the Normal mode, we move our cursor on the last word “editor” and press yaw to yank the word editor into the unnamed register “”. Next, we move the cursor to an empty line and press p without giving a register name. We'll see the yanked text “editor” is pasted.

What is the default register in Vim?

vim has a unnamed (or default) register that can be accessed with "" . Any text that you delete (with d , c , s or x ) or yank (with y ) will be placed there, and that's what vim uses to p aste, when no explicit register is given.

How do I delete a register in Vim?

To clear the a register, for instance, I type q a q to set the a register to an empty string.


1 Answers

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)

like image 126
Luc Hermitte Avatar answered Oct 21 '22 19:10

Luc Hermitte