Save and run at the same time in Vim

前端 未结 12 541
悲哀的现实
悲哀的现实 2021-01-30 03:13

I do a lot of Python quick simulation stuff and I\'m constantly saving (:w) and then running (:!!). Is there a way to combine these actions?

Maybe a "save and run&qu

12条回答
  •  南方客
    南方客 (楼主)
    2021-01-30 03:56

    Try making it inside the Bash.

    In case of a C file called t.c, this is very convenient:

    vi t.c &&  cc t.c -o t && ./t
    

    The and symbols (&&) ensure that one error message breaks the command chain.

    For Python this might be even easier:

    vi t.py && python t.py
    

提交回复
热议问题