Creating a Python fast development environment with VIM (i)

Source: Internet
Author: User

Bloggers have always been using the spring version of Vim to masturbate Python, VIMRC only some color, keys, tab settings and other small functions. In the middle also by Amway over some tall IDE, tried JetBrains pycharm CE, Wing IDE and Eclipse+pydev, feel these software such as code Navigation,refactor, Documentation These features are really powerful, but the IDE's working mode is always what I don't like: You can start working quickly, not having to go through a few seconds (or even several minutes if the company's PC) to open the software, create a new project, choose Interpreter, Take a name, choose a directory, add a file ... After this series of actions, what I thought at first was completely forgotten. One of the reasons we use Python is that life is short. I use Python to quickly grab inspiration and get started modeling at once. It is possible for a small script to solve a problem that requires Python's daily handling, and the best tool for this situation is the text editor. Only when the problem is solved, the inspiration is captured, and the prototype is built up, we find that it needs to be perfected, or it can be modified to enhance versatility, or it needs to be published to someone else to use the IDE. So, in the blogger's view, like Vim, with basic to high-level code editing functions, you can quickly open the first-written program and then save the text editor is the first time to get into the area of the need to deal with the problem of the perfect tool.

All right, the spit is over. This article will assume that you are similar to me, is an experienced vim user, can skillfully use C-w, C-v, M, Q and other higher-order features, but rarely toss configuration (so this blog can also have some value for you). In this case, you may find that when the Python file is larger than 500 lines, the import module is more than 10 and some are not very familiar, the work that is promoted with VIM will be continuously checked for documentation. And you, like me, feel that the IDE is overkill with the source code less than 5000 lines, so it's very upsetting to find the right tool for 500 to 5000 rows. In that case, just start tossing with me.

Compiling 64-bit's Vim

First of all, since some of the Vim plugins use Python (such as the python-mode we're going to use), our vim must support Python. If you've always downloaded vim from the download page of the VIM website like me, this official version has been shipped with Python support, but this vim is 32-bit. Use the: Version command to see the versions of Vim and the compilation options, such as.

Use the command: Echo has (' Python ') to see if it works. Unfortunately, for a variety of reasons, the blogger used Anaconda's 64-bit kit, the input command: Echo has (' python ') shows 0. The VIM website does not provide compiled 64-bit VIM installation files, only mentioned if 64-bit support to use alternative distribution, and the official website of the 64 third-party release version of the page has affirmed the Stop maintenance (Khan), and brought the blogger here. It seems that these third-party releases are nothing more than an integrated patch, so why don't we compile a version that works best for you?

Then the blogger found this article on Mr. Yun Liangzan's blog, experimented with it, and found that compiling vim was actually very simple.

Working environment

We need patch,c compilers, resource compilers, make and a full suite of tools, as well as a shell, where bloggers are using MSYS64, the new MinGW and Msys 64-bit version. (For MSYS64 installation and configuration, bloggers will have time to explain later.) )

Download vim source code and patches

First of all to download vim source code and patches, in view of the domestic network with VIM website FTP is simply very slow to heinous, we still use Zhong ke vim image (by the way praised Zhong Ke, beiligong and other universities and institutions, they are really the cornerstone of the domestic open source business Ah! )

mkdir ~/makevimcd ~/makevimwget-c http://mirrors.ustc.edu.cn/vim/pc/vim74src.zipwget-c http://mirrors.ustc.edu.cn/ Vim/pc/vim74rt.zipunzip vim74src.zipunzip Vim74rt.zipmkdir Patches HTTPS://MIRRORS.USTC.EDU.CN/VIM/PATCHES/7.4/CD Patcheswget-c-r-np-nd-e robots=off CD. Tar cvf Patches.tar patches/

Packaging patches actually doesn't make sense, it is in case of a mistake good spare, because download 778 patch file really a little trouble (laughter).

Patching source Code

The next step is to put these 778 patches into the source code, make sure that CWD is ~/makevim/vim/vim74, and then use the following command.

CD vim/vim74for file in.. /.. /patches/*; Do patch-f-s-np0-i $file; Done

Since we have downloaded all the patch files, it contains patches for other systems (such as OS/2, etc.), if only

Patch-np0-i <patch_file>

, the middle patch will ask us to skip the frequently asked questions because there are no files to find. So the-f-s option is added here to save time on the keyboard.

Start compiling

After the patch is ready, you can start compiling. Use the Make command below. Bloggers don't use Ruby, Perl, or LUA (not on the computer, they don't know what's missing, it's easy to compile again anyway) Python is only 2.7, so there's no support for these languages (it can be easily added if you need to).

Make-f Make_cyg_ming.mak cc=x86_64-w64-mingw32-gcc rc=windres arch=x86-64 Python=/c/users/nicholasyf/anaconda PYTHON _ver=27 dynamic_python=yes-j5 gui=yes static_stdcplus=yes ole=yes features=huge Username=nicholasyfzhou USERDOMAIN= Msys64

Compile speed is also fast, good after we get gvim.exe and other documents, even if completed. Because the Python directory is already specified in the Compile option, this time with the: Version command we can see:


Have you seen included patches:1-778? The first step is about to be accomplished!

If you need command line VIM.exe, you can also change the compiler switch gui=no, and make a bit. If you are integrating to a Windows system, move several files first:

MV *.exe. MV Gvimext/gvim.dll.

Running ~/vim/vim74/install.exe as an administrator, selecting D,install.exe will set up a shortcut in the desktop and Start menu, create a batch file in the Windows directory, and integrate "Edit with Vim" into the right-click menu.


Creating a Python fast development environment with VIM (i)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.