Download and install Python.
Download Vim from the vim website.Self-installing executable.
Edit the vim configuration file _ vimrc
Copy the stuff in vimrc_example to _ vimrc
Remove source $ VIMRUNTIME/vimrc_example.vim from _ vimrc.
Set Chinese support
"Sets automatic encoding recognition and displays Chinese quotation marks
"Set fileencodings = UTF-8, cp936, big5, euc-jp, euc-kr, latin1, ucs-bom
Set fileencodings = UTF-8, gbk
Set ambiwidth = double
Set ColorScheme. I chose desert. You can see other Color Scheme in GVim's Edit --> Color Scheme.
"ColorScheme
colorscheme desert
Set tab insertion space, indentation, deletion key deletion indent, page text width
"Allow the return key deletion and tab operations
Set smartindent
Set smarttab
Set expandtab
Set tabstop = 4
Set softtabstop = 4
Set shiftwidth = 4
Set backspace = 2
Set textwidth = 79
Enable mouse and line number
"Enable mouse
Set mouse =
"Enable row number
Set nu
After completing the preceding steps, use GVim to open the Python code.
Enable the code complementing function of omni-completion. The components of this series are installed with Vim. By the way, I have added support for Ruby and other languages. Press Ctrl-X and Ctrl-O to complete the code.
Modify _ vimrc as follows:
Code
"Auto-completion
Filetype plugin indent on
Set completeopt = longest, menu
"Use the menu-style match list when the auto-completion command is executed.
Set wildmenu
Autocmd FileType ruby, eruby set omnifunc = rubycomplete # Complete
Autocmd FileType python set omnifunc = pythoncomplete # Complete
Autocmd FileType javascript set omnifunc = javascriptcomplete # CompleteJS
Autocmd FileType html set omnifunc = htmlcomplete # CompleteTags
Autocmd FileType css set omnifunc = csscomplete # CompleteCSS
Autocmd FileType xml set omnifunc = xmlcomplete # CompleteTags
Autocmd FileType java set omnifunc = javacomplete # Complet
Omni-completion implements Code completion
Omni-completion can implement partial code complementing functions, but it is not very complete. Therefore, we enable pydiction, provide richer code complementing functions, and press tab to complete the code.
Download pydiction and decompress the package. Copy python_pydiction.vim and complete-dict to the ftplugin directory and modify _ vimrc.
"Pydiction
let g:pydiction_location = 'C:\Program Files\Vim\vim73\ftplugin\complete-dict
Now, you can press the Tab key to complete the code,
Next we need to analyze the source code tool Ctags, download the Ctags For windows website from the website, decompress the file, and then upload the ctags.exe to a certain place to ensure that the windows path contains this directory.
Open the source code file and click the buildtags button on GVim. Or manually execute the ctags-R command in the source code directory on the console. We can find that the tags file is generated in the current directory. This is what we need. We can press Crtl +] on the method, and Vim will help you find the method definition.
Next we need to use this file to view the source code. We need another plug-in TagList, which can be used with Ctags to efficiently view the source code. Download the TagList and decompress it to the doc and plugin directories and copy these two directories to your Vim installation directory (my path is C: \ Program Files \ Vim \ vim73 ), overwrite the original directory (do not worry that overwriting will not affect existing items). Modify _ vimrc as follows:
"TagList
let Tlist_Show_One_File=1
let Tlist_Exit_OnlyWindow=1
We need to create the tags directory for Vim and execute the command in Vim: set tags = path of your code \ tags, if you keep using the same code path, you can write it to _ vimrc. For example
D: \ VimTest configuration is as follows:
"tags
set tags=D:\VimTest\tags
Then execute Tlist in Vim to open the TagList window. For example, in the left window, click the method. You can see that the cursor on the right will automatically jump to the method you clicked.
Next we will add the file browsing function. Download WinManager, compress it, and put it in the plugin directory. The configuration below shows both FileExplorer and TagList
"WinManager
let g:winManagerWindowLayout='FileExplorer|TagList'
nmap wm :WMToggle<cr>
Enter the wm command below to see that the upper left is FileExplorer and the lower left is TagList.
Enable cssag for more advanced source code analysis and support Reverse Lookup
Download the available version of fuse in windows.
Download cscope_maps.vim and put it in the Vim plugin directory.
Modify _ vimrc to display the search result in the quickfix window instead of the main window.
"cscope show in quickfix
set cscopequickfix=s-,c-,d-,i-,t-,e-
Now, the configuration is complete. Let's see how to use it. Enter: help if_cscop.txt in vim to view the help for Cscope.
After reading the document, we can enter the command cs find c foo in vim to find out where the foo method has been called.
Cscope_maps.vim maps some keyboard shortcuts, so we can use the search function quickly.
I prefer to use Ctrl + \ to move the cursor over the content you want to search for. Then, enter Ctrl + \ and enter c quickly to view the search result in the quickfix form. If there are multiple results, you can enter the command: cw to expand the quickfix form. (This quick operation may be awkward for the first time. Just try it several times)
Below is a result of my search
Enable MiniBufExplorer and manage the vim buffer (buffer zone) to quickly switch between multiple files simultaneously edited.
Edit _ vimrc as follows:
"MiniBufExplorer
let g:miniBufExplMapWindowNavVim = 1
let g:miniBufExplMapWindowNavArrows = 1
let g:miniBufExplMapCTabSwitchBufs = 1
let g:miniBufExplModSelTarget = 1
After configuration, the MiniBufExplorer window appears. Click the file name above to quickly switch between different files.
Enable Grep and find in Project
Grep is a command in linux. If you are not familiar with Grep, you can read the Grep documentation.
Download and install Grep for windows
Download the Vim Grep plug-in. Place grep. vim In the plugin directory.
Configure _ vimrc and set F3 as the shortcut key
"Grep
nnoremap <silent> <F3> :Grep<CR>
Place the cursor on the content you want to Search. Press F3 to see Search for pattern: xxx. Press enter to Display Search in files and enter *. py, only find the python source code file, press enter to view the search results. See
Enable VimPdb to debug Python programs.
Download VimPdb, decompress it, copy VimPdb. py, and VimPdb. vim to plugin.
Run the python code file with vim, press F5, and then press F2 to set the breakpoint. After the breakpoint is run, press F12 to view the Stack Trace and F3 to view the variables and parameter values.
For more advanced usage, see the documentation.
Enable ropevim to refactor the Python Program
Download rope, ropemode, and ropevim, decompress them, open the console, cd to the decompressed directory, and execute python setup. py install.
Then copy the ropevim. vim file to the plugin directory. In this way, the installation is complete. Try refactoring a class name, place the cursor on the class name, press Ctrl-c, and then press r twice.
You can see that the quickfix form requires you to enter New name:, enter a New name, and press Enter. The reconstruction is complete. For example
Python code check
Create a python directory under the ftplugin directory of Vim.
Download pyflakes, decompress the package, and copy the pyflakes. vim file and the pyflakes directory to the ftplugin \ python directory.
Open a problematic python source code file and execute the command: cc to check the Code. For example, two errors are found.
Now I have finished writing it. I am so tired. I finally put a big picture to show the overall effect.
Reference:
How to convert Vim into an IDE programming environment)
VIM as Python IDE
There are many references. I will not list them one by one.