0

I'm trying to do i<Ctrl-R>=expandcmd('se shm') and more generally i<Ctrl-R>=expandcmd({expr}) but I'm just getting the literal {expr} inserted.

When I type :se shm<CR> I get the value of the option printed on the command-line. I'd like that inserted into my buffer.

1
  • 1
    It might help to explain what you're trying to achieve in the first place by using expandcmd(
    – Mass
    Commented Oct 15, 2019 at 23:39

1 Answer 1

0

expandcmd() expands wildcards, environment variables and such. It is not intended for VimScript execution.

In general, you can use execute() function to run VimScript interpreter and get the ouput as a string. But in this case it's enough to use &-notation (see :h expr-option):

i<C-R>=&shm

Your Answer

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

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