ype python set omnifunc=pythoncomplete#Complete
"------------Start Python PEP 8 stuff----------------
" Number of spaces that a pre-existing tab is equal to.
au BufRead,BufNewFile *py,*pyw,*.c,*.h set tabstop=4
"spaces for indents
au BufRead,BufNewFile *.py,*pyw set shiftwidth=4
au BufRead,BufNewFile *.py,*.pyw set expandtab
au BufRead,BufNewFile *.py set softtabstop=4
" Use the below highlight group when displaying bad whitespace is desired.
highlight BadWhitespace ctermbg=red guibg=red
" Display tabs at the beginning of a line in Python mode as bad.
au BufRead,BufNewFile *.py,*.pyw match BadWhitespace /^\t\+/
" Make trailing whitespace be flagged as bad.
au BufRead,BufNewFile *.py,*.pyw,*.c,*.h match BadWhitespace /\s\+$/
" Wrap text after a certain number of characters
au BufRead,BufNewFile *.py,*.pyw, set textwidth=100
" Use UNIX (\n) line endings.
au BufNewFile *.py,*.pyw,*.c,*.h set fileformat=unix
" Set the default file encoding to UTF-8:
set encoding=utf-8
" For full syntax highlighting:
let python_highlight_all=1
syntax on
" Keep indentation level from previous line:
autocmd FileType python set autoindent
" make backspaces more powerfull
set backspace=indent,eol,start
"Folding based on indentation:
autocmd FileType python set foldmethod=indent
"use space to open folds
nnoremap <space> za
"----------Stop python PEP 8 stuff--------------
"js stuff"
autocmd FileType java script setlocal shiftwidth=2 tabstop=2
5.3.直接运行vim,输入:PluginInstall
,等待安装,结束后退出即可。
以后安装插件,直接可以编辑 .vimrc
文件,例如在.vimrc的 call vundle#begin()
和 call vundle#end()
之间加上 Plugin 'Valloric/YouCompleteMe'
,再运行 :PluginInsstall
即安装YCM插件,
由于YouCompleteMe有223M左右,所以需要耐心等待,可以时不时用命令 du -s ~/.vim/bundle/YouCompleteMe
观察文件夹大小
6.YCM(YouCompleteMe)自动补全
(用Vundle下载慢的话,可以先去官网下载:`git clone https://github.com/Valloric/YouCompleteMe ~/.vim/bundle/YouCompleteMe` )
使用的话有些特殊,需要编译之后才能使用。
6.1. cd ~/.vim/bundle/YouCompleteMe
6.2. 安装支持补全的语言关联: ./install.py
# 这里可以使用install --help查看支持哪些补全
./install.py --clang-completer
# 关联C家族的语言; ./install.py
# 支持python补全
6.3. 配置文件.ycm_extra_conf.py,包含了补全的系统头文件和源文件出处。(python可以不用配置)
修改flags下的列表即可,在里面添加所需的目录
sudo cp ~/.vim/bundle/YouCompleteMe/third_party/ycmd/examples/.ycm_extra_conf.py ~/
sudo vim ~/.ycm_extra_conf.py
改前
改后
如果出现错误:
则 sudo vim ~/.ycm_extra_conf.py
, 然后修改目录:
把.ycm_extra_conf.py放在当前目录配置,是因为YCM是先在当前目录查找再网上走一直递归到找到为止,并且只会加载一次,方便修改。
End
附录博客:
Vundle新老版本的Vundle安装见此文章vundle: vim插件管理安装之错误总结
.vimrc大佬配置二无注释的可以见此文章:Vim配置(python版)
YCM的安装配置见此文章Ubuntu 16.04 64位安装YouCompleteMe