2

Is there a way to communicate with vim in python?

I mean, I am wring a small software using python, it has a facility of memo, so when I want to write some memo, the software should invoke vim. After editing, it will save the buffer of vim in some format.

Just like committing in git, git invokes an editor. So is there any module to do this?

1

2 Answers 2

3

Check my answer about invoking $EDITOR on the content of your choice: call up an EDITOR (vim) from a python script. That's how git and others do that: write an initial content up in temporary file, fire $EDITOR on it, wait for the process to exit and then read the new content, parsing it. To provide syntax colouring or other niceties, usually a 'contrib' package is provided and has nothing to do with the functionality of the program itself.

Sign up to request clarification or add additional context in comments.

Comments

3

Here's how git determines which editor to use. After that, you could just open a new process with the subprocess module.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.