> For the complete documentation index, see [llms.txt](https://dofy.gitbook.io/learn-vim/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dofy.gitbook.io/learn-vim/en/plugins/nerdtree.md).

# NERDTree

NERDTree is a file browsing plugin for Vim that allows you to open/close directory trees and browse/open files with commands.

## Project address

<https://github.com/preservim/nerdtree>

## Installation

> Modify the `.vimrc` configuration by adding the following configuration after `call plug#begin()`.

Add the following to `.vimrc` after `call plug#begin()`:

```vim
Plug 'preservim/nerdtree', { 'on': 'NERDTreeToggle' }
```

*Note: For use of the Vim plugin manager, see* [*vim-plugin.md*](/learn-vim/en/vim-plugin.md#plugin-management)

> Run Vim and execute the command `:PlugInstall`, you may get the following prompt:

```
1 Updated. Elapsed time: 6.008607 sec.
2 [===]
3
4 - Finishing ... Done!
5 - vim-github-dashboard: Already installed
6 - vim-easy-align: Already installed
7 - nerdtree: Resolving deltas: 100% (158/158), done.
```

## Using

If you see the above prompt, it means the plugin is installed successfully, you can execute the following commands to control the directory tree.

| Command           | Description                               |
| ----------------- | ----------------------------------------- |
| `:NERDTree`       | Open Directory Tree                       |
| `:NERDTreeClose`  | Close the tree                            |
| `:NERDTreeToggle` | open/close the catalog tree               |
| `:NERDTreeFind`   | Open the tree and locate the current file |

## Tips

### Binding shortcuts

Add the following configuration to `.vimrc`:

```vim
" NERDTree
map <C-n> :NERDTreeToggle<CR>
" map is the shortcut mapping command <C-n> defines the shortcut key, Ctrl-n.
" followed by the corresponding command and the enter key <CR>.
```

After reloading the `.vimrc` file, you can use `<Ctrl-n>` to open and close the directory tree.

### Show hidden files

The NERDTree plugin does not show hidden files by default. There are two ways to view hidden files:

1. Press `shift-i` after opening the tree to show hidden files, press it again to close the hidden files display.
2. Add the setting `let NERDTreeShowHidden=1` to `.vimrc` to show hidden files by default.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://dofy.gitbook.io/learn-vim/en/plugins/nerdtree.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
