Vim:用于删除配色方案背景的Autocmd无法运行



在使用终端窗口时,我试图覆盖所有配色方案的背景,主要是因为我发现透明的终端窗口令人兴奋。我所有的研究都指向定义一个自动命令,该命令将在每次更改配色方案时运行。当前命令如下:

autocmd ColorScheme * so rmbackground.vim

rmbackground.vim是我自己制作的一个文件,它基本上列出了一堆hilight命令,比如:

hi Normal ctermbg=NONE
hi Comment ctermbg=NONE
...

现在奇怪的是,如果我手动获取rmbackground.vim文件,一切都能正常工作,但自动命令不会按预期运行。如果我指定一个hilight命令作为autocmd而不是源整个rmbackground文件,它也不会起作用。

我对整个问题感到很困惑。下面是我完整的vimrc和rmbackground.vim,以防出现我不知道的冲突。(由于我刚开始构建我的配置,该文件目前很糟糕,但我希望你能原谅我;-)

.vmrc

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

.vimrc中的命令按顺序执行。您首先设置了:colorscheme,但:autocmd仅在末尾出现。

要么将autocmd移动到:colorscheme命令之前(以便它已经应用于该命令),要么在:colorscheme命令之后显式地移动:source rmbackground.vim,并且:autocmd仅用于以后的动态更改。

相关内容

  • 没有找到相关文章

最新更新