Running directories with the VCSCommand plugin when using the NERD tree

I am using vim 7.3, the NERDTree 4.1 plugin and VCSCommand version 1.99.42.

To commit a directory to VCSCommand, you need to open the directory buffer (it is the same with all the commands in the directories), however, whenever I try to open the directory buffer with the NERD Tree plugin installed, it refers to the buffer as Nerd_tree_ * and not the name of the directory, which I need to do for the appropriate commit.

How can I prevent this? How to open a standard directory buffer with the NERD tree installed? How to switch NERD Tree periodically to execute a command?

Note. I am aware of this question https://stackoverflow.com/a/16626632/2326328 where the developer says that he disabled the NERD Tree plugin because he used Command-T as a file explorer, but I would like to continue to use NERD Tree, no references to disabling the NERD tree in the help.

+4
source share
3 answers

There is a solution, but it requires some encoding.

You need to update the netrw and NERDTree plugins using the on / off interface.

I create this meaning for you with two files that need to be changed. The files themselves are also attached.

  • netrwPlugin.vim is located in the vim installation directory.
  • NERD_tree should be in the ~ / .vim / plugin directory (if you are not using pathogen ).

With this change you can use

call DisableNERDTree() 

to disable NERD and force vim to use netrw (it is controlled by the source file) and

 call HijackNERTW() 

To restore NERDTree again.

Of course, you also call functions before and after the corresponding VCS command, either using your own wrapper functions or by changing the VCS itself.

Hope this helps.

Edit 2011-03-17:

Calling these functions manually works well. I.e:

  • you call call DisableNERDTree()
  • then you are editing the folder
  • then you use the vcs command
  • and finally call HijackNERTW()

I updated the patch so that these functions can be used in an automatic way. DisableNERDTree() now changes the directory to the one that opens. For instance:.

 fun! NewVCSadd() call DisableNERDTree() :e . "start netrw :VCSAdd<CR> call HijackNERTW() :e . "start NERDTree endfunction 
+3
source

I use a simple combination: When I plan a recursive Diff or a recursive Commit - I run the command: Hexplore, which opens netrw in a split window, go to the directory you want and run: VCSCommit or: VCSDiff. This is a simple fix without additional changes or complex manipulations :).

+1
source

Devemouse changes and examples allowed me to build the following 2 wrapper functions that execute the VCS command and then return vim to its previous state

 " ------------------ Functions ------------------------------ " Wrapper function for VCSAdd to enable it to work with Nerd tree fun! NewVCSAdd() call DisableNERDTree() edit . "start netrw execute 'VCSAdd' call HijackNERTW() quit " quit add windows quit " quit out of netrw-NerdTree window (we want it pure) NERDTree . endfunction " Wrapper function for VCSCommit to enable it to work with Nerd tree fun! NewVCSCommit(comment) call DisableNERDTree() edit . "start netrw execute 'VCSCommit ' . a:comment call HijackNERTW() quit " quit commit windows quit " quit out of netrw-NerdTree window (we want it pure) NERDTree . endfunction 
0
source

Source: https://habr.com/ru/post/1343060/


All Articles