Skip to main content
2 of 2
tags edited, thanks removed as per https://meta.stackexchange.com/q/2950/295232

Place a string onto the command line without execution

Suppose I have a variable

let g:f_themes="./themes/**"

Suppose I want to map this command to a key:

:execute "vimgrep /".expand("<cword>")."/g ".g:f_themes." | copen"

That works, even though it may complain about not finding <cword>. I can deal with that.

But what if I want to instead place that string onto the command line and NOT execute it, which allows me to inspect and edit the command before hitting <cr>. I can't use :execute because it will go ahead and execute. And I can't get the value of g:f_themes to expand to ./themes/** if I just type the command without the :execute.

Is there a way to place a string onto the command line so that a simple <cr> would go ahead and execute the line?

BSM
  • 21
  • 1