Reputation: 1469
I'd like to create an abbreviation for NERDTree on the command-line. I find it annoying have to write :NERDTree
every time I want to enable it. So I'd like to type :nr
or something like that. Is that possible?
Upvotes: 46
Views: 37581
Reputation: 1
.vimrc:
let mapleader = "n" #nerdtree
nmap <leader> :NERDTreeFocus<cr>
let mapleader = "f" #focus
nmap <leader> :NERDTreeToggle<cr>
.bash_profile:
alias n="vim -c 'NERDTree'"
Upvotes: 0
Reputation: 37
add to your rc file (.bashrc / .zshrc) this shortcut
alias nerd="nvim -c \"NERDTree\""
then, reload your bash width
source ~/.zshrc # or ~/.bashrc according your case
and run
nerd
the -c flag allows you to execute a command when starting the terminal
nvim -c "command"
Upvotes: 0
Reputation: 22680
I find this works very nicely, better than any other suggestions I've tried:
map <silent> <C-n> :NERDTreeFocus<CR>
You just hit control-n to go back to the hierarchy. Selecting a file name in the hierarchy will switch you, of course, to that file.
:NERDTree
command starts you from scratch, closing the hierarchy, while using :NERDTreeFocus
simply moves the focus, which I think is what you want)Upvotes: 31
Reputation: 9318
In my .vimrc
I have:
let mapleader = ","
nmap <leader>ne :NERDTree<cr>
So when I need NERDTree I just write ,ne
in normal mode.
Upvotes: 58