Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm currently using NERDTree for browsing directories within Vim. One thing I miss from heftier IDEs (e.g. Eclipse) is the ability to browse in a flattened or "package" view of the directory structure, particularly when browsing Java or Python packages (for example).

This:

com.foo.bar
com.foo.baz

Instead of this:

com/
  foo/
    bar/
    baz/

You can quickly get to any node that contains source without navigating the entire path to that source.

Anyone aware of a plugin or other way to accomplish this?

share|improve this question

2 Answers 2

Take a look at the Command-T plugin:

https://wincent.com/products/command-t

Here's the description from the developer:

The Command-T plug-in for VIM provides an extremely fast,
intuitive mechanism for opening files with a minimal number
of keystrokes. It's named "Command-T" because it is inspired
by the "Go to File" window bound to Command-T in TextMate.

Files are selected by typing characters that appear in their
paths, and are ordered by an algorithm which knows that
characters that appear in certain locations (for example,
immediately after a path separator) should be given more weight.

As you browse, files are presented in a flattened list, with full pathnames relative to the current directory:

Surface.java
TextureChooser.java
Tools.java
demos/Arcs_Curves/Arcs.java
demos/Arcs_Curves/BezierAnim.java
demos/Arcs_Curves/Curves.java
demos/Arcs_Curves/Ellipses.java
demos/Clipping/Areas.java
demos/Clipping/ClipAnim.java
demos/Clipping/Intersection.java
demos/Clipping/Text.java
demos/Colors/BullsEye.java
demos/Colors/ColorConvert.java
demos/Colors/Rotator3D.java
demos/Composite/ACimages.java
demos/Composite/ACrules.java

To narrow the list of files, type characters from anywhere in the pathname. For example, dcb or bul are enough to specify demos/Colors/BullsEye.java.

Once you've typed enough of the pathname to find the file you want, just hit Enter to load it. (You don't have to get all the way to a single file; once you're close, you can use the arrow keys to select the one you want.)

Anyway, it's not exactly what you described, but it might be exactly what you want. :-)

share|improve this answer
    
I have installed this and am playing around with it. Will let you know what I think. I've already found myself trying to j,k to navigate the file listing. Colorsjjjjj, doh! –  Joe Holloway Jul 7 '10 at 18:00
    
You'll be happy to learn that the plugin provides Control+J / Control+K for this very reason. :-) –  Bill Odom Jul 8 '10 at 19:14

edit

my apologies for an original answer that was completely incorrect. This revised version is much more possessed of logic.

You could do

:new
:r !find -type d

and then put the cursor on the directory you're interested in and hit ^W-F to get a netrw window on that directory.

This is going to give you a listing of all directories, including ones that have subdirectories, though. It sounds like you just want to see the directories that don't have subdirectories.

So to filter it so it just shows 'leaf nodes', you could pipe it into another command. I suspect that there's a better way, but this should do it:

:r !find -type d | while read d; do if (( $(find "$d" -mindepth 1 -maxdepth 1 -type d | wc -l) == 0 )); then echo "$d"; fi; done

Basically it just goes through all subdirectories, and prints the ones that themselves do not have subdirectories. This is a pretty inefficient way to do this, but it should get you what (I think) you want.

I've never used NERDTree, so I can't tell you how that would integrate with it.. but that's how I'd do that. If you're using Windows, please disregard this advice.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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