tags:

views:

889

answers:

1

i have this line in my vimrc:

nmap p :NERDTreeToggle

so what is the hotkey for toggling NERDTree?

how do i remap it to CTRL-D?

what is the difference between nmap, map, nnoremap, inoremap, etc?

thanks.

+3  A: 

to remap in normal mode use

nmap <silent> <C-D> :NERDTreeToggle<CR>

nmap means map in normal mode
imap means map in insert mode

the nore part in nnoremap and its friends prevent expanding the mapping recursively. For example, i use to also hide search string so, in my vimrc I have

nnoremap <silent> <C-L> :noh<CR><C-L>

Without the nore, the above mapping will loop.

Ayman
i tried both nmap <silent> <C-D> :NERDTreeToggle<CR> and nmap <silent> <c-d> :NERDTreeToggle<CR> but when i press CTRL-D it seems to scroll down about 33 lines...
fcuk112
You need to do the nnoremap because <c-d> is scroll down by default.
Ayman
i changed it to nnoremap <silent> <C-D> :NERDTreeToggle<CR> but it still seems to scroll down when i press ctrl-D?
fcuk112
:map <c-d> :echo "hello"<CR> does it print hello on <C-d>?
Maxim Kim
no, it scrolls down about 33 lines as before.
fcuk112
i found that it does work if i put the entry in /etc/vim/vimrc. it does not work if i put it in ~/.vim/vimrc...
fcuk112
I *thought* you did all the commands in vim ex-commandline! :)
Maxim Kim
strange, why is the ~/.vim/vimrc file not being used?
fcuk112