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
    It might help to explain what you're trying to achieve in the first place by using expandcmd( – Mass Oct 15 '19 at 23:39
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
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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