Is there a way to insert the output of a vim command into a buffer?

What I want to do from time to time, inserts the output of the vim command into the buffer. For instance. when I edit vimrc, it would be nice to be able to mess around with statusline, and then be able to just do something similar to

"=set statusline?<Enter>p

The problem is what gives

E121: Undefined variable: set
E15: Invalid expression: set statusline?
Press ENTER or type command to continue

I believe that this is possible, and that I just don’t know enough about the built-in functions and how to use them (I see what is expandused here and there, but I never did it for me in any context), although I (think that I) understand the normal mode pretty well.

Please note that this particular example is a little contrived, but right now I cannot come up with a better one. For the specific use case above, I could just ":pget the whole command setthat I used during the experiment and then edit as required, but quite regularly I come across other cases where I want vim to tell me something, and then I want to insert this conclusion somewhere so that I can continue to look at it, continuing my work.

+5
source share
2 answers

You can insert a parameter:

"=&statusline<Enter>p

However, I do not know how to place the output from an arbitrary command in the buffer.

+4
source

, &. , , statusline , &statusline. - "", <ctrl-R>=. , <ctrl-R>, =. , : &statusline, enter. .

+4

All Articles