Stop NERDTree opening when vim starts
Asked Answered
I

3

13

I have NERDTree plugin installed but it is always present when I start vim like this:

vim .

I only want it to open on demand.

How can I stop it opening whenever I start vim?

Iodine answered 25/10, 2012 at 16:43 Comment(0)
G
14

Try adding

let g:NERDTreeHijackNetrw=0

to your vimrc and make sure there is no other line that sets this variable.

Gerard answered 25/10, 2012 at 16:49 Comment(4)
I'm curious where do you get this info. I've taken a look at this but I didn't find anything.Phosphatase
@Vdt From docs, just the same file. You’ve overlooked it.Gerard
@Vdt Don’t search for g:Smth, if you really read NERDTree help you should’ve noted all options go without g: prefix hence they are searched by NERDTreeHijackNetrw.Gerard
This does not work for gvim.Inauspicious
V
5

$ vim . always opens a file explorer. If you don't have NERDTree or NERDTree is configured as per ZyX's answer you'll get netrw by default anyway.

I wonder what would happen if the netrw plugin was somehow removed.

Virginiavirginie answered 25/10, 2012 at 19:15 Comment(1)
You can easily test this with gvim --noplugin . and you get an empty buffer and the prompt "'.' is a directory".Viscountcy
F
4

In your vimrc file, do below steps

  1. comment autocmd VimEnter * NERDTree, which stops opening nerdTree by default

  2. paste map <C-n> :NERDTreeToggle<CR> in vimrc, this will open NerdTree only when 'Ctrl+n' is pressed from keyboard

Fitton answered 22/1, 2019 at 7:29 Comment(1)
I was using this approach for a long time. But for some weird reason, I am getting "E42: No Errors" when I press Ctrl + n. Do you have any idea why?Anders

© 2022 - 2024 — McMap. All rights reserved.