我正在尝试在使用终端窗口时覆盖所有colorschemes的背景 - 主要是因为我发现透明的终端窗口非常令人兴奋。我所做的最大努力都是为了定义一个自动命令,它将在每次更改colorscheme时运行。目前命令如下所示:
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
答案 0 :(得分:3)
.vimrc
中的命令按顺序执行。您首先设置:colorscheme
,但:autocmd
仅在结束时出现。
要么将autocmd移动到:colorscheme
命令之前(以便它已经应用于此命令),要么在:source rmbackground.vim
命令后显式:colorscheme
,并且{{1}仅适用于以后的动态更改。