【问题标题】:Set a vim colorscheme for all users为所有用户设置 vim 颜色方案
【发布时间】:2020-04-28 06:10:32
【问题描述】:

我想为所有用户将 gruvbox 设置为全局默认配色方案,但我无法让它工作。我得到E185: Cannot find color scheme*,但这个解决方案here 对我不起作用。 (我试图在vim 中执行此操作,而不是gvim)。

我在/usr/share/vim/vim82/plugs/gruvbox 中安装了 gruvbox。我的/etc/vimrc 是我在 Windows 桌面上使用的 vimrc 的修改,但现在我在 Linux 中运行它:

" All system-wide defaults are set in $VIMRUNTIME/archlinux.vim (usually just
" /usr/share/vim/vimfiles/archlinux.vim) and sourced by the call to :runtime
" you can find below.  If you wish to change any of those settings, you should
" do it in this file (/etc/vimrc), since archlinux.vim will be overwritten
" everytime an upgrade of the vim packages is performed.  It is recommended to
" make changes after sourcing archlinux.vim since it alters the value of the
" 'compatible' option.

" This line should not be removed as it ensures that various options are
" properly set to work with the Vim-related packages.
runtime! archlinux.vim

" If you prefer the old-style vim functionalty, add 'runtime! vimrc_example.vim'
" Or better yet, read /usr/share/vim/vim80/vimrc_example.vim or the vim manual
" and configure vim to your own liking!

" do not load defaults if ~/.vimrc is missing
"let skip_defaults_vim=1

" Make vim portable, well, not portable in linux yet
" let $HOME=$VIM

" Set color scheme
set t_Co=256
syntax on
colorscheme gruvbox
set background=dark
highlight Comment cterm=bold

" Setup Vimplugs
call plug#begin('/usr/share/vim/vim82/plugs')
Plug 'vim-python/python-syntax'
Plug 'scrooloose/nerdcommenter'
Plug 'tmhedberg/SimpylFold'
Plug 'vim/killersheep'
Plug 'gruvbox-community/gruvbox'
call plug#end()

这是我的runtimepath

runtimepath=~/.vim,/usr/share/vim/vim82/plugs/python-syntax,/usr/share/vim/vim82/plugs/nerdcommenter,/usr/share/vim/vim82/plugs/SimpylFold,/usr/share/vim/vim82/plugs/killersheep,/usr/share/vim/vim82/plugs/gruvbox,/usr/share/vim/vimfiles,/usr/share/vim/vim82,/usr/share/vim/vimfiles/after,~/.vim/after

vim --version 显示这些搜索路径:

   system vimrc file: "/etc/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/share/vim"

有什么想法吗?

【问题讨论】:

  • 尝试在/etc/vimrc 的最后移动colorscheme gruvbox。我怀疑/usr/share/vim/vim82/plugscall plug#begin(…) 之后被添加到runtimepath
  • @phd 在plug#end() 之后实际上...是的,colorscheme gruvbox 需要在该行之后。使用 vim-plug 为多个用户管理插件有些问题……但那是另一回事了。
  • 感谢您的建议。我试图将colorscheme gruvbox 放在call plug#end() 后面,但仍然无法加载,同样的错误。你认为我应该从 /usr/share 中删除这些插件并将它们安装在每个用户的家中吗?

标签: vim


【解决方案1】:

我已经解决了这样的问题:

  1. 打开根控制台 (su)
  2. 卸载所有 Vimplug 插件
  3. 重启vim
  4. 重新安装gruvbox
  5. 重启vim
  6. 重新安装其余插件

在我安装插件并修改我的 /etc/vimrc 之前,总是从我的用户帐户中添加sudo,但它似乎没有那么有效。 root 帮助所有事情重做。

【讨论】:

    猜你喜欢
    • 2011-02-27
    • 1970-01-01
    • 2016-09-20
    • 2011-05-18
    • 2023-04-11
    • 2010-11-10
    • 1970-01-01
    • 1970-01-01
    • 2018-12-25
    相关资源
    最近更新 更多