记一次安装vim 的python插件

       本身要学习python,周围不少人用pycharm,可是本身喜欢linux界面。因此安装了vim的pyton插件来解决这个问题,如下是步骤,本人亲测,能够。从附件中下载masterpython

vim版本推荐7.3以上的,若是不是,请升级,另外还须要保证的是支持+python
linux

[root@python love]# vim --version

wKioL1gro9_ja8ffAAAZqyzhZgg399.png

[root@python love]# yum -y update vim
[root@python  love]#  vim --version

wKiom1grpDrx9aTnAAAYmTxdwZA890.png

wKiom1grpO3woK4BAAChldr6uwI748.png

安装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

wKiom1grr8TweKpSAAAFiZEo4VE433.png

以下显示则安装成功
vim

wKiom1grrYvRP5UQAAAZDua3ddU691.png

添加如下代码能够实现切换分割布局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'

相关文章
相关标签/搜索