What are the best practices for writing Python with Vim?

Source: Internet
Author: User
Whether you need to automatically prompt, complement the same function, how to add these features. My own eclipse write Java more, thank you!

Reply content:

Vim 3 years, itself is a Python backend development
Link is my configuration, GitHub, support one-click Installation

https:// Github.com/wklken/k-vim The real cool part of VIM is not the code-completion hints feature (I don't know if there are any hints, but there are a lot of complements), but it's quick to locate and quickly format the code you want.

I mainly configure some plugins and settings on the format. Compilation and debugging have not been done yet. All of the following are the Linux system settings, win under some places different.

The first thing to do is to format python in VIMRC (this is the simplest setting I have now):
"Show rows, set soft return and indent and syntax
Set number
Set Expandtab
Set Tabstop=8
Set shiftwidth=4
Set softtabstop=4
Set Autoindent
: Syntax on
"Complete settings, not set can also be used
Let tlist_ctags_cmd= '/usr/bin/ctags '
FileType plugin indent on
FileType plugin on
Set Ofu=syntaxcomplete#complete
"This is what I like, once a line of characters exceeds 80, the background of those characters is set to red
Highlight Overlength ctermbg=red ctermfg=white guibg= #592929
Match Overlength/\%81v.\+/

Some of the remaining plugins I have installed:
VCS (version control, support GIT,SVN,HG, etc.)
Tabular (very handy typesetting tool)

The rest is a few tricks, only slowly practice can
Lazy Copy the answer I have on the person:
/ http ZHEYE.ORG/ASKS/4DC62CBB fd503c368f00000e

    • Press ^[or ^c without pressing ESC, much faster
    • Learn the difference between several key positions: 0, $, {,}, G, G, W, E, b ...
    • O, o insert a new row below/above the current position and into the insert State
    • Shift+v select several lines and then move them together
    • CTRL + V selects characters at the beginning or end of a line, then inserts with Shift+i, or shift+x deletes
    • Learn to use Y,d and P, p to do the paste cut
    • Learn to operate with ^w windows. Open file with SP or VS
    • Learn to record macro commands. Use Q plus any key to start recording, and then press Q to save. You can then use the @ Plus this any key to play back, before @ plus a number to define the number of playback times.
    • "." Repeat the last command, "U" cancels the previous command, "^r" anti-Cancel
    • ^n, ^p with buf in the key words complement.
    • Learn to replace ":%s/to search for things/Things to change/g"
    • Any time you move to a word, press # to highlight all the same words in this document
    • Use "/" to search, press N or n prev/Next
    • ":!" Command & "can run this command directly, with":! Command%& "If you want this command to operate on the currently edited file.
    • Any time available ": cd%:p: H" To switch directories to the directory where the current edit file is located.


The rest I would like to add that a lot of people might ignore: Jedi-vim
setfoldmethod=indentsetfoldlevel=99 " press space to fold/unfold codennoremap<space> zavnoremap<space> zf
Update, I have given up the Spf13-vim, because the author is currently on the project with a shepherd attitude, uncontrolled merger pull request, no test, the master branch on the introduction of the bug, the bug introduced last April to now there is no sign of repair. Issues piled up dozens of pages.

This release is intended to save time, and the result is that I spend a lot of time fixing bugs, which is not worth the candle.
==================

With Spf13 Bar, I originally also saved 300 rows or so of the configuration.
Discover Spf13/spf13-vim GitHub After that, he took refuge in it completely. Originally I rarely use vim, I feel that the configuration is too troublesome.
After reading the question and its answer, I was inspired to spend 2 days learning how to optimize the configuration of vim. Wrote a little vim distribution. Basically meet the completion, hints, find files, check the wrong, git and other functions, the interface is very beautiful, Ubuntu support a command installation. Connecting to the school's VMs can finally get rid of the turtle speed xming.
Rarezhang/simple_vim_setting GitHub
Thanks to the answer of @ Li Jigang and @ Ma Weiwei, we learn a lot from these two answers.
Last picture.
Direct blank vim using John Anderson's configuration is all right.
Turning Vim into a modern Python IDE
Link:/httpsontek.net/turning-vim-into-a-modern-python-ide
Attached to my Vim screenshot: Recommended Spf13-vim, to upgrade your vim to vim7.4, if it is Mac can directly use Macvim. Then spf13 in the Youcompleteme plug-in will work, code hints, variable function jump not too convenient! Privately think that the Pycharm+ideavim plugin writes Python is the most comfortable

Pycharm powerful search and code jump used to be very comfortable, more than ctags use do not know how much. The other is a file explore, more comfortable than the nerd-tree of the bug.
Of course Ideavim is not perfect, such as can not support Sorround, easymotion and other vim plug-ins, this is a sad thing. I am a pythoner, is also a loyal user of vim, I think my configuration file write Python is very cool, code completion, error hints, smart indentation, one-click Typesetting, one-click execution, interested in the words can try, GitHub on the project is: Ma6174/vim GitHub , according to the Readme tutorial can be a named automatic installation configuration good
  • 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.