Sometimes, when working in a project, we need to keep the entire directory structure visible. That's why, most text editors or IDEs come with a tree explorer built-in, except for some terminal based editors like Vim, Neovim, Emacs etc. However, they are flexible enough so that anyone can create a plugin like NERDTree to implement a tree view that's more flexible than any built-in implementation would be.
But what if you want a tree-view in your favorite file explorer as well? Some GUI file explorer like macOS's Finder, or KDE's Dolphin, and TUI explorers like broot implements tree view in their own way. But is it possible to implement a tree view in xplr?
xplr, being a file system explorer, is already a tree explorer. It's just that we only see the contents of the current directory, while the contents of the neighboring directories are hidden. If we could somehow "un-hide" them, we got a tree view.
And this is exactly what I did. As a result, we actually got a tree view, without changing anything about how xplr works. You can use the same set of key bindings to navigate your file system you normally use. But, in addition, you also get:
o to toggle the expansion of a directory.
O to toggle expansion of all the directories under the present working directory.
backspace to do a clean exit, i.e. close all, back, and close.
] to navigate up, down across directories without needing to use
) to quickly navigate between the deep level directories.
Moreover, you can use the
esc key to toggle between the default view and tree view whenever required.
Sometimes the tree-view can be really inefficient inside a directory with large number of files and directories. In that case, you need to toggle back to the default view. Additionally, you can set the
fallback_threshold field to some number (e.g. 500) to let xplr automatically fall back to the layout mentioned in
fallback_layout which is by default set to
true if you want to always start xplr with tree view layout.
true if you want to treat it as the default layout, which disables the manual toggling between default and tree view.
This plugin also supports vroot, a special concept in xplr, that lets you treat a directory as the project root, isolating your navigation inside that directory only. Use
:vv to toggle vroot.
You can also use this plugin in combination with other layout plugins for more flexibility.
So, go ahead and give it a try to see if the simplistic default view of xplr was holding you back all this time.