Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
181 views
in Technique[技术] by (71.8m points)

How to SIMPLY configure VIM for Python?

Note: A previous question was closed because it needed to be more "focused", so I deleted the old one and modified the question so it only focus on VIM for Python.

I want to start using VIM but I′m having a hard time configuring it.

First, I did :syntax on to add some color to the syntax. Then, I wanted to change the version of Python that VIM is "verifying" as default (version 2+) to the recent version (3+) and did (something I found online) :let g:syntastic_python_python_exec = 'python3'. After I did this, the :syntax on stopped working (no more syntax highlighting) and VIM still didn′t support python3. What I mean is that if I write in Python3 I get error because it doesn't recognize version 3+

I′m using VIM (version 8+) from Terminal on Mac High Sierra.

Question:

  1. How can I configure VIM to work with Python ? - to work with recent version of Python(3+), have syntax highlight ON and have a "file tree".

Please, answer as simply as possible so anyone who is new to VIM can understand. I searched a lot and the answers I found were old and confusing to understand for someone who is new to VIM and wants to start with it.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

For the file tree, I would suggest the NerdTree plugin.

As for your syntax checker not working, I suggest you first create a Python 3 virtual environment via Pipenv, then open your vim within that virtual environment. That might solve your problem. You should always be using a virtual environment in any case if you are writing Python code.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...