tags:

views:

704

answers:

3

So I'm basically a beginner when it comes to Vim, nonetheless I do know the basic things (open files, edit, move around, basic grep, .vimrc, etc)

I would submit 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 a link to the home page. I have already gotten NERD_tree installed, so far so good.

Only thing is, this guy (JamisBuck) adds a line to the .vimrc file to streamline it's usage (I'm guessing to toggle 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 in:

:NERDTree

Every time which is less than desirable. The follwing is the code he adds to the .vimrc file:

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

He doesn't explain exactly what is is and/or how to use it, so If someone could give me a short explanation and/or point me towards a resource to learn more about this, that would be appreciated.

+5  A: 

I'd say :help leader will give you what you need, is an anti-slash by default.

Thus, map <leader>d will be launched when you do \d.

mat
I don't understand your summation of your answer, but your actual answer: \dIs the correct answer. Thanks. I would give you an upvote but I don't have enough rep.
rey
+4  A: 

According to the vim documentation, the

<Leader>

Is a special variable that is replaced with the value of "mapleader" at the time the mapping is defined. So:

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

Is mapping the mapleader and "d" to the toggle. If you look at the page you linked, earlier in the page he 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 the toggle should be ",d" as far as I can tell.

Jay
+2  A: 

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

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

Is simply executing the NERDTreeToggle command with the first argument as the current working directory. The at the end is a carriage return, and is just simulating a press of the enter key.

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

Jeremy Cantrell