首页 > 解决方案 > Set a vim colorscheme for all users

问题描述

I want to set gruvbox as the default color scheme globally, for all users, but I can't get this working. I get E185: Cannot find color scheme*, but this solution here doesn't work for me. (I'm trying to do this in vim, not gvim).

I have gruvbox installed in /usr/share/vim/vim82/plugs/gruvbox. My /etc/vimrc is a modification of the vimrc I used on my Windows desktop, but now I run it in 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()

This is my 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 shows these search paths:

   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"

Any ideas what's wrong?

标签: vim

解决方案


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

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

在我安装插件和修改我的 /etc/vimrc 之前,总是从我的用户帐户使用 prepended sudo,但它似乎效率不高。root所有事情都按照帮助重做。


推荐阅读