Save and run at the same time in Vim

前端 未结 12 768
悲哀的现实
悲哀的现实 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:49

    This will work in insert mode too:

    " F5 => Save & Run python3 "
    nnoremap  :w  :!sh -c 'python3 %' 
    inoremap   :w  :!sh -c 'python3 %' 
    

    I use it all the time to test stuff that is just too long to retype in the interpreter.

提交回复
热议问题