Reputation: 41
I would like to create an individual vim command that does the following:
Currently I have to do it like this:
:w
:! python3 {filename}
Instead, I would like to do this:
:pyRun
or something similar
Upvotes: 2
Views: 356
Reputation: 4589
You can chain commands with |
. So
:w | ! python3 %
will save the buffer and run it with python3.
See :help :bar
and :help c_%
for more information.
You can create a command for this like:
:command PyRun execute 'w <bar> ! python3 %'
Note that custom commands in vim have to start with an uppercase letter.
Upvotes: 1