本身要學習python,周圍不少人用pycharm,可是本身喜歡linux界面。因此安裝了vim的pyton插件來解決這個問題,如下是步驟,本人親測,能夠。從附件中下載masterpython
vim版本推薦7.3以上的,若是不是,請升級,另外還須要保證的是支持+python
linux
[root@python love]# vim --version
[root@python love]# yum -y update vim [root@python love]# vim --version
安裝git,方便下載vim擴展管理器:Vundle,而且將配置文件建立好
git
[root@python love]# yum -y install git [root@python love]# git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim [root@python love]# vim /root/.vimrc
set nocompatible " required filetype off " required " set the runtime path to include Vundle and initialize set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() " alternatively, pass a path where Vundle should install plugins "call vundle#begin('~/some/path/here') " let Vundle manage Vundle, required Plugin 'gmarik/Vundle.vim' " Add all your plugins here (note older versions of Vundle used Bundle instead of Plugin) " All of your Plugins must be added before the following line call vundle#end() " required filetype plugin indent on " required
執行安裝命令github
以下顯示則安裝成功
vim
添加如下代碼能夠實現切換分割佈局bash
set splitbelow set splitright "split navigations nnoremap <C-J> <C-W><C-J> nnoremap <C-K> <C-W><C-K> nnoremap <C-L> <C-W><C-L> nnoremap <C-H> <C-W><C-H>
添加如下代碼實現PEP8風格的縮進,一個tab鍵是4個空格ide
au BufNewFile,BufRead *.py \ set tabstop=4 | \ set softtabstop=4 | \ set shiftwidth=4 | \ set textwidth=79 | \ set expandtab | \ set autoindent | \ set fileformat=unix |
自動縮進有用,可是在某些狀況下(好比函數定義有多行的時候),並無很好的效果,這時咱們能夠利用indentpython.vim插件,來解決這個問題,固然也須要從新安裝一下
函數
Plugin 'vim-scripts/indentpython.vim'
咱們但願避免出現多餘的空白字符。可讓Vim幫咱們標示出來,使其很容易發現並刪除佈局
hi BadWhitespace guifg=gray guibg=red ctermfg=gray ctermbg=red au BufRead,BufNewFile *.py,*.pyw,*.c,*.h match BadWhitespace /\s\+$/
支持utf-8編碼學習
set encoding=utf-8
支持python自動補全,固然須要使用PluginInstall命令進行安裝
Bundle 'Valloric/YouCompleteMe'
[root@python ~]# unzip -q master
[root@python ~]# mkdir -p ~/.vim/tools/pydiction
[root@python ~]# cp -r pydiction-master/after/ ~/.vim
[root@python ~]# cp pydiction-master/complete-dict ~/.vim/tools/pydiction/
[root@python ~]# vim ~/.vimrc
filetype plugin onlet g:pydiction_location = '~/.vim/tools/pydiction/complete-dict'