1 Star 0 Fork 0

山鹰 / nerdtree

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
WTFPL

The NERDTree Vint

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.

NERDTree Screenshot

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.
  1. In the terminal,
    git clone https://github.com/preservim/nerdtree.git ~/.vim/bundle/nerdtree
  2. In your vimrc,
    call pathogen#infect()
    syntax on
    filetype plugin indent on
  3. Restart Vim, and run :helptags ~/.vim/bundle/nerdtree/doc/ or :Helptags.
Vundle
  1. Install Vundle, according to its instructions.
  2. Add the following text to your vimrc.
    call vundle#begin()
      Plugin 'preservim/nerdtree'
    call vundle#end()
  3. Restart Vim, and run the :PluginInstall statement to install your plugins.
Vim-Plug
  1. Install Vim-Plug, according to its instructions.
  2. Add the following text to your vimrc.
call plug#begin()
  Plug 'preservim/nerdtree'
call plug#end()
  1. Restart Vim, and run the :PlugInstall statement to install your plugins.
Dein
  1. Install Dein, according to its instructions.
  2. Add the following text to your vimrc.
    call dein#begin()
      call dein#add('preservim/nerdtree')
    call dein#end()
  3. 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 and 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.

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 automatically when NERDTree is the last window?

" Exit Vim if NERDTree is the only window left.
autocmd BufEnter * if tabpagenr('$') == 1 && 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 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 * silent NERDTreeMirror

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.

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE Version 2, December 2004 Copyright (C) 2004 Sam Hocevar <sam@hocevar.net> Everyone is permitted to copy and distribute verbatim or modified copies of this license document, and changing it is allowed as long as the name is changed. DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. You just DO WHAT THE FUCK YOU WANT TO.

简介

暂无描述 展开 收起
Vim script
WTFPL
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/shanying/nerdtree.git
git@gitee.com:shanying/nerdtree.git
shanying
nerdtree
nerdtree
master

搜索帮助