此操作来自以下链接学来
配置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
系统环境
1 2 3 4 |
|
vim环境
1 |
|
输出中一定要有+python 选项
开始安装
安装基本环境信息
安装epel仓库
1 |
|
安装基本软件
1 |
|
安装python-pip
1 2 |
|
下载vundle
1 |
|
创建配置文件
1 2 |
|
填入这些基本配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
|
进入vim执行
:PluginInstall
完成后 基本设置就成功了
先开始安装最大的一个插件
这是一个用于代码补全的重要性也是杠杠的链接
1 |
|
把这个填入.vimrc里面
再次执行:PluginInstall
进行一些设置避免补全窗口出问题
避免窗口丢失
1 2 3 |
|
设置显示行号
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'
添加一个C-P搜索插件链接
Plugin 'kien/ctrlp.vim'
添加一个git集成链接
Plugin 'tpope/vim-fugitive'
添加一个状态栏插件链接
Plugin 'Lokaltog/powerline', {'rtp': 'powerline/bindings/vim/'}
最后执行安装
:PluginInstall
完成后就可以开始痛苦的适应之路了
$
# git clone https://github.com/Valloric/YouCompleteMe.git
#git submodule update --init --recursive
#yum install python-dev python3-dev
#python3 install.py --clang-completer --system-libclang
wget -qO- https://raw.github.com/ma6174/vim/master/setup.sh | sh -x