首页 > 解决方案 > .vimrc 仅在 virtualenv 内导致错误

问题描述

我本来打算使用 VIM 编辑器在 venv 中进行开发,我使用大学机器设置了从我相信的服务器加载 python36 的命令。(就像我要使用的那样scl)在这个特定的venv之外,我调用命令来编辑文件没有问题vi,但我在venv里面做。

(venv) [----]UUN: vi ~/.vimrc
Error detected while processing /afs/inf.ed.ac.uk/user/s18/sUUN/.vimrc:
line   11:
E492: Not an editor command: Plugin 'gmarik/Vundle.vim'
line   13:
E492: Not an editor command: Plugin 'https://github.com/nvie/vim-flake8'
line   14:
E492: Not an editor command: Plugin 'scrooloose/nerdtree'
line   15:
E492: Not an editor command: Plugin 'Royal-Colorschemes'
line   16:
E492: Not an editor command: Plugin 'powerline/powerline'
line   22:
E492: Not an editor command: Bundle 'godlygeek/tabular'

我不明白为什么。有人可以启发..以下是我~/.vimrc不在venv上的。

1 set nocompatible
2 filetype off
3 
4 " set the runtime path to include Vundle and initialize
5 set rtp+=~/.vim/bundle/Vundle.vim
6 call vundle#begin()
7 " alternatively, pass a path where Vundle should install plugins
8 "call vundle#begin('~/some/path/here')
9 
10 " let Vundle manage Vundle, required
11 Plugin 'gmarik/Vundle.vim'
12 "place plugin here
13 Plugin 'https://github.com/nvie/vim-flake8'
14 Plugin 'scrooloose/nerdtree'
15 Plugin 'Royal-Colorschemes'
16 Plugin 'powerline/powerline'
17 " All of your Plugins must be added before the following line
18 call vundle#end()            " required
19 
20 filetype plugin indent on
21 
22 Bundle 'godlygeek/tabular'
23 set fileencodings=utf-8
24 set encoding=utf-8
25 
26 syntax on
27 
28 set tabstop=8
29 set expandtab
30 set shiftwidth=4
31 set softtabstop=4
32 
33 set nu
34 set paste
35 
36 set autoindent
37 set cindent
38 
39 set laststatus=2
40 set modeline
41 set background=dark
42 
43 " Key Map "
44 nmap nerd :NERDTreeToggle<CR>

使用 VIM 有效!谢谢你。(但为什么它不起作用vi?)

标签: vimpython-venv

解决方案


它在 vi 中不起作用,因为你还没有set compatible. 相反,您在 .vimrc 中明确设置了不兼容模式:set nocompatible. 您可以尝试设置兼容模式,但我怀疑这些插件中的任何一个是否可以工作——但我还没有亲自测试过这一点。相反,我遵循经验法则:在使用为 vim 编写的插件时使用 vim。


推荐阅读