Vim: Expression register

Today's Vim discovery is the expression register, "=. I wanted to insert the value of a Vim option (namely iskeyword) into a buffer so I could edit / play with it. Normally I'd have done

:set iskeyword?

to display the value, and then typed the result out by hand by reading what it output. But you can use the expression register to paste it directly. In Normal mode:

"=&iskeyword<CR>p

(where means hit Enter). When you do "= in Normal mode, it prompts you to give it an expression. When you hit enter, it will evaluate the expression and use the result as the contents of the register. See also :h quote=.

Tags:

Leave a Reply

You can use these tags in comments (Note: HTML is automatically escaped inside <pre> tags, nowhere else, so if you post source code, put it in <pre>):

<pre lang="some_programming_language"> 
<em>
<strong>
<a href="url">

NOTE: Comments are automatically spam-filtered. If your comment fails to appear, it was likely munched by the filter. Try not to link-spam or post anything that looks like it was typed by a robot.