mirror of
https://github.com/preservim/nerdtree.git
synced 2025-11-08 11:23:48 -05:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9b465acb27 | ||
|
|
09aec2cfca | ||
|
|
fbb71fcd90 | ||
|
|
6ad85ec29b |
@@ -13,6 +13,10 @@
|
||||
- Pull Request Title n (PR Author) [PR Number](Link to PR)
|
||||
-->
|
||||
#### 7.1
|
||||
- **.3**:
|
||||
- docs: update FAQ snippets containing quit command. (rzvxa) [#1417](https://github.com/preservim/nerdtree/pull/1417)
|
||||
- feat: jump to bookmark table shortcut. (ds2606, rzvxa) [#1394](https://github.com/preservim/nerdtree/pull/1394)
|
||||
- fix: typo in docs for show file lines setting. (lothardp) [#1426](https://github.com/preservim/nerdtree/pull/1426)
|
||||
- **.2**:
|
||||
- fix: GetWinNum regex pattern. (rzvxa) [#1409](https://github.com/preservim/nerdtree/pull/1409)
|
||||
- fix: session restore for nerdtree buffers. (rzvxa) [#1405](https://github.com/preservim/nerdtree/pull/1405)
|
||||
|
||||
@@ -150,6 +150,24 @@ autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists('s:std_in
|
||||
|
||||
### 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
|
||||
|
||||
```vim
|
||||
" 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
|
||||
```
|
||||
---
|
||||
```vim
|
||||
" 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
|
||||
|
||||
```vim
|
||||
" 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
|
||||
|
||||
@@ -70,6 +70,7 @@ function! nerdtree#ui_glue#createDefaultBindings() abort
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpRoot, 'scope': 'all', 'callback': s.'jumpToRoot' })
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpNextSibling, 'scope': 'Node', 'callback': s.'jumpToNextSibling' })
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpPrevSibling, 'scope': 'Node', 'callback': s.'jumpToPrevSibling' })
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpBookmarks, 'scope': 'all', 'callback': s.'jumpToBookmarks' })
|
||||
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTab, 'scope': 'Node', 'callback': s . 'openInNewTab' })
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTabSilent, 'scope': 'Node', 'callback': s . 'openInNewTabSilent' })
|
||||
@@ -496,6 +497,21 @@ function! s:jumpToSibling(node, forward) abort
|
||||
call b:NERDTree.ui.centerView()
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:jumpToBookmarks() {{{1
|
||||
" moves the cursor to the bookmark table
|
||||
function! s:jumpToBookmarks() abort
|
||||
try
|
||||
if b:NERDTree.ui.getShowBookmarks()
|
||||
call g:NERDTree.CursorToBookmarkTable()
|
||||
else
|
||||
call b:NERDTree.ui.setShowBookmarks(1)
|
||||
endif
|
||||
catch /^NERDTree/
|
||||
call nerdtree#echoError('Failed to jump to the bookmark table')
|
||||
return
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
" FUNCTION: nerdtree#ui_glue#openBookmark(name) {{{1
|
||||
" Open the Bookmark that has the specified name. This function provides the
|
||||
" implementation for the :OpenBookmark command.
|
||||
|
||||
@@ -1073,7 +1073,7 @@ mapping and is useful for drastically shrinking the tree when you are
|
||||
navigating to a different part of the tree.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*NERDTreeShowFilesLines*
|
||||
*NERDTreeFileLines*
|
||||
Values: 0 or 1.
|
||||
Default: 0.
|
||||
|
||||
@@ -1083,8 +1083,8 @@ file.
|
||||
This setting can be toggled dynamically, per tree, with the |NERDTree-FL|
|
||||
mapping.
|
||||
Use one of the follow lines for this setting: >
|
||||
let NERDTreeShowFilesLines=0
|
||||
let NERDTreeShowFilesLines=1
|
||||
let NERDTreeFileLines=0
|
||||
let NERDTreeFileLines=1
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*NERDTreeShowHidden*
|
||||
|
||||
@@ -62,6 +62,7 @@ function! s:UI._dumpHelp()
|
||||
let help .= "\"\n\" ----------------------------\n"
|
||||
let help .= "\" Bookmark table mappings~\n"
|
||||
let help .= "\" double-click,\n"
|
||||
let help .= '" '. g:NERDTreeMapJumpBookmarks .": jump to bookmark table\n"
|
||||
let help .= '" '. g:NERDTreeMapActivateNode .": open bookmark\n"
|
||||
let help .= '" '. g:NERDTreeMapPreview .": preview file\n"
|
||||
let help .= '" '. g:NERDTreeMapPreview .": find dir in tree\n"
|
||||
@@ -482,10 +483,10 @@ function! s:UI.toggleIgnoreFilter()
|
||||
call self.centerView()
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:UI.toggleShowBookmarks() {{{1
|
||||
" Toggle the visibility of the Bookmark table.
|
||||
function! s:UI.toggleShowBookmarks()
|
||||
let self._showBookmarks = !self._showBookmarks
|
||||
" FUNCTION: s:UI.setShowBookmarks() {{{1
|
||||
" Sets the visibility of the Bookmark table.
|
||||
function! s:UI.setShowBookmarks(value)
|
||||
let self._showBookmarks = a:value
|
||||
|
||||
if self.getShowBookmarks()
|
||||
call self.nerdtree.render()
|
||||
@@ -503,6 +504,12 @@ function! s:UI.toggleShowBookmarks()
|
||||
call self.centerView()
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:UI.toggleShowBookmarks() {{{1
|
||||
" Toggle the visibility of the Bookmark table.
|
||||
function! s:UI.toggleShowBookmarks()
|
||||
call self.setShowBookmarks(!self._showBookmarks)
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:UI.toggleShowFiles() {{{1
|
||||
" toggles the display of hidden files
|
||||
function! s:UI.toggleShowFiles()
|
||||
|
||||
@@ -101,6 +101,7 @@ endif
|
||||
|
||||
"SECTION: Init variable calls for key mappings {{{2
|
||||
let g:NERDTreeMapCustomOpen = get(g:, 'NERDTreeMapCustomOpen', '<CR>')
|
||||
let g:NERDTreeMapJumpBookmarks = get(g:, 'NERDTreeMapJumpBookmarks', 'gb')
|
||||
let g:NERDTreeMapActivateNode = get(g:, 'NERDTreeMapActivateNode', 'o')
|
||||
let g:NERDTreeMapChangeRoot = get(g:, 'NERDTreeMapChangeRoot', 'C')
|
||||
let g:NERDTreeMapChdir = get(g:, 'NERDTreeMapChdir', 'cd')
|
||||
|
||||
Reference in New Issue
Block a user