天天看点

vim配置python开发环境_centos6.8 vim+python 开发环境配置

此操作来自以下链接学来

配置vim+python开发环境

https://realpython.com/blog/python/vim-and-python-a-match-made-in-heaven/

解决上文中py文件格式配置报错

http://stackoverflow.com/questions/11087041/gvim-to-custom-highlight-group-in-vimrc-not-working

系统环境[[email protected] ~]$ cat /etc/redhat-release

CentOS release 6.8 (Final)

[[email protected] ~]$ uname -a

Linux localhost.jiel 2.6.32-642.el6.x86_64 #1 SMP Tue May 10 17:27:01 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

vim环境[[email protected] ~]$ vim --version

输出中一定要有+python 选项

开始安装

安装基本环境信息

安装epel仓库[[email protected] ~]$ sudo yum install epel-release

安装基本软件[[email protected] ~]$ sudo yum install vim python python34 python-devel python34-devel git curl wget

安装python-pip[[email protected] ~]$ curl -O https://bootstrap.pypa.io/get-pip.py

[[email protected] ~]$ sudo python get-pip.py

下载vundle[[email protected] ~]$ git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim

创建配置文件[[email protected] ~]$ touch ~/.vimrc

[[email protected] ~]$ vim .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

进入vim执行

:PluginInstall

完成后 基本设置就成功了

先开始安装最大的一个插件

这是一个用于代码补全的重要性也是杠杠的链接Bundle 'Valloric/YouCompleteMe'

把这个填入.vimrc里面

vim配置python开发环境_centos6.8 vim+python 开发环境配置

再次执行:PluginInstall

vim配置python开发环境_centos6.8 vim+python 开发环境配置

进行一些设置避免补全窗口出问题

避免窗口丢失let g:ycm_python_binary_path = 'python'

let g:ycm_autoclose_preview_window_after_completion=1

map g :YcmCompleter GoToDefinitionElseDeclaration

设置显示行号

set nu

设置编码

set encoding=utf8

现在设置分屏

set splitbelow

set splitright

映射分屏快捷键

"split navigations

nnoremap

nnoremap

nnoremap

nnoremap

启用折叠

set foldmethod=indent

set foldlevel=99

映射空格键折叠

nnoremap za

自带折叠有时候很头疼安装一个折叠插件

Plugin 'tmhedberg/SimpylFold'

设置显示折叠行字符串

let g:SimpylFold_docstring_preview=1

设置py代码格式PEP8

原文这里后面没有|会报错

au BufNewFile,BufRead *.py

\ set tabstop=4|

\ set softtabstop=4|

\ set shiftwidth=4|

\ set textwidth=79|

\ set expandtab|

\ set autoindent|

\ set fileformat=unix

安装一个自动缩进插件链接

Plugin 'vim-scripts/indentpython.vim'

标记多余的空格

原文这里也是少了一行声明highlight

highlight BadWhitespace ctermbg=red guibg=darkred

au BufRead,BufNewFile *.py,*.pyw,*.c,*.h match BadWhitespace /\s\+$/

设置C-n 打开目录树

map :NERDTreeToggle

添加一个语法高亮插件链接

Plugin 'scrooloose/syntastic'

添加一个目录树插件链接

Plugin 'scrooloose/nerdtree'

添加一个C-P搜索插件链接

Plugin 'kien/ctrlp.vim'

添加一个git集成链接

Plugin 'tpope/vim-fugitive'

添加一个状态栏插件链接

Plugin 'Lokaltog/powerline', {'rtp': 'powerline/bindings/vim/'}

最后执行安装

:PluginInstall

完成后就可以开始痛苦的适应之路了

vim配置python开发环境_centos6.8 vim+python 开发环境配置