
在个人的home目录中,打开 *.bashrc*文件,打开方式为
没有安装gedit文本编辑器的使用如下命令安装
或者使用vim、nano等。打开后,输入如下内容:
然后注销登录或者输入如下命令以使命令立刻生效
先删除默认的Python软链接:
然后创建一个新的软链接指向需要的Python版本:
如果想还原回原python2.7,只需
注意,ln命令的基本用法为:
直接执行下面两个命令即可:
如果需要改回python2默认,则输入:
完毕。
你可能不想(或至少不应该) code>python3 作为vim的默认python解释器,因为你的插件的一些(大部分)将变得不兼容,例如 YouCompleteMe 和 clang_complete 本身,因为他们没有 python3 支持。通常,支持 python3 的插件可以让您决定是否要通过添加到 .vimrclet g:syntastic_python_python_exec ='python3'
解决方案: :echo has('python')显示 0 实际上告诉你vim可能不是用 python2 编译的。所以首先检查 vim --version 的输出,你应该能够看到你的编译器构建vim的共享库列表。你看到以下? (例如对于python 2.7):
-L / usr / lib / python2.7 / config-x86_64-linux-gnu - lpython2.7
如果没有(或者如果你看到 -lpython2.x 和 -lpython3.x 我建议你从源代码编译vim,具体链接到 -lpython2.x
sudo apt-get remove --purge vim vim-runtime vim-gnome vim-tiny vim-common vim-gui-common
clone vim mercurial
hg clone htvim/
cd vim
,然后使用以下标志运行 ./ configure :
./configure --with-features = huge \
--enable-cscope \
--enable-pythoninterp \
--enable-largefile \
--with-python-config-dir = / usr / lib / python2.7 / config
您还可能想要链接 ruby 和 lua 如果需要,然后最后运行
make build
make install
这里是shell脚本,将自动执行整个过程为你。这可能有点过分,但我认为这是你应该如何处理这不与运行与您的未来包的兼容性问题。
1、安装pydictionpydiction可以让vim自动补全Python代码,无论是关键字,标准库还是第三方库。它主要包含3个文件:
python_pydiction.vim: vim插件文件。
complete-dict: 一个字典文件,包含了Python的关键字和模块。插件引用的内容即来自于此。
pydiction.py: 一个py脚本,运行此文件可以增加新的模块到complete-dict字典中。
Linux/Unix系统:将python_pydiction.vim文件复制到 ~/.vim/after/ftplugin 目录下。如果该目录不存在,则创建它,vim会自动在此目录下搜索。
$ cp after/ftplugin/python_pydiction.vim ~/.vim/after/ftplugin
$ cp complete-dict ~/.vim
$ cp pydiction.py ~/.vim
2、编辑~/.vimrc文件,如果不存在则创建。添加以下内容:
let Tlist_Auto_Highlight_Tag=1
let Tlist_Auto_Open=1
let Tlist_Auto_Update=1
let Tlist_Display_Tag_Scope=1
let Tlist_Exit_OnlyWindow=1
let Tlist_Enable_Dold_Column=1
let Tlist_File_Fold_Auto_Close=1
let Tlist_Show_One_File=1
let Tlist_Use_Right_Window=1
let Tlist_Use_SingleClick=1
nnoremap <silent><F8>:TlistToggle<CR>
filetype plugin on
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascrīpt set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType c set omnifunc=ccomplete#Complete
let g:pydiction_location='~/.vim/complete-dict'
set autoindent
set tabstop=4
set shiftwidth=4
set expandtab
set number
3、在~/.vimrc中加入下面两行设置,实现离开补全d窗或者离开插入模式时自动关闭scratch preview。
autocmd InsertLeave * if pumvisible() == 0|pclose|endif
autocmd CursorMovedI * if pumvisible() == 0|pclose|endif
备注: ctrl x,ctrl o打开代码补齐,ctrl e关闭补齐,ctrl y 选择当前的补齐代码,并关闭。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)