我只想为C文件打开taglist窗口
如果我将以下命令放入我的.vimrc中,那么窗口将打开,用于所有文件
let Tlist_Auto_Open=1但是,当我使用基于文件类型的autocmd时,它不会打开。有什么我需要检查的依赖吗?
autocmd FileType c,cpp,h,py let Tlist_Auto_Open=1我的.vimrc的一部分如下所示-
" Install pathogen
execute pathogen#infect()
set number " Display Line Numbers
set autoindent " Auto-indenting
set showmatch " Highlight Matching brackets
set tabstop=4 " Default tabstop value
set shiftwidth=4
set smarttab " Enable smart tab
set hlsearch " highlight searched items
set ignorecase " ignore case when searching
set smartcase " ignore case if search pattern is all lowercase, case-sensitive otherwise
" set scrolloff=999 "Start scrolling when we're 8 lines away from margins
" No annoying sound on errors
set noerrorbells
set novisualbell
set timeoutlen=500
filetype plugin on
filetype plugin indent on
set ic
autocmd filetype python set expandtab
" Remove the trailing white-spaces in the C-file
autocmd FileType c,cpp,h,py autocmd BufWritePre <buffer> %s/\s\+$//e
" Unmap the tab-key in the taglist window.
:autocmd BufEnter __Tag_List__ silent! nunmap <buffer> <Tab>
" Syntax higlight for Groovy
au BufRead,BufNewFile *.atc set filetype=groovy
""""""""""""""""""""""""""""""""""
" Taglist configuration
""""""""""""""""""""""""""""""""""
"
" To automatically close the tags tree for inactive files.
" let Tlist_File_Fold_Auto_Close = 1
" Display only one file in taglist.
let Tlist_Show_One_File = 1
" Taglist window size
let Tlist_WinWidth = 30
" Open Taglist by default
autocmd FileType c,cpp,h,py let Tlist_Auto_Open=1
" Close VIM when only taglist window is open
let Tlist_Exit_OnlyWindow = 1发布于 2017-01-12 17:52:07
这是时间问题。taglist插件在加载期间评估Tlist_Auto_Open配置。此时,您的~/.vimrc已被读取,但尚未打开任何文件。您的:autocmd只在这样的文件被:edit编辑之后才激活,到那时,taglist初始化已经结束。另外,除非您只编辑Vim会话中的一种类型的文件,否则您的方法将导致所有后续文件打开taglist!
因此,您不能使用taglist提供的配置特性,但幸运的是,通过:TlistOpen命令实现插件的自动触发非常容易。只需将autocmd修改为:
:autocmd FileType c,cpp,h.py TlistOpenhttps://stackoverflow.com/questions/41618239
复制相似问题