With python2.7 on the CENTOS7, we need to optimize the Python environment.
First, using the watercress source to accelerate the software installation
Pip install-i flask #使用-i option mkdir ~./pip && vim pip.conf #修改pip的配置文件 [global]index-url = Https://pypi. douban.com/simple/
Ii.. Modify the. vimrc file
Mainly add some configuration options, such as displaying line numbers, one-click execution, etc.
VIM .VIMRC
set nocompatible "Turn off compatibility mode with VI set number " show line number set nowrap " Do not wrap lines set showmatch "Display matching parentheses set scrolloff=3 "set encoding=utf-8 " from top and bottom 3 lines "Code set fenc=utf-8 "encode set mouse=a " Enable mouse set hlsearch "Search highlighting syntax on " syntax highlighting Au bufnewfile, bufread *.py\ set tabstop=4 "tab Width \ set softtabstop=4 \ set shiftwidth=4 \ set textwidth=79 "Row Maximum width \ set expandtab "tab replaced by SPACEBAR \ set autoindent "Auto Indent \ set fileformat=unix " Save file format Set foldmethod=indentset foldlevel=99map <F8> :call runpython () <cr>func! runpython () exec "W" if &filetype == ' python ' exec "!time python2.7 %" endifendfunc
One-click F8 execution Effect
Third, configure VIM plug-in management Vundle
Vundle is the short name of the vim bundle, using Git to manage the Vim plugin, and with it, installing other plugins is a lot easier.
Create a Directory
CD ~mkdir. Vimcd. Vimmkdir Bundle
Go to directory, download files
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/vundle.vim
The following configuration is then placed at the beginning of the. vimrc file:
set nocompatible " be iMproved, requiredfiletype off " required " set the runtime path to include vundle and initializeset rtp+=~/.vim/bundle/vundle.vimcall vundle#begin () " let Vundle manage vundle, requiredplugin ' Vundlevim/vundle.vim ' All of your Plugins Must be added before the following linecall vundle#end () " requiredfiletype plugin indent on " required
If you want to download a plugin, such as an auto-indent Indentpython.vim plugin, you need to
Plugin ' Vim-scripts/indentpython.vim '
placed call Vundle#begin () and between Call Vundle#end (), save the configuration and execute it in vim
:P Lugininstall
Four, multi-window editing
Installation of common Python plugins
Programming Tips Plugin Jedi-vim
Pip install Jedigit clone--recursive https://github.com/davidhalter/jedi-vim.git ~/.vim/bundle/jedi-vim
2. Grammar check Syntastic
git clone https://github.com/vim-syntastic/syntastic.gitPlugin ' vim-syntastic/syntastic ' #.vimrc added
3.FLAK8 code style check
Pip install Flake8https://github.com/nvie/vim-flake8.gitplugin ' Nvie/vim-flake8 ' #.vimrc added
Press F7 for inspection ·
4. Add a tree-shaped table of contents
git clone Plugin ' scrooloose/nerdtree ' #.vimrc add map <C-n>:nerdtreetoggle<cr> #.vimrc in Add Use CTRL + N shortcut keys
5. Indent Display Indentline
git clone https://github.com/Yggdroot/indentLinePlugin ' Yggdroot/indentline ' #vimrc中添加
6.VIM-AUTOPEP8 Automatic Formatting code
Pip install autopep8 git clone https://github.com/tell-k/vim-autopep8.git Plugin ' Tell-k/vim-autopep8 ' #vimrc中添加 Autocmd FileType python noremap <buffer> <F9>: Call AUTOPEP8 () <CR> #使用快捷键F9
7.auto-pairs Auto-complete brackets and quotation marks
git clone Plugin ' Jiangmiao/auto-pairs '
8.Ctrlp.vim Search File
Search for ctl+p in vim normal mode
Plugin ' Kien/ctrlp.vim '
Finally, the entire configuration file. VIMRC is as follows:
set nocompatible " be iMproved, requiredfiletype off " required " set the runtime path to include vundle and initializeset rtp+=~/.vim/bundle/vundle.vimcall vundle#begin () " let Vundle manage Vundle, requiredPlugin vundlevim/" Vundle.vim ' plugin ' davidhalter/jedi-vim ' plugin ' vim-syntastic/syntastic ' Plugin ' nvie/ Vim-flake8 ' plugin ' scrooloose/nerdtree ' plugin ' yggdroot/indentline ' plugin ' tell-k/ Vim-autopep8 ' plugin ' vim-scripts/indentpython.vim ' plugin ' kien/ctrlp.vim ' Plugin ' jiangmiao/ Auto-pairs ' " All of your Plugins must be added before the Following linecall vundle#end () " requiredfiletype plugin indent on " requiredset nocompatible " Off compatibility mode with VI Set number "Show line number set nowrap " does not automatically wrap set showmatch "displays matching parentheses set scrolloff=3 "3 rows from top and bottom" set encoding=utf-8 "coded set fenc=utf-8 " encoding set mouse=a "Enable mouse set hlsearch " to search for highlighted syntax on "Syntax highlighting au bufnewfile,bufread *.py\ set tabstop=2 Tab Width \ set softtabstop=4 \ set shiftwidth=4 \ set textwidth=79 "Row max width \ set expandtab " tab replaced by SPACEBAR \ set autoindent "Auto Indent \ set fileformat=unix " Save file format set Foldmethod=indentset foldlevel=50map <f8> :call runpython () <CR>func! Runpython () exec "W" if &filetype == ' Python ' exec !time python2.7 % ' endifendfuncmap <c-n> :nerdtreetoggle<cr>autocmd filetype python &NBSP;NOREMAP&NBSP;<BUFFER>&NBSP;<F9>&NBSP;:CALL&NBSP;AUTOPEP8 () <CR>
Python Learning-vim Plugin Installation