Sitemap
Press enter or click to view image in full size

How to Turn VIFM into a Full-Fledged File Explorer

4 min readJan 10, 2023

--

Vifm is a terminal file manager for linux that relies heavily on vim-like keybindings. Overall it is quite fast and feature-full, making it a prominent choice among minimalist users. Below I mention some steps I have taken to make it more useful.

Most of these require modifying only the VIFM config file. A good place to find/create such a file is ~/.config/vifm/vifmrc. If this file already exists on your machine, create a backup of the file, because we will be editing it. Now delete all contents from the original file (not the backup), and start with an empty vifmrc file. If you do not have such a file at that location, create an empty file with that name.

Coloured file/folder preview and suggestions

VIFM, by default, has a left pane and a right pane. I have found that it is best to use the left pane as the standard file browser, and the right panel as a preview for the file/folder currently under the cursor. That is enable by the following command:

This runs at startup and forces VIFM to use the right panel for preview. The second command tells VIFM to use the man command for preview text files. We can improve this by introducing multiple colours in the folder preview.

The two commands together instruct VIFM to use the shell command ls --color=always as a folder previewer. The resultant view is shown in the image below.

Press enter or click to view image in full size

Using tabs more efficiently

We often find it convenient to work simultaneously with multiple directories/views. This is where tabs become useful; you can have your work folder open in one tab and your downloads folder open in another tab, and copy files easily from one to the other. In order to make this process easy, insert the following lines in your vimrc.

The mappings, respectively, mean that you can use CTRL+t to create a new tab, H to switch to the tab on the left, L to switch to the tab on the right, and Q to close to the current tab.

Trash folder for safer deletion

For safer delete operators, we enable the trash setting and set a trash folder.

If the folder mentioned in the last setting does not exist, you have to create it. Once this is done, any file/folder that is deleted using the default dd keybinding actually goes into the trash folder, and can be restored later. Permanent deletion can be performed through the more distant keybinding DD, to ensure that it does not happen accidentally. We can also remove the confirmation dialog that appears whenever we want to trash/delete a file.

Customise the statusline

The bottom of the VIFM window shows a statusline where various pieces of information can be displayed. I prefer a simplistic status, where I show the filename at the left end (%t), the current file size (%20s) after that, then the file modification date (%-30d), and finally the remaining storage on the file-system (%a). The numbers represent the width of the blocks.

The format of the modification date can be set in the following way:

The resultant statusline is shown in the image below.

Press enter or click to view image in full size

Marks can be used as favourite folders to reach them quickly. They are defined in the following manner:

Inserting these lines into the vifmrc defines three marks corresponding to the three specified folders. Upon starting vifm, you can now press, say, '+d to change into the Downloads folder. Same holds for the other marks. This provides a very fast method of accessing commonly used folders.

Fuzzy search using fzf

It is easier to search files using a fuzzy finder like fzf. After installing the fzf binary (look up how you can do this in your specific distribution), fuzzy finding can be integrated into VIFM using the following lines:

The above search is triggered by the keybinding /. It lists all files in the present directory and further down in the subdirectories and allows searching according to the provided prompt. The file that is selected (by pressing Enter) is executed.

Creating new files and folders

The first command below sets t as the key to wait for a filename, and then creates an empty file with the name on pressing enter. The second command similarly does the same for a new folder, but with the key M.

The directory creation is shown in the image below (notice the :mkdir at the bottom).

Press enter or click to view image in full size

Starting a shell or a terminal

S starts a shell in the current directory. ALT+t spawns a new terminal by executing the environment variable $TERMINAL. Since I use the simple terminal st, mine is set to TERMINAL=st in my .bashrc file. A spawned terminal is shown in the image below.

Press enter or click to view image in full size

There are more.

To see the complete post, visit my website. Hope you enjoyed it.

Originally published at https://abhirup-m.github.io on January 10, 2023.

--

--

Abhirup Mukherjee
Abhirup Mukherjee

Written by Abhirup Mukherjee

Graduate student at IISER Kolkata. I work on theoretical physics. Interested in anime, free/open-source software and programming . https://abhirup-m.github.io/