如果在 Arch Linux 上没有给出输入,如何让 Vim 在启动时启动 NERDTree

如果在 Arch Linux 上没有给出输入,如何让 Vim 在启动时启动 NERDTree

我已经gvim-gtk2从我自己的开放构建服务存储库安装(这里是的)并且大多数事情都可以很好地使用它。唯一的例外是 my 的~/.vimrc目的是在启动时加载 NERDTree,当没有给出输入时(即,它启动时vim没有gvim指定要打开的文件或文件夹),但事实并非如此。

相反,这是 Vim 在启动时显示的屏幕: 在此输入图像描述

这里是我的~/.vimrc文件。以下是 my 中~/.vimrc用于在 Vim 启动时启动 NERDTree 的行:

autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif

这些行是借自书呆子树自述文件文件。在其他发行版上,我在启动时在加载 NERDTree 中发现这一行~/.vimrc完全符合我想要的方式,但在 Arch Linux 上却并非如此。/etc/vimrc我的包安装的文件是vim-runtime

" 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

这是我的archlinux.vim文件:

" The ArchLinux global vimrc - setting only a few sane defaults
"
" Maintainer:      Thomas Dziedzic [[email protected]]
"
" NEVER EDIT THIS FILE, IT'S OVERWRITTEN UPON UPGRADES, GLOBAL CONFIGURATION
" SHALL BE DONE IN /etc/vimrc, USER SPECIFIC CONFIGURATION IN ~/.vimrc

" Normally we use vim-extensions. If you want true vi-compatibility
" remove change the following statements
set nocompatible                " Use Vim defaults instead of 100% vi compatibility
set backspace=indent,eol,start  " more powerful backspacing

" Now we set some defaults for the editor
set history=50                  " keep 50 lines of command line history
set ruler                       " show the cursor position all the time

" Suffixes that get lower priority when doing tab completion for filenames.
" These are files we are not likely to want to edit or read.
set suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc,.png,.jpg

if has('gui_running')
  " Make shift-insert work like in Xterm
  map <S-Insert> <MiddleMouse>
  map! <S-Insert> <MiddleMouse>
endif

相关内容