4

I wonder how folks navigate efficiently with in a nerdtree window, for example if I'm in a folder like this:

├── m1.py
├── m1.pyc
├── m2.py
├── m2.py.bak
├── m2.pyc
├── main.py
├── matplotdemo.py
├── phonecount.py
├── haha
├── helloworld
│   ├── someothercode.py
│   └── source
│       └── somecode.py
├── images_stat_20150120.tsv

If I'm going to helloworld/source/somecode.py, I would have to jjjj...jjjjojjoj to get there, which is extremely tiring.

and I can't even use the easymotion plugin inside nerdtree, so how can I have some efficiency when using nerdtree?

5

I usually use a combination of j and the / search (with the incsearch setting enabled) to jump to where I want to be. In your example, I probably would have done something like /hello<enter><enter>/sou/<enter><enter>j<enter>. One thing I really like about this method is that I can search for any substring. Some of my directories have multiple files with the same prefix, so it's nice being able to just type in the meat of the file name and jump straight to it.

It never occurred to me until I was typing that out just now how many times I have to hit <enter> and /, but when I'm actually doing it, it doesn't seem so bothersome.

You can also use the same navigation movements as when navigating a normal document, so if you are in a directory with a lot of files you could use ctrl-f and ctrl-b to jump forward and backward a page and gg and G to jump to the top and bottom of the listing.

1

and I can't even use the easymotion plugin inside nerdtree, so how can I have some efficiency when using nerdtree?

You navigate that listing exactly like you navigate in any buffer: with /?*#HLM and any other adequate motion. Beware plugin addiction.

I don't use mouse, that's not vim.

Who said so?

0

Well, I did somewhat of very nice overkill. I have written code such that when you get to a wanted folder, you simply press alt-right and it expands the folder (on top) and opens a new search. So I keep searching the wanted folder name in wanted level. I can also press O (expand all) and look for it under the folder.

To collapse, alt-left.

Hope you find it useful!

function! DoOpen()
    let node = g:NERDTreeFileNode.GetSelected()
    if node.path.isDirectory && (node.isOpen==0) 
        execute "norm \<CR>ztj"
    endif   
endfunction
" other
"To use for consecutive searches. Saves the need to enter search seperately
"each time. TODO: only on file xzt  
:autocmd FileType nerdtree cmap <buffer> <M-Right> <CR>:call DoOpen()<CR>/
:autocmd FileType nerdtree cmap <buffer> <M-left> <CR>x
:autocmd FileType nerdtree nmap <buffer> <M-Right> :call DoOpen()<CR>/
:autocmd FileType nerdtree nmap <buffer> <M-left> x

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.