Configure vim on Ubuntu 15.10 for Python development

Source: Internet
Author: User



1. To 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 automatic hint completion configuration (pydiction)



From the official download http://www.vim.org/scripts/script.php?script_id=850 The latest can, after decompression, into the extracted directory, 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

 

 Explain:
The first line is to copy the downloaded file to/usr/share/vim/vim74/ftplugin The second line is to create a folder under the/usr/share/vim/vim74/directory Pydiction
The third line replicates complete-dict pydiction.py these two files to
Line four opens the. VIMC configuration file

and copy the following three lines of code into it.
Then save it, it should be. After you click ESC, do: Wq, save
 
let g:pydiction_location = ‘/usr/share/vim/vim74/pydiction/complete-dict‘ 
let g:pydiction_menu_height = 20
autocmd FileType python set omnifunc=pythoncomplete#Complete
2> installing Python_fold Auto-folding plug-in
From the official download http://www.vim.org/scripts/script.php?script_id=515 The latest plugin, unzip, into the extracted directory, execute the following command
 
# cp python_fold.vim  /usr/share/vim/vim74/plugin/
# vi ~/.vimrc
 
Explain: The first line is to copy the downloaded file to/usr/share/vim/vim74/plugin The second line  opens the. VIMC configuration file and copy the following line of code into it. 
Set Foldmethod=indent

3> Installing the auto-highlight plugin
Downloaded from the official:http://www.vim.org/scripts/script.php?script_id=790, download the latest plugin, unzip, enter the extracted directory, 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

Explain: The first line is to back up the Python.vim The second line replicates Python.vim to the /usr/share/vim/vim74/syntax directory Generate Ctag Sequence


Go to the directory where the Python program script (project) is located and execute in that directory:

Ctags-r *

If you are prompted not to install Ctags, perform apt-get install Ctags.



generates a ctags file that records analysis sequence records for a program/project's functions, classes, and so on. For detailed usage of Ctag please read Ctag's manpage.



5> Installing the taglist plugin



From the official download plug-in:http://www.vim.org/scripts/script.php?script_id=273 , with the latest can , unzip, into the extracted directory, execute the following command.

# cp plugin/taglist.vim  /usr/share/vim/vim74/plugin/
# cp doc/taglist.txt  /usr/share/vim/vim74/doc/
# vi








                    Execute the following command     
 
:helptags  /usr/share/vim/vim74/doc    
:help  taglist.txt 

First line Second line  view TagList Help information Configure VIMRC, vi ~/.VIMRC, add the following code after 
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  

Explain:



The first line does not display the tag of multiple files at the same time, only the current file is displayed.
Second line if the TagList window is the last window, exit vim.
The third line displays the TagList window in the right window.
The line four automatically opens the TagList window after Vim is started.
The five lines only show the current file tag, the other file's tag folding.


 The final configuration results are as follows : The contents of the configuration file are as follows: required to be replicable. 
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
set autoindent
set foldmethod=indent
let Tlist_Auto_Highlight_Tag=1
let Tlist_Auto_Open=1
let Tlist_Auto_Update=1
let Tlist_Display_Tag_Scope=1
let Tlist_Exit_OnlyWindow=1
let Tlist_Enable_Dold_Column=1
let Tlist_File_Fold_Auto_Close=1
let Tlist_Show_One_File=1
let Tlist_Use_Right_Window=1
let Tlist_Use_SingleClick=1
nnoremap <silent> <F8> :TlistToggle<CR>
filetype plugin on
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascrīpt 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 php set omnifunc=phpcomplete#CompletePHP
autocmd FileType c set omnifunc=ccomplete#Complete
autocmd FileType python set omnifunc=pythoncomplete#Complete
let g:pydiction_location = ‘/usr/share/vim/vim74/pydiction/complete-dict‘
let g:pydiction_menu_height = 20
set foldmethod=indent


After configuration, the file editing results are as follows:








Note: This article refers to the blog of some netizens. 


Configure vim on Ubuntu 15.10 for Python development


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.