Vim: plugin NERD_tree. Need help understanding bloggers .vimrc addon to optimize this plugin

So, I'm basically a newbie when it comes to Vim, however I know basic things (open files, editing, moving, basic grep, .vimrc, etc.)

I would post this link first

http://weblog.jamisbuck.org/2008/11/17/vim-follow-up

If you scroll down to where it says "NERD___tree" it explains what it is and gives you a link to the home page. I have already installed NERD_tree, how good it is.

The only thing is, this guy (JamisBuck) adds a line to the .vimrc file to make it easier to use (I'm guessing I'm switching between NERD_tree and the actual file, because as far as I can tell, there is no quick way to do it other than typing:

:NERDTree

      

Every time it is less desirable. The following is the code it adds to the .vimrc file:

map <leader>d :execute 'NERDTreeToggle ' . getcwd()<CR>

      

It doesn't explain exactly what is and / or how to use it, so if someone can give me a short explanation and / or point me to a resource to find out more about it, that would be appreciated.

+1


source to share


3 answers


I would say that :help leader

will give you what you need, the default is anti-slash.



Thus, it map <leader>d

will be launched when you do \d

.

+5


source


According to the vim documentation ,

<Leader>

      

This is a special variable that is replaced by the "mapleader" value when defining the map. So:

map <leader>d :execute 'NERDTreeToggle ' . getcwd()<CR>

      



Displays mapleader and "d" to switch. If you look at the page you linked, on the previous page it says:

I’ve got my <Leader> character (:h mapleader) mapped to the comma 
(since it’s easier to reach than the backspace character).

let mapleader = ","

      

So, as far as I can tell, the switch should be ", d".

+5


source


In addition to what others have said (d mapped to command), the command itself is:

:execute 'NERDTreeToggle ' . getcwd()<CR>

      

It just runs the NERDTreeToggle command with the first argument as the current working directory. At the end it is a carriage return and just simulates pressing the enter key.

This means that when the NERD tree is opened, it will be in the current working directory.

+4


source







All Articles