Every time I edit my python script, I have to type :w
and then :!./myscript.py
(run current script).
Can I combine those two commands together?
Write this in your .vimrc
:
function! SaveAndRun()
w
!%:p
endfunction
nmap <F2> :call SaveAndRun()<cr>
and it will execute the current file when you press f2 in normal mode.
Define a function in your .vimrc
and then define a command to invoke it.
function DoMyStuff()
:w
:!./myscript.py
endfunction
command W exec DoMyStuff()
Then, you can call it with :W
.
If I am interpret the title of your question literally, and you just want to execute the last executed command, you can use !!
in command mode to execute the last external command. Combined with the pipe, this looks like the following.
:w | !!
If 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