在使用终端窗口时,我试图覆盖所有颜色方案的背景——主要是因为我发现透明的终端窗口非常令人兴奋。我所有最大的研究努力都指向定义一个自动命令,该命令将在每次更改颜色方案时运行。目前该命令如下所示:
autocmd ColorScheme * so rmbackground.vim
rmbackground.vim 是我自己制作的一个文件,它基本上列出了一堆 hilightcommands,如下所示:
hi Normal ctermbg=NONE
hi Comment ctermbg=NONE
...
现在奇怪的是,如果我手动获取 rmbackground.vim 文件,一切正常,但自动命令不会按预期运行。如果我将单个 hilight 命令指定为 autocmd 而不是获取整个 rmbackground 文件,它也不起作用。
我对整个问题感到非常困惑。下面是我的完整 vimrc 和 rmbackground.vim,以防有我不知道的冲突。(由于我刚刚开始构建我的配置,该文件目前很糟糕,但我希望你能原谅我;-))
.vimrc
runtime bundle/vim-pathogen/autoload/pathogen.vim
call pathogen#infect()
"Turn on syntax
if has("syntax")
syntax on
endif
"Jump to last edited line
if has("autocmd")
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif
"Indent correctly
if has("autocmd")
filetype plugin indent on
endif
set t_Co=256 "use 256 colors
let g:CSApprox_attr_map = { 'bold' : 'bold', 'italic' : '', 'sp' : '' }
set background=light
colorscheme twilight
set showcmd " Show (partial) command in status line.
set showmatch " Show matching brackets.
set ignorecase " Do case insensitive matching
set smartcase " Do smart case matching
set hlsearch " Highlight search-terms
set incsearch " Incremental search
set autowrite " Automatically save before commands like :next and :make
set hidden " Hide buffers when they are abandoned
set mouse=a " Enable mouse usage (all modes)
set history=1000
runtime macros/matchit.vim
set wildmenu
set wildmode=list:longest
set title
set scrolloff=3
set backupdir=~/.vim/tmp,~/.tmp,/var/tmp,/tmp
set directory=~/.vim/tmp,~/.tmp,/var/tmp,/tmp
set ruler
set backspace=indent,eol,start
set tabstop=4
set softtabstop=4
set shiftwidth=4
set shiftround "Round the indention nicely with other indents
set visualbell
"!autocmd
autocmd ColorScheme * so rmbackground.vim
rmbackground.vim
"Remove background set by colorscheme
hi Normal ctermbg=NONE
hi Comment ctermbg=NONE
hi Constant ctermbg=NONE
hi Special ctermbg=NONE
hi Identifier ctermbg=NONE
hi Statement ctermbg=NONE
hi PreProc ctermbg=NONE
hi Type ctermbg=NONE
hi Underlined ctermbg=NONE
hi Todo ctermbg=NONE
hi String ctermbg=NONE
hi Function ctermbg=NONE
hi Conditional ctermbg=NONE
hi Repeat ctermbg=NONE
hi Operator ctermbg=NONE
hi Structure ctermbg=NONE