File Management in Vim: filebeagle

In my quest to find the perfect file manager plugin for Vim, I’ve used NerdTree, netrw and vim-vinegar. All of them offer great features and functionality when I needed them, but they also all had minor drawbacks that wound up getting in my way when I wasn’t using them. What I’ve come to at this point is yet another plugin called filebeagle. Install it through whatever plugin management system you happen to use. You’ll probably also want to remove or disable NERDTree or vim-vinegar if you have either of those currently installed.

filebeagle sets up two launch shortcuts: - works exactly like vim-vinegar, opening the filebeagle UI to the directory of the file in the current buffer, while <Leader>f opens it up in the local directory where Vim was launched.

Once launched, the UI you get is very similar to netrw or vim-vinegar. It takes over the current window and offers you a list of the current files in the directory it was opened in. You can navigate and search just like the other plugins we’ve looked at, and open files in the current window, or splits, or tabs or as previews, etc.

filebeagle’s UI is probably a bit more minimal than the others we’ve looked at. But that works for me. It also doesn’t have quite as many features. You can create a new file in the current directory with + (creates an actual file) or % (just creates a new buffer that you’ll have to save to create a file). But it doesn’t offer file deletion, moving, renaming, etc. If you need those features, you might want to go with one of the other solutions.

For me, this more minimal functionality is acceptable. However, I did figure out a way to add some basic delete and move/rename functionality. filebeagle offers a command: :ClipPathname. This copies the full path of the file your cursor is on into the + register. You can then open a command line and paste it back in to an rm or mv command. Or, use these mappings:

1
2
nnoremap bd :ClipPathname<CR>:!rm <C-r>+
nnoremap bm :ClipPathname<CR>:!mv <C-r>+ <C-r>+

I used bd and bm. Think “beagle delete” and “beagle move”. But feel free to use whatever you want. Both of these end with the command line open for you to confirm the delete by hitting enter, or change the name or path of the file in the case of mv.

Sadly, the filebeagle UI doesn’t instantly update after one of these actions, but you can refresh it by hitting R.

What I really like about filebeagle though is that unlike netrw and vinegar, when I choose a file or just close the UI (using the q key), filebeagle goes away completely. It doesn’t hang around in an uncloseable buffer to annoy me for the rest of the session.

To see all of filebeagle’s options, type :help filebeagle.

Dirvish

There’s one more file management plugin I wanted to mention. I’s called dirvish. This is pretty similar to filebeagle, but with a few more advanced features. In fact, it was originally forked from filebeagle, but eventually completely re-written, according to the author. I haven’t used it extensively, but it definitely does a lot more than filebeagle. It was a bit more than what I needed, but if you’re looking to do more advanced file management from within Vim, this could be a good fit for you.

Update

I figured a workaround for the issues I was having with netrw and vinegar-vim. You can find that in this article. With that workaround in place, I find that plain vanilla netrw works really well for me and that’s what I’m currently using.