此操作来自以下链接学来
配置vim+python开发环境
https://realpython.com/blog/python/vim-and-python-a-match-made-in-heaven/
http://stackoverflow.com/questions/11087041/gvim-to-custom-highlight-group-in-vimrc-not-working
系统环境
[jiel@localhost~]$cat/etc/redhat-release CentOSrelease6.8(Final) [jiel@localhost~]$uname-a Linuxlocalhost.jiel2.6.32-642.el6.x86_64#1SMPTueMay1017:27:01UTC2016x86_64x86_64x86_64GNU/Linux
vim环境
[jiel@localhost~]$vim--version
输出中一定要有+python 选项
开始安装
安装基本环境信息
安装epel仓库
[jiel@localhost~]$sudoyuminstallepel-release
安装基本软件
[jiel@localhost~]$sudoyuminstallvimpythonpython34python-develpython34-develgitcurlwget
安装python-pip
[jiel@localhost~]$curl-Ohttps://bootstrap.pypa.io/get-pip.py [jiel@localhost~]$sudopythonget-pip.py
下载vundle
[jiel@localhost~]$gitclonehttps://github.com/gmarik/Vundle.vim.git~/.vim/bundle/Vundle.vim
创建配置文件
[jiel@localhost~]$touch~/.vimrc [jiel@localhost~]$vim.vimrc
填入这些基本配置
setnocompatible"required filetypeoff"required "settheruntimepathtoincludeVundleandinitialize setrtp+=~/.vim/bundle/Vundle.vim callvundle#begin() " "alternatively,passapathwhereVundleshouldinstallplugins "callvundle#begin('~/some/path/here') " "letVundlemanageVundle,required Plugin'gmarik/Vundle.vim' " "Addallyourpluginshere(noteolderversionsofVundleusedBundle "insteadofPlugin) "AllofyourPluginsmustbeaddedbeforethefollowingline callvundle#end()"required filetypepluginindenton"required
进入vim执行
:PluginInstall
完成后 基本设置就成功了
Bundle'Valloric/YouCompleteMe'
把这个填入.vimrc里面
再次执行:PluginInstall
进行一些设置避免补全窗口出问题
避免窗口丢失
letg:ycm_python_binary_path='python' letg:ycm_autoclose_preview_window_after_completion=1 map<leader>g:YcmCompleterGoToDeFinitionElseDeclaration<CR>
设置显示行号
set nu
设置编码
set encoding=utf8
现在设置分屏
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>
启用折叠
set foldmethod=indent
set foldlevel=99
映射空格键折叠
nnoremap <space> 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 <C-n> :NERDTreetoggle<CR>
Plugin 'scrooloose/syntastic'
Plugin 'scrooloose/nerdtree'
Plugin 'kien/ctrlp.vim'
Plugin 'tpope/vim-fugitive'
Plugin 'Lokaltog/powerline',{'rtp': 'powerline/bindings/vim/'}
最后执行安装
:PluginInstall
完成后就可以开始痛苦的适应之路了
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。