Skip to main content
1 of 2
MaxGyver
  • 231
  • 1
  • 8

Start vim with ex-command and append it to vim's command history

When I start vim with an ex-command as command line parameter, it won't show up in vim's command history. Why? Can I tell vim to do so?

Minimal example:

vim -c 'execute "help -c"'

Why I'm asking:

After grepping in the command line, sometimes I want to open the results in vim. That's why I made a script that opens vim with the last ripgrep search as parameter, for example:

nvim -c 'execute "RgRaw failed --glob !lib"'

After closing the search (inside vim), I would like to simply repeat (and maybe adapt) this search via :up.

  • This specific workflow needs ripgrep, fzf, fzf.vim, vim-agriculture to be installed.
  • I use nvim here, because vim (8.2.628) shows a warning (twice): "E994: Not allowed in a popup window"
MaxGyver
  • 231
  • 1
  • 8