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" command.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Option 1:
Write a function similar to this and place it in your startup settings:
You could even map a key combination to it — look at the documentation.
Option 2 (better):
Look at the documentation for remapping keystrokes – you may be able to accomplish it through a simple key remap. The following works, but has "filename.py" hardcoded. Perhaps you can dig in and figure out how to replace that with the current file?
After mapping that, you can just press F2 in command mode.
imap, vmap, etc… are mappings in different modes. The above only applies to command mode. The following should work in insert mode also:
Section 40.1 of the Vim manual is very helpful.