Browse Source

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.
ZeusTheTrueGod 6 years ago
parent
commit
0a16b24268
2 changed files with 24 additions and 2 deletions
  1. 18
    0
      doc/NERD_tree.txt
  2. 6
    2
      nerdtree_plugin/fs_menu.vim

+ 18
- 0
doc/NERD_tree.txt View File

@@ -658,6 +658,10 @@ NERD tree. These options should be set in your vimrc.
658 658
                                 Casade open while selected directory has only
659 659
                                 one child that also is a directory.
660 660
 
661
+|'NERDTreeAutoDeleteBuffer'|    Tells the NERD tree to automatically remove 
662
+                                a buffer when a file is being deleted or renamed
663
+                                via a context menu command.
664
+
661 665
 ------------------------------------------------------------------------------
662 666
 3.2. Customisation details                             *NERDTreeOptionDetails*
663 667
 
@@ -982,6 +986,20 @@ for Java projects.  Use one of the follow lines to set this option: >
982 986
     let NERDTreeCasadeOpenSingleChildDir=1
983 987
 <
984 988
 
989
+------------------------------------------------------------------------------
990
+                                          *'NERDTreeAutoDeleteBuffer'*
991
+Values: 0 or 1
992
+Default: 0.
993
+
994
+When using a context menu to delete or rename a file you may also want to delete
995
+the buffer which is no more valid. If the option is not set you will see a
996
+confirmation if you really want to delete an old buffer. If you always press 'y'
997
+then it worths to set this option to 1. Use one of the follow lines to set this
998
+option: >
999
+    let NERDTreeAutoDeleteBuffer=0
1000
+    let NERDTreeAutoDeleteBuffer=1
1001
+<
1002
+
985 1003
 ==============================================================================
986 1004
 4. The NERD tree API                                             *NERDTreeAPI*
987 1005
 

+ 6
- 2
nerdtree_plugin/fs_menu.vim View File

@@ -15,6 +15,11 @@ if exists("g:loaded_nerdtree_fs_menu")
15 15
 endif
16 16
 let g:loaded_nerdtree_fs_menu = 1
17 17
 
18
+"Automatically delete the buffer after deleting or renaming a file
19
+if !exists("g:NERDTreeAutoDeleteBuffer")
20
+    let g:NERDTreeAutoDeleteBuffer = 0
21
+endif
22
+
18 23
 call NERDTreeAddMenuItem({'text': '(a)dd a childnode', 'shortcut': 'a', 'callback': 'NERDTreeAddNode'})
19 24
 call NERDTreeAddMenuItem({'text': '(m)ove the current node', 'shortcut': 'm', 'callback': 'NERDTreeMoveNode'})
20 25
 call NERDTreeAddMenuItem({'text': '(d)elete the current node', 'shortcut': 'd', 'callback': 'NERDTreeDeleteNode'})
@@ -52,11 +57,10 @@ endfunction
52 57
 "     del the buffer
53 58
 function! s:promptToDelBuffer(bufnum, msg)
54 59
     echo a:msg
55
-    if nr2char(getchar()) ==# 'y'
60
+    if g:NERDTreeAutoDeleteBuffer || nr2char(getchar()) ==# 'y'
56 61
         exec "silent bdelete! " . a:bufnum
57 62
     endif
58 63
 endfunction
59
-
60 64
 "FUNCTION: NERDTreeAddNode(){{{1
61 65
 function! NERDTreeAddNode()
62 66
     let curDirNode = g:NERDTreeDirNode.GetSelected()

Loading…
Cancel
Save