Welcome to Vifm Q&A, where you can ask questions about using Vifm. Registration is optional, anonymous posts are moderated. E-mail and GitHub logins are enabled.
0 votes
ago in vifm by
edited ago by

This command works as expected:

command! vimgrep !vim "+silent grep %a"

I'm trying to replace %a with %c in a mapping. How can I make this mapping work?

nnoremap <wait> <help> ,v :execute "!vim '+silent grep %c' >/dev/null 2>&1"<CR>

Greetings

1 Answer

0 votes
ago by

This works in my tests:

:nnoremap <wait> <help> ,v :execute "!vim '+silent grep '%c' *' 2>&1"<CR>

Changes:

  • because %c is escaped, put it outside of single quotes
  • removed >/dev/null as that prevents Vim from using the terminal
  • added * because Vim's :grep needs at least two parameters
...