This article describes how to configure vim on ubuntu15.10 in Python development. If you need more information, see
1. Install vim. you can install it using the apt-get tool that comes with ubuntu.
Apt-get install vim-gnome
2. After the installation is successful, configure
1> first, perform the configuration (pydiction) that automatically prompts completion)
Download http://www.vim.org/scripts/script.php from official? Script_id = 850 latest. After decompression, enter the decompressed directory and execute the following command:
# cp python_pydiction.vim /usr/share/vim/vim74/ftplugin# mkdir /usr/share/vim/vim74/pydiction# cp complete-dict pydiction.py /usr/share/vim/vim74/pydiction/# vi ~/.vimrc
Explanation:
The first line is to copy the downloaded file to/usr/share/vim/vim74/ftplugin.
The second line is to create the pydiction folder in the/usr/share/vim/vim74/directory.
Copy the complete-dict pydiction. py files
Line 4 open the. vimc configuration file
Copy the following three lines of code and save them.
Click Esc and run: wq to save
let g:pydiction_location = '/usr/share/vim/vim74/pydiction/complete-dict' let g:pydiction_menu_height = 20autocmd FileType python set omnifunc=pythoncomplete#Complete
2> install the python_fold auto collapse plug-in to download the http://www.vim.org/scripts/script.php from official? Script_id = 515 latest plug-in. After decompression, enter the decompressed directory and execute the following command
# cp python_fold.vim /usr/share/vim/vim74/plugin/# vi ~/.vimrc
Explanation:
The first line is to copy the downloaded file to/usr/share/vim/vim74/plugin.
Line 2 open the. vimc configuration file
Then copy the following line of code to it.
Set foldmethod = indent
3> install auto-highlighted plug-in from the official download: http://www.vim.org/scripts/script.php? Script_id = 790, download the latest plug-in, decompress it, enter the decompressed directory, and execute the following command
mv /usr/share/vim/vim74/syntax/python.vim /usr/share/vim/vim74/syntax/python.vim_backup cp python.vim /usr/share/vim/vim74/syntax
Explanation:
The first line is to back up python. vim
Copy python. vim to the/usr/share/vim/vim74/syntax directory in the second line.
4> Generate the ctag Sequence
Go to the directory where the python program script (project) is located and execute:
Ctags-R *
If you are prompted that the ctags is not installed, run apt-get install ctags.
Generate a ctags file that records the analysis sequence records of functions and classes of programs/projects. For more information about ctag usage, see the manpage of ctag.
5> install the taglist plug-in
Download plug-in from official: http://www.vim.org/scripts/script.php? Script_id = 273. Use the latest one. After decompression, enter the decompressed directory and execute the following command.
# cp plugin/taglist.vim /usr/share/vim/vim74/plugin/# cp doc/taglist.txt /usr/share/vim/vim74/doc/# vi
Run the following command:
: Helptags/usr/share/vim/vim74/doc
: Help taglist.txt generate the taglist help file list in the first line. view the taglist help information in the second line. Configure vimrc, vi ~ /. Vimrc, add the following code
let Tlist_Show_One_File = 1 let Tlist_Exit_OnlyWindow = 1 let Tlist_Use_Right_Window = 1 let Tlist_Auto_Open=1 let Tlist_File_Fold_Auto_Close=1
Explanation:
The first line only displays the tags of the current file.
In the second line, if the taglist window is the last window, exit vim.
The third line shows the taglist window in the right window.
The fourth line automatically opens the taglist window after vim is started.
The fifth line only displays the tag of the current file, and the tag of other files is collapsed.
The final configuration result is as follows:
The configuration file content is as follows: the required file can be copied.
set tabstop=4set softtabstop=4set shiftwidth=4set expandtabset autoindentset foldmethod=indentlet Tlist_Auto_Highlight_Tag=1let Tlist_Auto_Open=1let Tlist_Auto_Update=1let Tlist_Display_Tag_Scope=1let Tlist_Exit_OnlyWindow=1let Tlist_Enable_Dold_Column=1let Tlist_File_Fold_Auto_Close=1let Tlist_Show_One_File=1let Tlist_Use_Right_Window=1let Tlist_Use_SingleClick=1nnoremap
:TlistToggle
filetype plugin onautocmd FileType python set omnifunc=pythoncomplete#Completeautocmd FileType javascrīpt set omnifunc=javascriptcomplete#CompleteJSautocmd FileType html set omnifunc=htmlcomplete#CompleteTagsautocmd FileType css set omnifunc=csscomplete#CompleteCSSautocmd FileType xml set omnifunc=xmlcomplete#CompleteTagsautocmd FileType php set omnifunc=phpcomplete#CompletePHPautocmd FileType c set omnifunc=ccomplete#Completeautocmd FileType python set omnifunc=pythoncomplete#Completelet g:pydiction_location = '/usr/share/vim/vim74/pydiction/complete-dict'let g:pydiction_menu_height = 20set foldmethod=indent
After configuration, the file editing result is as follows: