在DEBIAN系统上配置VIM来开发PYTHON3
我使用的是debian9,默认安装了Python3.5,但是没有安装vim,所以我使用了APT来安装vim:
sudo apt-get install vim-nox
该版本的vim默认支持Python3,所以不用通过源码编译的方法进行配置。
要查看vim是否支持Python3,可以使用命令:
vim --version
来查看,如果Python3前面有个+号则表示支持。
接下来给vim装一个插件管理器vundle:
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
然后在个人的主目录下的.vimrc文件(找不到就自己创建)中加上:
set nocompatible filetype off set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() " alternatively, pass a path where Vundle should install plugins "call vundle#begin('~/some/path/here') Plugin 'VundleVim/Vundle.vim' " All of your Plugins must be added before the following line call vundle#end() filetype plugin indent on
下一步,安装各种插件,在.vimrc文件中添加下列信息到vundle管理安装插件的行中
" 添加nerdtree插件 Plugin 'scrooloose/nerdtree' "代码自动补全插件 Plugin 'Valloric/YouCompleteMe' "python语法检测 Plugin 'scrooloose/syntastic' "添加PEP8代码风格检查 Plugin 'nvie/vim-flake8' "代码折叠插件 Plugin 'tmhedberg/SimpylFold' "自动缩进 Plugin 'vim-scripts/indentpython.vim' "Powerline状态栏 Plugin 'Lokaltog/powerline', {'rtp': 'powerline/bindings/vim/'} "在vim的normal模式下搜索文件 Plugin 'kien/ctrlp.vim' "快速注释/解开注释 Plugin 'scrooloose/nerdcommenter'
保存后,在终端中中输入vim进入vim编辑器,然后输入
:PluginInstall
进行安装。
安装完成后(YouCompleteMe的安装时间较长)还需要到YouCompleteMe所在目录下运行
python3 install.py --clang-completer
再进行相应的设置,我的.vimrc文件如下,可供参考:
set nu set encoding=utf-8 " vundle设置 set nocompatible " be iMproved, required filetype off " required set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() Plugin 'VundleVim/Vundle.vim' " 添加nerdtree插件 Plugin 'scrooloose/nerdtree' "代码自动补全插件 Plugin 'Valloric/YouCompleteMe' "python语法检测 Plugin 'scrooloose/syntastic' "添加PEP8代码风格检查 Plugin 'nvie/vim-flake8' "代码折叠插件 Plugin 'tmhedberg/SimpylFold' "自动缩进 Plugin 'vim-scripts/indentpython.vim' "Powerline状态栏 Plugin 'Lokaltog/powerline', {'rtp': 'powerline/bindings/vim/'} "在vim的normal模式下搜索文件 Plugin 'kien/ctrlp.vim' "快速注释/解开注释 Plugin 'scrooloose/nerdcommenter' call vundle#end() " required filetype plugin indent on " required " 配置信息 " nerdtree " 设置按F2启动NerdTree map <F2> :NERDTreeToggle<CR> " 隐藏目录树中的.pyc文件 let NERDTreeIgnore=['\.pyc$', '\~$'] "ignore files in NERDTree " 设置宽度 let NERDTreeWinSize=20 " YouCompleteMe "youcompleteme 默认tab s-tab 和自动补全冲突 let g:ycm_key_list_select_completion = ['<Down>'] "关闭加载.ycm_extra_conf.py提示 let g:ycm_confirm_extra_conf=0 " 开启 YCM 基于标签引擎 let g:ycm_collect_identifiers_from_tags_files=1 " 从第1个键入字符就开始罗列匹配项 let g:ycm_min_num_of_chars_for_completion=1 " 禁止缓存匹配项,每次都重新生成匹配项 let g:ycm_cache_omnifunc=0 " 语法关键字补全 let g:ycm_seed_identifiers_with_syntax=1 "force recomile with syntastic nnoremap <F5> :YcmForceCompileAndDiagnostics<CR> "nnoremap <leader>lo :lopen<CR> "open locationlist "nnoremap <leader>lc :lclose<CR> "close locationlist inoremap <leader><leader> <C-x><C-o> "在注释输入中也能补全 let g:ycm_complete_in_comments = 1 "在字符串输入中也能补全 let g:ycm_complete_in_strings = 1 "注释和字符串中的文字也会被收入补全 let g:ycm_collect_identifiers_from_comments_and_strings = 0 "开启代码折叠 set foldmethod=indent set foldlevel=99 " 设置快捷键为空格 noremap <space> za " 显示折叠代码的文档字符串 let g:SimpylFold_docstring_preview=1 "注释后自动加一个空格 let g:NERDSpaceDelims=1 "let g:mapleader = ',' " Brief help " :PluginList - lists configured plugins " :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate " :PluginSearch foo - searches for foo; append `!` to refresh local cache " :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
版权声明:本文转载请注明出处!
最新评论:
发表评论
电子邮件地址不会被公开。 必填项已用*标注