The Vim plug-in technology is introduced in VIM (4). This section uses these technologies to create a python IDE.
1. Grammar highlighting
To support Python syntax in Vim, plug-in python is required. VIM: this plug-in is located under <Vim installation directory>/<$ vimruntime>/syntax/by default. If you do not find this plug-in this path, you need to go to Python. VIM: enhanced version of the python syntax highlighting script download. To enable Vim to recognize the python syntax, add the following in vimrc:
Set filetype=Python
AU bufnewfile, bufread*. Py,*. Pyw SETF Python
2. indent
Add the following indentations to vimrc:Code:
Set autoindent"Same level indent
Set smartindent"Next level indent
Set expandtab
Set tabstop=4
Set shiftwidth=4
Set softtabstop=4
3. Project View
IDE like Visual Studio or eclipse provides a project view (on the left or right ),ProgramThe member uses this view to jump between files or classes. You can use ctags and the plug-in tasklist to implement this function in Vim.
- First download exuberant ctags
- Decompress ctags and enter the decompressed directory. Use the following command to compile and install ctags:
./Configure&&Sudo make install
- In this way, ctags are installed under/usr/local/bin. Next, add the following command in vimrc to tell the installation path of VIM ctags:
Let tlist_ctags_cmd='/Usr/local/bin/ctags'
- Install the tasklist plug-in: Download tasklist. vim and put it in the plugin directory.
- Finally, use the command tlisttoggle to open the taglist window, which is displayed.
4. minibufexplorer
In Visual Studio or eclipse, the cache you open is listed at the top or bottom of the window in the form of a tab. In vim, The minibufexplorer plug-in is used to implement this function. Download
Minibufexpl. vim and put it in the plugin directory. Add the following command to vimrc:
Let G: minibufexplmapwindownavvim= 1
Let G: minibufexplmapwindownavarrows= 1
Let G: minibufexplmapctabswitchbufs= 1
Let G: minibufexplmodseltarget= 1
Demonstrate the usage of minibufexplorer:
5. omnicompletion
Support for syntax prompts and Automatic completion is added to vim7. For python, You need to download pythoncomplete. run Vim in the <Vim installation directory>/<$ vimruntime>/autoload/directory, and then add the following command to vimrc:
Filetype plugin on
Set Ofu=Syntaxcomplete#Complete
Autocmd filetype Python set
Omnifunc=Pythoncomplete#Complete
Autocmd filetype Python runtime! Autoload/Pythoncomplete. Vim
Finally, press Ctrl-x Ctrl-O to open the context menu of the syntax prompt, as shown in:
References
1. http://www.swaroopch.com/notes/Vim
2. http://blog.dispatched.ch/2009/05/24/vim-as-python-ide/
3. http://www.phacks.net/macvim-code-completion-syntax-highlighting-for-python-pyqt4-twisted-on-mac-osx-snow-leopard/
4. http://vim.wikia.com/wiki/Omni_completion