commit 0a16b24268cb0b597fd8ac815d0baf05d54ff560
parent a1433c485eb254838c1db52e087d5ec4d1e77cfd
Author: ZeusTheTrueGod <l-2732@yandex.ru>
Date: Sun, 26 Aug 2012 08:51:26 +0000
Better flow for renaming and deleting files
Previously when you delete or moved a file via
md or mm commands the NERDTree was asking you about what to do
with the remaining buffer of the just deleted or moved file. I
always press 'y' in this cases so I've decided to add a new parameter,
NERDTreeAutoDeleteBuffer which you can set to 1 in order to skip
this confirmation.
Diffstat:
2 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt
@@ -658,6 +658,10 @@ NERD tree. These options should be set in your vimrc.
Casade open while selected directory has only
one child that also is a directory.
+|'NERDTreeAutoDeleteBuffer'| Tells the NERD tree to automatically remove
+ a buffer when a file is being deleted or renamed
+ via a context menu command.
+
------------------------------------------------------------------------------
3.2. Customisation details *NERDTreeOptionDetails*
@@ -982,6 +986,20 @@ for Java projects. Use one of the follow lines to set this option: >
let NERDTreeCasadeOpenSingleChildDir=1
<
+------------------------------------------------------------------------------
+ *'NERDTreeAutoDeleteBuffer'*
+Values: 0 or 1
+Default: 0.
+
+When using a context menu to delete or rename a file you may also want to delete
+the buffer which is no more valid. If the option is not set you will see a
+confirmation if you really want to delete an old buffer. If you always press 'y'
+then it worths to set this option to 1. Use one of the follow lines to set this
+option: >
+ let NERDTreeAutoDeleteBuffer=0
+ let NERDTreeAutoDeleteBuffer=1
+<
+
==============================================================================
4. The NERD tree API *NERDTreeAPI*
diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim
@@ -15,6 +15,11 @@ if exists("g:loaded_nerdtree_fs_menu")
endif
let g:loaded_nerdtree_fs_menu = 1
+"Automatically delete the buffer after deleting or renaming a file
+if !exists("g:NERDTreeAutoDeleteBuffer")
+ let g:NERDTreeAutoDeleteBuffer = 0
+endif
+
call NERDTreeAddMenuItem({'text': '(a)dd a childnode', 'shortcut': 'a', 'callback': 'NERDTreeAddNode'})
call NERDTreeAddMenuItem({'text': '(m)ove the current node', 'shortcut': 'm', 'callback': 'NERDTreeMoveNode'})
call NERDTreeAddMenuItem({'text': '(d)elete the current node', 'shortcut': 'd', 'callback': 'NERDTreeDeleteNode'})
@@ -52,11 +57,10 @@ endfunction
" del the buffer
function! s:promptToDelBuffer(bufnum, msg)
echo a:msg
- if nr2char(getchar()) ==# 'y'
+ if g:NERDTreeAutoDeleteBuffer || nr2char(getchar()) ==# 'y'
exec "silent bdelete! " . a:bufnum
endif
endfunction
-
"FUNCTION: NERDTreeAddNode(){{{1
function! NERDTreeAddNode()
let curDirNode = g:NERDTreeDirNode.GetSelected()