Posted on November 7, 2011 by Sam
This time has been in Python with the idle editor, but this idle code indentation really hurt, when you use the If:elif:, the Elif: not automatically aligned, which makes me often in the debugging time only to find the code indentation problems, So this time finally summon up the courage to change the idle to vim, but with vim there is a more disturbing problem, when you write a good code with VIM, you want to press F5 run to see the effect (many editors are F5 to run) under the vim of course is not possible.
Look, my requirements for the Python editor are simple.
1. Automatic indentation of code
2, code highlighting
3. Running and commissioning
Python's own idle code indentation is really a pit daddy, and Vim has no Python running debug
To make vim the Python editor we need to do some setup.
Open Vim installation directory edit _VIMRC file
1. Let vim display the line number of the code (idle does not display)
2. Set File encoding
Set fileencodings=tuf-8,ucd-bom,gb18030,gbk,gb2312,cp936 |
3, set indentation, (recommended to set 4 spaces as indentation)
Set tabstop=4 Set sts=4 Set Expandtab Set softtabstop=4 Set shiftwidth=4 Set Autoindent Set Cindent Set Cinoptions={0,1s,t0,n-2,p2s, (03s,=.5s,>1s,=1s,:1s |
4, modified under the font color, vim default white bottom black words really do not drop
5, the elimination of Vim automatic backup function (auto-generated ~ file is actually very not see)
Add a line below behave Mswin
6, I have just started to use vim to write Python code will often inadvertently press F5, so for vim configuration Python debugging is quite necessary.
Map <F5>:! D:\python32\python.exe% |
After adding a map, when we have finished writing the code, press ESC and then press the F5+enter to invoke Python to run the code.
Our configuration of vim is complete and you can use VIM to complete all of the idle functions.
Original: http://www.cnblogs.com/lexus/archive/2012/03/11/2390414.html
Reference: https://www.zhihu.com/question/20271508 (Know)
Vim Configuration python development environment