I would like to have the following behavior for a key in vim (for example the F8 key):
Find the most recent ex command starting with :! and repeat it.
For example, if my command history is
(...)
:!python abc.py
/hi
:%s/hi/ho/g
:w
then by pressing F8 I would like vim to run :!python abc.py
:!! repeats the last :!{cmd}. You can map it to F8 like so:
:nnoremap <F8> :!!<CR>
You could try the following mapping:
nnoremap <F8> q:?^!<CR><CR>
Explanation:
q: - open the command-line window?^! - search for a line starting with !<CR><CR> - hit enter twice to execute that commandIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With