mirror of
https://github.com/preservim/nerdtree.git
synced 2025-11-09 20:03:48 -05:00
Remove questions already answered in the README.
72
F.A.Q..md
72
F.A.Q..md
@@ -6,81 +6,27 @@ Also you can switch between windows faster by their direction:
|
||||
|
||||
```
|
||||
" Switch between different windows by their direction`
|
||||
no <C-j> <C-w>j| "switching to below window
|
||||
no <C-k> <C-w>k| "switching to above window
|
||||
no <C-l> <C-w>l| "switching to right window
|
||||
no <C-h> <C-w>h| "switching to left window
|
||||
noremap <C-j> <C-w>j
|
||||
noremap <C-k> <C-w>k
|
||||
noremap <C-l> <C-w>l
|
||||
noremap <C-h> <C-w>h
|
||||
```
|
||||
|
||||
Put the above lines in your vimrc, so now you can switch between different windows by their direction easier and faster.
|
||||
|
||||
## What is a buffer, a window, a tab?
|
||||
|
||||
This isn't a NERDTree-specific question, but misunderstanding these Vim "objects" will negatively affect your user experience. Vim is not like other text editors or IDEs, and it shouldn't be made to fit their molds. There is great power in the way Vim handles files (buffers), splits (windows), and layouts (tabs), power that you can't get in other editors. For a better, more in-depth explanation, read the following blog post: http://joshldavis.com/2014/04/05/vim-tab-madness-buffers-vs-tabs/.
|
||||
This isn't a NERDTree-specific question, but misunderstanding these Vim "objects" will negatively affect your user experience. Vim is not like other text editors or IDEs, and it shouldn't be made to fit their molds. There is great power in the way Vim handles files (buffers), splits (windows), and layouts (tabs), power that you can't get in other editors. For an in-depth explanation, read the following blog post: http://joshldavis.com/2014/04/05/vim-tab-madness-buffers-vs-tabs/ or this StackOverflow discussion: http://stackoverflow.com/questions/102384/using-vims-tabs-like-buffers.
|
||||
|
||||
## Is there any support for `git` flags?
|
||||
|
||||
Yes, install [nerdtree-git-plugin](https://github.com/Xuyuanp/nerdtree-git-plugin).
|
||||
|
||||
## Can I have the nerdtree on every tab automatically?
|
||||
|
||||
Nope. If this is something you want then chances are you aren't using tabs and buffers as they were intended to be used. Read this http://stackoverflow.com/questions/102384/using-vims-tabs-like-buffers. If you are interested in this behaviour then consider [vim-nerdtree-tabs](https://github.com/jistr/vim-nerdtree-tabs)
|
||||
|
||||
## How can I open a NERDTree automatically when vim starts up?
|
||||
|
||||
Stick this in your vimrc: `autocmd vimenter * NERDTree`
|
||||
|
||||
## How can I open a NERDTree automatically when vim starts up if no files were specified?
|
||||
|
||||
Stick this in your vimrc:
|
||||
|
||||
autocmd StdinReadPre * let s:std_in=1
|
||||
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
|
||||
|
||||
Note: Now start vim with plain `vim`, not `vim .`
|
||||
|
||||
## How can I open NERDTree automatically when vim starts up on opening a directory?
|
||||
|
||||
autocmd StdinReadPre * let s:std_in=1
|
||||
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | endif
|
||||
|
||||
or
|
||||
|
||||
autocmd StdinReadPre * let s:std_in=1
|
||||
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | wincmd p | ene | exe 'NERDTree' argv()[0] | endif
|
||||
|
||||
The difference between the two is: The first example places the cursor in the empty buffer, while the second example puts it in the NERDTree. This window is tab-specific, meaning it's used by all windows in the tab. This trick also prevents NERDTree from hiding when first selecting a file.
|
||||
|
||||
## How can I map a specific key or shortcut to open NERDTree?
|
||||
|
||||
Stick this in your vimrc to open NERDTree with `Ctrl+n` (you can set whatever key you want):
|
||||
|
||||
map <C-n> :NERDTreeToggle<CR>
|
||||
|
||||
## How can I close vim if the only window left open is a NERDTree?
|
||||
|
||||
Stick this in your vimrc:
|
||||
|
||||
autocmd BufEnter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
|
||||
|
||||
## Can I have different highlighting for different file extensions?
|
||||
|
||||
See here: https://github.com/scrooloose/nerdtree/issues/433#issuecomment-92590696 or https://github.com/tiagofumo/vim-nerdtree-syntax-highlight, referenced in the comment.
|
||||
|
||||
## How can I change default arrows?
|
||||
|
||||
Use these variables in your vimrc. Note that below are default arrow symbols.
|
||||
|
||||
let g:NERDTreeDirArrowExpandable = '▸'
|
||||
let g:NERDTreeDirArrowCollapsible = '▾'
|
||||
|
||||
## How can I open files, directories, and bookmarks in new tabs?
|
||||
|
||||
Use the `t` and `T` mappings in the NERDTree window.
|
||||
|
||||
## How can I close NERDTree window after opening a file in it
|
||||
|
||||
You can define a hotkey for it in your .vimrc file. In the example below the d+<CR> key is defined to do so. This hotkey will be valid only until the NERDTree is closed.
|
||||
|
||||
autocmd BufEnter NERD_tree_* nmap d<CR> <CR> :NERDTreeToggle <CR>
|
||||
autocmd BufLeave NERD_tree_* unmap d<CR>
|
||||
## How can I close NERDTree window after opening a file from it?
|
||||
Use this NERDTree setting: `let NERDTreeQuitOnOpen = 1`. However if you usually want NERDTree to stay open, but sometimes want it to close after opening a file, you can use one of these option.
|
||||
1. Use the NERDTree keys: `go` followed by `q`.
|
||||
1. You can map another key to do `goq` for you: `autocmd FileType nerdtree nmap d goq`
|
||||
Reference in New Issue
Block a user