I'm basically working in an environment where I sometimes use ctrlp and sometimes nerdtree. But when I start vim using vim . it always opens NERDTree. I've tried various .vimrc config commands:
let NERDTreeQuitOnOpen=1
let g:nerdtree_tabs_open_on_gui_startup=0
But they all don't work. Is there some whay I can disable the NERDTree directory listing when VIM opens? Note, I don't like just using the vim command by itself because I'm usually opening VIM when I'm in the application directory.
Thanks!
Netrw plugin opens when vim opens a directory. NerdTree takes over netrw and therefore opens when editing a directory.
vim . is equivalent to :e .
Just open vim without the . and you will be good
Related
I have nerdtree and ctrlp installed in vim.
I use vim in command line on some directory: vim somedir.
I intend to let vim start with an empty file just as if I only type vim.
But currently, vim will start with nerdtree opened, the root directory is the same as the directory after vim command.
How can let vim start with an empty buffer and afterwards I want to use ctrlp to search files?
You should do it the other way around:
$ cd somedir && vim
If I open a folder in vim like this:
$ mvim . # or vim .
NERDTree opens by default in full width:
How can I prevent this from happening and show default VIM welcome screen instead?
You are explicitly telling vim to start with a listing of the current directory, if you don't want that, just do $ vim.
Run vim to get the Welcome Screen.
If you open vim . you'll get a directory listing of the current working directory (Netrw or NERDTree Directory Listing).
NERDTree overrides the default file browser (netrw).
To disable directory listing by NERDTree at startup, add let g:NERDTreeHijackNetrw=0 to your ".vimrc".
This Option tells NERD tree whether to replace the netrw autocommands for exploring local directories.
Run vim --noplugin . and you see an empty buffer.
I'm a new user of NERD tree in Vim and am obviously not that much familiar with its features.
When I'm using :NERDTreeToggle, the sidebar window always opens my home directory, ~. How can I change the default directory (like open a project in Sublime Text)?
Also, how can I keep this sidebar window open in all of the new tab windows (something like the Sublime Text sidebar)? Or at least, is there another alternative to this task?
In your .vimrc file, add the following code, which will by default open Vim with a NERD tree sidebar of the current directory. So if you are in the projects directory and you type "vim" it will open Vim with a sidebar on the left showing all the files and directories in the projects folder
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
If you want toggle on and off the sidebar, just add this into your .vimrc file so that if you want to toggle the sidebar, just type Ctrl + N:
map <C-n> :NERDTreeToggle<CR>
Vim has no concept of "project".
The closest you can get without installing clunky plugins is the "current directory": when you start Vim, the "current directory" is set to the directory where you started Vim.
In your shell, this is easy to manage:
$ cd /path/to/project
$ vim
:pwd --> /path/to/project
If you use gVim or MacVim, the "current directory" is usually set automatically to $HOME if you start Vim without a file so, either you find a way to start Vim in an arbitrary directory or you use :cd /path/to/dir as soon as possible.
Without argument, the :NERDTree* commands open the NERD tree window in the "current directory".
You can use :NERDTreeToggle /path/to/dir to make it display the content of a specific directory.
Or you can make sure you start Vim from your project's directory and NERD tree will do what you want it to do.
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?
Try adding
let g:NERDTreeHijackNetrw=0
to your vimrc and make sure there is no other line that sets this variable.
$ 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.
In your vimrc file, do below steps
comment autocmd VimEnter * NERDTree, which stops opening nerdTree
by default
paste map <C-n> :NERDTreeToggle<CR> in vimrc, this will open
NerdTree only when 'Ctrl+n' is pressed from keyboard
using vim + NERDTree in windows is a bit of a pain for me because each time I start vim and toggle NERDTree, NERDTree takes a long time caching my whole /Windows/system32 directory.
In order to avoid that, how can I create a shortcut to open vim in say C:\users\me\vim ?
You can add somewhere in your .vimrc.
cd C:\users\me\vim
It will change the working directory of your Vim instance.
According to :help starting.txt.vimrc is loaded before plugins.