{"id":27906447,"url":"https://github.com/scrooloose/nerdtree","last_synced_at":"2025-05-06T02:01:07.389Z","repository":{"id":385931,"uuid":"3282","full_name":"preservim/nerdtree","owner":"preservim","description":"A tree explorer plugin for vim.","archived":false,"fork":false,"pushed_at":"2024-07-20T05:04:50.000Z","size":1965,"stargazers_count":19868,"open_issues_count":28,"forks_count":1443,"subscribers_count":307,"default_branch":"master","last_synced_at":"2025-05-01T06:02:52.642Z","etag":null,"topics":["file-management","file-manager","vim","vim-plugin","vim-plugins"],"latest_commit_sha":null,"homepage":"","language":"Vim Script","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"wtfpl","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/preservim.png","metadata":{"files":{"readme":"README.markdown","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2008-03-10T07:34:08.000Z","updated_at":"2025-05-01T02:52:57.000Z","dependencies_parsed_at":"2023-02-14T12:45:34.447Z","dependency_job_id":"ac6444bc-507c-4492-8df2-1c1be065fab8","html_url":"https://github.com/preservim/nerdtree","commit_stats":{"total_commits":1161,"total_committers":155,"mean_commits":7.490322580645161,"dds":0.6347975882859604,"last_synced_commit":"9b465acb2745beb988eff3c1e4aa75f349738230"},"previous_names":["scrooloose/nerdtree"],"tags_count":112,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/preservim%2Fnerdtree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/preservim%2Fnerdtree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/preservim%2Fnerdtree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/preservim%2Fnerdtree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/preservim","download_url":"https://codeload.github.com/preservim/nerdtree/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252606936,"owners_count":21775415,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["file-management","file-manager","vim","vim-plugin","vim-plugins"],"created_at":"2025-05-06T02:00:42.330Z","updated_at":"2025-05-06T02:01:07.342Z","avatar_url":"https://github.com/preservim.png","language":"Vim Script","readme":"# The NERDTree [![Vint](https://github.com/preservim/nerdtree/workflows/Vint/badge.svg)](https://github.com/preservim/nerdtree/actions?workflow=Vint)\n\n## Introduction\n\nThe NERDTree is a file system explorer for the Vim editor. Using this plugin, users can visually browse complex directory hierarchies, quickly open files for reading or editing, and perform basic file system operations.\n\n![NERDTree Screenshot](https://github.com/preservim/nerdtree/raw/master/screenshot.png)\n\n## Installation\n\nUse your favorite plugin manager to install this plugin. [tpope/vim-pathogen](https://github.com/tpope/vim-pathogen), [VundleVim/Vundle.vim](https://github.com/VundleVim/Vundle.vim), [junegunn/vim-plug](https://github.com/junegunn/vim-plug), and [Shougo/dein.vim](https://github.com/Shougo/dein.vim) are some of the more popular ones. A lengthy discussion of these and other managers can be found on [vi.stackexchange.com](https://vi.stackexchange.com/questions/388/what-is-the-difference-between-the-vim-plugin-managers). Basic instructions are provided below, but please **be sure to read, understand, and follow all the safety rules that come with your ~~power tools~~ plugin manager.**\n\nIf you have no favorite, or want to manage your plugins without 3rd-party dependencies, consider using Vim 8+ packages, as described in Greg Hurrell's excellent Youtube video: [Vim screencast #75: Plugin managers](https://www.youtube.com/watch?v=X2_R3uxDN6g).\n\n\u003cdetails\u003e\n\u003csummary\u003ePathogen\u003c/summary\u003e\nPathogen is more of a runtime path manager than a plugin manager. You must clone the plugins' repositories yourself to a specific location, and Pathogen makes sure they are available in Vim.\n\n\n1. In the terminal,\n    ```bash\n    git clone https://github.com/preservim/nerdtree.git ~/.vim/bundle/nerdtree\n    ```\n1. In your `vimrc`,\n    ```vim\n    call pathogen#infect()\n    syntax on\n    filetype plugin indent on\n    ```\n1. Restart Vim, and run `:helptags ~/.vim/bundle/nerdtree/doc/` or `:Helptags`.\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eVundle\u003c/summary\u003e\n\n1. Install Vundle, according to its instructions.\n1. Add the following text to your `vimrc`.\n    ```vim\n    call vundle#begin()\n      Plugin 'preservim/nerdtree'\n    call vundle#end()\n    ```\n1. Restart Vim, and run the `:PluginInstall` statement to install your plugins.\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eVim-Plug\u003c/summary\u003e\n\n1. Install Vim-Plug, according to its instructions.\n1. Add the following text to your `vimrc`.\n```vim\ncall plug#begin()\n  Plug 'preservim/nerdtree'\ncall plug#end()\n```\n1. Restart Vim, and run the `:PlugInstall` statement to install your plugins.\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eDein\u003c/summary\u003e\n\n1. Install Dein, according to its instructions.\n1. Add the following text to your `vimrc`.\n    ```vim\n    call dein#begin()\n      call dein#add('preservim/nerdtree')\n    call dein#end()\n    ```\n1. Restart Vim, and run the `:call dein#install()` statement to install your plugins.\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eVim 8+ packages\u003c/summary\u003e\n\nIf you are using Vim version 8 or higher you can use its built-in package management; see `:help packages` for more information. Just run these commands in your terminal:\n\n```bash\ngit clone https://github.com/preservim/nerdtree.git ~/.vim/pack/vendor/start/nerdtree\nvim -u NONE -c \"helptags ~/.vim/pack/vendor/start/nerdtree/doc\" -c q\n```\n\u003c/details\u003e\n\n## Getting Started\nAfter installing NERDTree, the best way to learn it is to turn on the Quick Help. Open NERDTree with the `:NERDTree` command, and press `?` to turn on the Quick Help, which will show you all the mappings and commands available in the NERDTree. Of course, your most complete source of information is the documentation: `:help NERDTree`.\n\n## NERDTree Plugins\nNERDTree can be extended with custom mappings and functions using its built-in API. The details of this API are described in the included documentation. Several plugins have been written, and are available on Github for installation like any other plugin. The plugins in this list are maintained (or not) by their respective owners, and certain combinations may be incompatible.\n\n* [Xuyuanp/nerdtree-git-plugin](https://github.com/Xuyuanp/nerdtree-git-plugin): Shows Git status flags for files and folders in NERDTree.\n* [ryanoasis/vim-devicons](https://github.com/ryanoasis/vim-devicons): Adds filetype-specific icons to NERDTree files and folders,\n* [tiagofumo/vim-nerdtree-syntax-highlight](https://github.com/tiagofumo/vim-nerdtree-syntax-highlight): Adds syntax highlighting to NERDTree based on filetype.\n* [scrooloose/nerdtree-project-plugin](https://github.com/scrooloose/nerdtree-project-plugin): Saves and restores the state of the NERDTree between sessions.\n* [PhilRunninger/nerdtree-buffer-ops](https://github.com/PhilRunninger/nerdtree-buffer-ops): 1) Highlights open files in a different color. 2) Closes a buffer directly from NERDTree.\n* [PhilRunninger/nerdtree-visual-selection](https://github.com/PhilRunninger/nerdtree-visual-selection): Enables NERDTree to open, delete, move, or copy multiple Visually-selected files at once.\n\nIf any others should be listed, mention them in an issue or pull request.\n\n\n## Frequently Asked Questions\n\nIn the answers to these questions, you will see code blocks that you can put in your `vimrc` file.\n\n### How can I map a specific key or shortcut to open NERDTree?\n\nNERDTree doesn't create any shortcuts outside of the NERDTree window, so as not to overwrite any of your other shortcuts. Use the `nnoremap` command in your `vimrc`. You, of course, have many keys and NERDTree commands to choose from. Here are but a few examples.\n```vim\nnnoremap \u003cleader\u003en :NERDTreeFocus\u003cCR\u003e\nnnoremap \u003cC-n\u003e :NERDTree\u003cCR\u003e\nnnoremap \u003cC-t\u003e :NERDTreeToggle\u003cCR\u003e\nnnoremap \u003cC-f\u003e :NERDTreeFind\u003cCR\u003e\n```\n\n### How do I open NERDTree automatically when Vim starts?\nEach code block below is slightly different, as described in the `\" Comment lines`.\n\n```vim\n\" Start NERDTree and leave the cursor in it.\nautocmd VimEnter * NERDTree\n```\n---\n```vim\n\" Start NERDTree and put the cursor back in the other window.\nautocmd VimEnter * NERDTree | wincmd p\n```\n---\n```vim\n\" Start NERDTree when Vim is started without file arguments.\nautocmd StdinReadPre * let s:std_in=1\nautocmd VimEnter * if argc() == 0 \u0026\u0026 !exists('s:std_in') | NERDTree | endif\n```\n---\n```vim\n\" Start NERDTree. If a file is specified, move the cursor to its window.\nautocmd StdinReadPre * let s:std_in=1\nautocmd VimEnter * NERDTree | if argc() \u003e 0 || exists(\"s:std_in\") | wincmd p | endif\n```\n---\n```vim\n\" Start NERDTree, unless a file or session is specified, eg. vim -S session_file.vim.\nautocmd StdinReadPre * let s:std_in=1\nautocmd VimEnter * if argc() == 0 \u0026\u0026 !exists('s:std_in') \u0026\u0026 v:this_session == '' | NERDTree | endif\n```\n---\n```vim\n\" Start NERDTree when Vim starts with a directory argument.\nautocmd StdinReadPre * let s:std_in=1\nautocmd VimEnter * if argc() == 1 \u0026\u0026 isdirectory(argv()[0]) \u0026\u0026 !exists('s:std_in') |\n    \\ execute 'NERDTree' argv()[0] | wincmd p | enew | execute 'cd '.argv()[0] | endif\n```\n\n### How can I close Vim or a tab automatically when NERDTree is the last window?\n\nBecause of the changes in how Vim handles its `autocmd` and layout locking `quit` command is no longer available in Vim9 auto commands, Depending on which version you're running select one of these solutions.\n\n__NeoVim users should be able to choose either one of them!__\n\n#### Vim9\n\n```vim\n\" Exit Vim if NERDTree is the only window remaining in the only tab.\nautocmd BufEnter * if tabpagenr('$') == 1 \u0026\u0026 winnr('$') == 1 \u0026\u0026 exists('b:NERDTree') \u0026\u0026 b:NERDTree.isTabTree() | call feedkeys(\":quit\\\u003cCR\u003e:\\\u003cBS\u003e\") | endif\n```\n---\n```vim\n\" Close the tab if NERDTree is the only window remaining in it.\nautocmd BufEnter * if winnr('$') == 1 \u0026\u0026 exists('b:NERDTree') \u0026\u0026 b:NERDTree.isTabTree() | call feedkeys(\":quit\\\u003cCR\u003e:\\\u003cBS\u003e\") | endif\n```\n\n#### Vim8 or older\n\n```vim\n\" Exit Vim if NERDTree is the only window remaining in the only tab.\nautocmd BufEnter * if tabpagenr('$') == 1 \u0026\u0026 winnr('$') == 1 \u0026\u0026 exists('b:NERDTree') \u0026\u0026 b:NERDTree.isTabTree() | quit | endif\n```\n---\n```vim\n\" Close the tab if NERDTree is the only window remaining in it.\nautocmd BufEnter * if winnr('$') == 1 \u0026\u0026 exists('b:NERDTree') \u0026\u0026 b:NERDTree.isTabTree() | quit | endif\n```\n\n### How can I prevent other buffers replacing NERDTree in its window?\n\n```vim\n\" If another buffer tries to replace NERDTree, put it in the other window, and bring back NERDTree.\nautocmd BufEnter * if winnr() == winnr('h') \u0026\u0026 bufname('#') =~ 'NERD_tree_\\d\\+' \u0026\u0026 bufname('%') !~ 'NERD_tree_\\d\\+' \u0026\u0026 winnr('$') \u003e 1 |\n    \\ let buf=bufnr() | buffer# | execute \"normal! \\\u003cC-W\u003ew\" | execute 'buffer'.buf | endif\n```\n\n### Can I have the same NERDTree on every tab automatically?\n\n```vim\n\" Open the existing NERDTree on each new tab.\nautocmd BufWinEnter * if \u0026buftype != 'quickfix' \u0026\u0026 getcmdwintype() == '' | silent NERDTreeMirror | endif\n```\nor change your NERDTree-launching shortcut key like so:\n```vim\n\" Mirror the NERDTree before showing it. This makes it the same on all tabs.\nnnoremap \u003cC-n\u003e :NERDTreeMirror\u003cCR\u003e:NERDTreeFocus\u003cCR\u003e\n```\n\n### How can I change the default arrows?\n\n```vim\nlet g:NERDTreeDirArrowExpandable = '?'\nlet g:NERDTreeDirArrowCollapsible = '?'\n```\nThe preceding values are the non-Windows default arrow symbols. Setting these variables to empty strings will remove the arrows completely and shift the entire tree two character positions to the left. See `:h NERDTreeDirArrowExpandable` for more details.\n\n### How can I show lines of files?\n\n```vim\nlet g:NERDTreeFileLines = 1\n```\n\nLines in the file are displayed as shown below.\n```\n\u003c/pack/packer/start/nerdtree/\n▸ autoload/\n▸ doc/\n▸ lib/\n▸ nerdtree_plugin/\n▸ plugin/\n▸ syntax/\n  _config.yml (1)\n  CHANGELOG.md (307)\n  LICENCE (13)\n  README.markdown (234)\n  screenshot.png (219)\n```\n\n### Can NERDTree access remote files via scp or ftp?\n\nShort answer: No, and there are no plans to add that functionality. However, Vim ships with a plugin that does just that. It's called netrw, and by adding the following lines to your `.vimrc`, you can use it to open files over the `scp:`, `ftp:`, or other protocols, while still using NERDTree for all local files. The function seamlessly makes the decision to open NERDTree or netrw, and other supported protocols can be added to the regular expression.\n\n```vim\n\" Function to open the file or NERDTree or netrw.\n\"   Returns: 1 if either file explorer was opened; otherwise, 0.\nfunction! s:OpenFileOrExplorer(...)\n    if a:0 == 0 || a:1 == ''\n        NERDTree\n    elseif filereadable(a:1)\n        execute 'edit '.a:1\n        return 0\n    elseif a:1 =~? '^\\(scp\\|ftp\\)://' \" Add other protocols as needed.\n        execute 'Vexplore '.a:1\n    elseif isdirectory(a:1)\n        execute 'NERDTree '.a:1\n    endif\n    return 1\nendfunction\n\n\" Auto commands to handle OS commandline arguments\nautocmd StdinReadPre * let s:std_in=1\nautocmd VimEnter * if argc()==1 \u0026\u0026 !exists('s:std_in') | if \u003cSID\u003eOpenFileOrExplorer(argv()[0]) | wincmd p | enew | wincmd p | endif | endif\n\n\" Command to call the OpenFileOrExplorer function.\ncommand! -n=? -complete=file -bar Edit :call \u003cSID\u003eOpenFileOrExplorer('\u003cargs\u003e')\n\n\" Command-mode abbreviation to replace the :edit Vim command.\ncnoreabbrev e Edit\n```\n","funding_links":[],"categories":["Vim script","VimL","Tools","What's in it?","Editor Utilities","Install","Plugins","Basics","Some screenshots","Vim"],"sub_categories":["File Management","vim","Installing","Few Shortcuts","[Vim](http://www.vim.org)","Install for multiple users","Chess :chess_pawn:","Explorer"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscrooloose%2Fnerdtree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscrooloose%2Fnerdtree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscrooloose%2Fnerdtree/lists"}