NERDTree toggling and keyboard mapping
Asked Answered
M

2

13

I have this line in my .vimrc:

nmap <silent> <Leader>p :NERDTreeToggle<CR>

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?

Macrography answered 17/9, 2009 at 10:45 Comment(1)
the correct line should be nmap <silent> <leader>p :NERDTreeToggle<CR>Macrography
S
37

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.

Sanbo answered 17/9, 2009 at 11:10 Comment(8)
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...Macrography
You need to do the nnoremap because <c-d> is scroll down by default.Sanbo
i changed it to nnoremap <silent> <C-D> :NERDTreeToggle<CR> but it still seems to scroll down when i press ctrl-D?Macrography
:map <c-d> :echo "hello"<CR> does it print hello on <C-d>?Bouchier
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...Macrography
I thought you did all the commands in vim ex-commandline! :)Bouchier
strange, why is the ~/.vim/vimrc file not being used?Macrography
~/.vimrc is the proper file name.Excessive
F
-4

@fcuk122 - try this nmap :NERDTreeToggle I think CTRL + D is already used in system try CRTL + T or any other convenient key and which not used by terminal or VIM. may work for you.

Fremd answered 1/6, 2013 at 13:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.