简体   繁体   English

在vim打开时打开NERDTree时自动切换缓冲区

[英]Automatically switch buffer when opening NERDTree on vim open

Currently I have NERDTree opening by default when I edit a file that is not a git commit message using this command: 当前,当我使用以下命令编辑不是git commit消息的文件时,默认情况下会打开NERDTree:

autocmd VimEnter * if &filetype !=# 'gitcommit' | NERDTree | endif

Only issue is that when the file opens, NERDTree is the default buffer, which is very annoying. 唯一的问题是,当文件打开时,NERDTree是默认缓冲区,这很烦人。 What can I add to my vimrc file so that when I open a file, that file is the focused buffer, and not NERDTree? 我可以在vimrc文件中添加什么内容,以便在打开文件时该文件成为焦点缓冲区,而不是NERDTree?

打开NERDTree后,您可以尝试使用此命令切换到上一个窗口。

autocmd VimEnter * if &filetype !=# 'gitcommit' | NERDTree | wincmd p | endif

nerdtree tabs will handle that for you automatically. nerdtree标签将自动为您处理。

let g:nerdtree_tabs_open_on_console_startup=1
let g:nerdtree_tabs_open_on_gui_startup=1

It will also select the right buffer for you. 它还将为您选择合适的缓冲区。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM