Top Related Projects
A tree explorer plugin for vim.
fzf :heart: vim
Find, Filter, Preview, Pick. All lua, all the time.
File manager for Neovim. Better than NERDTree.
A file explorer tree for neovim written in lua
Quick Overview
NERDTree is a file system explorer plugin for Vim. It allows users to visually browse complex directory structures, quickly open files for editing, and perform basic file system operations. NERDTree provides an intuitive tree-like view of the file system within Vim, enhancing navigation and file management capabilities.
Pros
- Easy and intuitive file system navigation within Vim
- Customizable appearance and behavior through various options
- Supports bookmarks for quick access to frequently used directories
- Integrates well with other Vim plugins and workflows
Cons
- Can be resource-intensive for very large directory structures
- Learning curve for some advanced features and keyboard shortcuts
- May be redundant for users who prefer command-line file navigation
- Occasional conflicts with other plugins or custom Vim configurations
Getting Started
To install NERDTree using Vim-Plug, add the following line to your .vimrc
:
Plug 'preservim/nerdtree'
Then run :PlugInstall
in Vim.
To open NERDTree, use the command :NERDTree
in Vim. You can also map a key to toggle NERDTree:
nnoremap <leader>n :NERDTreeToggle<CR>
Basic usage:
- Use
j
andk
to navigate up and down - Press
o
to open/close directories or open files - Press
?
for help and to see all available commands
Competitor Comparisons
A tree explorer plugin for vim.
Pros of NERDTree
- Well-established and widely used file explorer plugin for Vim
- Extensive customization options and keybindings
- Large community support and regular updates
Cons of NERDTree
- Can be resource-intensive for large projects
- Learning curve for new users due to numerous features
- May feel cluttered or overwhelming for some users
Code Comparison
NERDTree configuration example:
let g:NERDTreeShowHidden = 1
let g:NERDTreeMinimalUI = 1
let g:NERDTreeIgnore = []
let g:NERDTreeStatusline = ''
Since both repositories refer to the same project, there is no code comparison to be made between them. The code example provided above is a common configuration for NERDTree.
Additional Notes
It's important to note that the comparison requested is between two identical repositories. Both preservim/nerdtree and preservim/nerdtree> refer to the same project, NERDTree. The slight difference in the repository name (with the added ">") appears to be a typo or formatting issue in the question.
NERDTree is a popular file system explorer plugin for the Vim editor. It allows users to efficiently navigate and manage their project files within Vim. The plugin is highly customizable and integrates well with other Vim plugins, making it a staple in many developers' Vim setups.
fzf :heart: vim
Pros of fzf.vim
- Faster and more efficient for searching files and content
- More versatile, offering fuzzy finding for various Vim elements (buffers, tags, etc.)
- Integrates well with the command-line fzf tool for system-wide use
Cons of fzf.vim
- Steeper learning curve, especially for Vim beginners
- Lacks visual file tree representation, which some users prefer for navigation
- Requires additional setup and dependencies (fzf core tool)
Code Comparison
NERDTree (file browsing):
:NERDTree
" Navigate using j/k, open files with Enter
fzf.vim (file searching):
:Files
" Type to fuzzy-search, Enter to open selected file
Summary
NERDTree provides a traditional file explorer interface within Vim, making it intuitive for users familiar with GUI file managers. It's excellent for visualizing project structure but can be slower for large projects.
fzf.vim, on the other hand, offers a powerful fuzzy-finding approach to file navigation and various Vim operations. It's faster and more flexible but requires users to adapt to a different workflow.
The choice between these tools often comes down to personal preference and specific workflow needs. Some users even combine both for a comprehensive file management solution in Vim.
Find, Filter, Preview, Pick. All lua, all the time.
Pros of telescope.nvim
- Highly extensible and customizable fuzzy finder
- Fast and efficient searching across files, buffers, and more
- Integrates well with other Neovim plugins and LSP features
Cons of telescope.nvim
- Steeper learning curve compared to NERDTree's simpler interface
- Requires Neovim 0.5+ and Lua knowledge for advanced configuration
Code Comparison
NERDTree (basic usage):
:NERDTree
telescope.nvim (basic file search):
require('telescope.builtin').find_files()
Key Differences
- NERDTree is primarily a file explorer, while telescope.nvim is a versatile fuzzy finder
- telescope.nvim offers more advanced search capabilities across various sources
- NERDTree provides a traditional tree-like file browser interface
- telescope.nvim relies on Lua for configuration, while NERDTree uses Vimscript
Use Cases
NERDTree is ideal for:
- Users who prefer a traditional file explorer interface
- Quick navigation through project directory structure
telescope.nvim excels at:
- Rapid file searching and opening
- Fuzzy finding across multiple sources (files, buffers, git, etc.)
- Integration with LSP features for code navigation
Both plugins have their strengths, and the choice depends on personal preference and workflow requirements.
File manager for Neovim. Better than NERDTree.
Pros of chadtree
- Faster performance, especially for large directories
- Asynchronous operations for improved responsiveness
- More modern UI with icons and visual enhancements
Cons of chadtree
- Steeper learning curve due to more advanced features
- Less widespread adoption and community support
- Requires Neovim and Python 3.8+, limiting compatibility
Code Comparison
NERDTree:
let g:NERDTreeShowHidden = 1
let g:NERDTreeMinimalUI = 1
let g:NERDTreeIgnore = []
let g:NERDTreeStatusline = ''
chadtree:
let g:chadtree_settings = {
\ 'view.width': 30,
\ 'theme.icon_glyph_set': 'ascii',
\ 'keymap.primary': ['<enter>', 'o'],
\ 'keymap.secondary': ['<c-v>', '<c-x>', '<c-t>'],
}
Both plugins offer customization options, but chadtree provides more granular control over appearance and behavior. NERDTree's configuration is simpler, while chadtree offers more advanced features at the cost of increased complexity.
A file explorer tree for neovim written in lua
Pros of nvim-tree.lua
- Written in Lua, offering better performance and integration with Neovim
- More customizable with a wide range of configuration options
- Actively maintained with frequent updates and new features
Cons of nvim-tree.lua
- Requires Neovim 0.5+ and Lua knowledge for advanced customization
- May have a steeper learning curve for users familiar with NERDTree
- Some users report occasional stability issues with complex setups
Code Comparison
NERDTree (Vimscript):
let g:NERDTreeShowHidden = 1
let g:NERDTreeMinimalUI = 1
let g:NERDTreeIgnore = []
let g:NERDTreeStatusline = ''
nvim-tree.lua (Lua):
require'nvim-tree'.setup {
view = {
width = 30,
hide_root_folder = false,
},
filters = {
dotfiles = true,
},
}
Both plugins offer similar functionality for file tree navigation in Vim/Neovim. NERDTree is a mature, widely-used plugin written in Vimscript, while nvim-tree.lua is a newer, Lua-based alternative specifically designed for Neovim. The choice between them often depends on personal preference, Neovim version, and desired customization level.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
The NERDTree 
Introduction
The 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.
Installation
Use your favorite plugin manager to install this plugin. tpope/vim-pathogen, VundleVim/Vundle.vim, junegunn/vim-plug, and 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. 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.
If 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.
Pathogen
Pathogen 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.- In the terminal,
git clone https://github.com/preservim/nerdtree.git ~/.vim/bundle/nerdtree
- In your
vimrc
,call pathogen#infect() syntax on filetype plugin indent on
- Restart Vim, and run
:helptags ~/.vim/bundle/nerdtree/doc/
or:Helptags
.
Vundle
- Install Vundle, according to its instructions.
- Add the following text to your
vimrc
.call vundle#begin() Plugin 'preservim/nerdtree' call vundle#end()
- Restart Vim, and run the
:PluginInstall
statement to install your plugins.
Vim-Plug
- Install Vim-Plug, according to its instructions.
- Add the following text to your
vimrc
.
call plug#begin()
Plug 'preservim/nerdtree'
call plug#end()
- Restart Vim, and run the
:PlugInstall
statement to install your plugins.
Dein
- Install Dein, according to its instructions.
- Add the following text to your
vimrc
.call dein#begin() call dein#add('preservim/nerdtree') call dein#end()
- Restart Vim, and run the
:call dein#install()
statement to install your plugins.
Vim 8+ packages
If 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:
git clone https://github.com/preservim/nerdtree.git ~/.vim/pack/vendor/start/nerdtree
vim -u NONE -c "helptags ~/.vim/pack/vendor/start/nerdtree/doc" -c q
Getting Started
After 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
.
NERDTree Plugins
NERDTree 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.
- Xuyuanp/nerdtree-git-plugin: Shows Git status flags for files and folders in NERDTree.
- ryanoasis/vim-devicons: Adds filetype-specific icons to NERDTree files and folders,
- tiagofumo/vim-nerdtree-syntax-highlight: Adds syntax highlighting to NERDTree based on filetype.
- scrooloose/nerdtree-project-plugin: Saves and restores the state of the NERDTree between sessions.
- PhilRunninger/nerdtree-buffer-ops: 1) Highlights open files in a different color. 2) Closes a buffer directly from NERDTree.
- PhilRunninger/nerdtree-visual-selection: Enables NERDTree to open, delete, move, or copy multiple Visually-selected files at once.
If any others should be listed, mention them in an issue or pull request.
Frequently Asked Questions
In the answers to these questions, you will see code blocks that you can put in your vimrc
file.
How can I map a specific key or shortcut to open NERDTree?
NERDTree 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.
nnoremap <leader>n :NERDTreeFocus<CR>
nnoremap <C-n> :NERDTree<CR>
nnoremap <C-t> :NERDTreeToggle<CR>
nnoremap <C-f> :NERDTreeFind<CR>
How do I open NERDTree automatically when Vim starts?
Each code block below is slightly different, as described in the " Comment lines
.
" Start NERDTree and leave the cursor in it.
autocmd VimEnter * NERDTree
" Start NERDTree and put the cursor back in the other window.
autocmd VimEnter * NERDTree | wincmd p
" Start NERDTree when Vim is started without file arguments.
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists('s:std_in') | NERDTree | endif
" Start NERDTree. If a file is specified, move the cursor to its window.
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * NERDTree | if argc() > 0 || exists("s:std_in") | wincmd p | endif
" Start NERDTree, unless a file or session is specified, eg. vim -S session_file.vim.
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists('s:std_in') && v:this_session == '' | NERDTree | endif
" Start NERDTree when Vim starts with a directory argument.
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists('s:std_in') |
\ execute 'NERDTree' argv()[0] | wincmd p | enew | execute 'cd '.argv()[0] | endif
How can I close Vim or a tab automatically when NERDTree is the last window?
Because 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.
NeoVim users should be able to choose either one of them!
Vim9
" Exit Vim if NERDTree is the only window remaining in the only tab.
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | call feedkeys(":quit\<CR>:\<BS>") | endif
" Close the tab if NERDTree is the only window remaining in it.
autocmd BufEnter * if winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | call feedkeys(":quit\<CR>:\<BS>") | endif
Vim8 or older
" Exit Vim if NERDTree is the only window remaining in the only tab.
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
" Close the tab if NERDTree is the only window remaining in it.
autocmd BufEnter * if winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
How can I prevent other buffers replacing NERDTree in its window?
" If another buffer tries to replace NERDTree, put it in the other window, and bring back NERDTree.
autocmd BufEnter * if winnr() == winnr('h') && bufname('#') =~ 'NERD_tree_\d\+' && bufname('%') !~ 'NERD_tree_\d\+' && winnr('$') > 1 |
\ let buf=bufnr() | buffer# | execute "normal! \<C-W>w" | execute 'buffer'.buf | endif
Can I have the same NERDTree on every tab automatically?
" Open the existing NERDTree on each new tab.
autocmd BufWinEnter * if &buftype != 'quickfix' && getcmdwintype() == '' | silent NERDTreeMirror | endif
or change your NERDTree-launching shortcut key like so:
" Mirror the NERDTree before showing it. This makes it the same on all tabs.
nnoremap <C-n> :NERDTreeMirror<CR>:NERDTreeFocus<CR>
How can I change the default arrows?
let g:NERDTreeDirArrowExpandable = '?'
let g:NERDTreeDirArrowCollapsible = '?'
The 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.
How can I show lines of files?
let g:NERDTreeFileLines = 1
Lines in the file are displayed as shown below.
</pack/packer/start/nerdtree/
⸠autoload/
⸠doc/
⸠lib/
⸠nerdtree_plugin/
⸠plugin/
⸠syntax/
_config.yml (1)
CHANGELOG.md (307)
LICENCE (13)
README.markdown (234)
screenshot.png (219)
Can NERDTree access remote files via scp or ftp?
Short 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.
" Function to open the file or NERDTree or netrw.
" Returns: 1 if either file explorer was opened; otherwise, 0.
function! s:OpenFileOrExplorer(...)
if a:0 == 0 || a:1 == ''
NERDTree
elseif filereadable(a:1)
execute 'edit '.a:1
return 0
elseif a:1 =~? '^\(scp\|ftp\)://' " Add other protocols as needed.
execute 'Vexplore '.a:1
elseif isdirectory(a:1)
execute 'NERDTree '.a:1
endif
return 1
endfunction
" Auto commands to handle OS commandline arguments
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc()==1 && !exists('s:std_in') | if <SID>OpenFileOrExplorer(argv()[0]) | wincmd p | enew | wincmd p | endif | endif
" Command to call the OpenFileOrExplorer function.
command! -n=? -complete=file -bar Edit :call <SID>OpenFileOrExplorer('<args>')
" Command-mode abbreviation to replace the :edit Vim command.
cnoreabbrev e Edit
Top Related Projects
A tree explorer plugin for vim.
fzf :heart: vim
Find, Filter, Preview, Pick. All lua, all the time.
File manager for Neovim. Better than NERDTree.
A file explorer tree for neovim written in lua
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot