How to Install and Use Vifm in Linux for a Dual-Pane Vi-Style Terminal File Manager

Navigating dense directory hierarchies, comparing remote directory trees, and executing batch file operations in the Linux terminal often slows down when relying strictly on basic shell commands like cd, ls, and cp. While modern terminal file managers have emerged, developers and system administrators who have already internalised Vi and Vim keybindings often find dual-pane Orthodox File Managers significantly more productive. Vifm is an open-source, dual-pane terminal file manager written in C that maps familiar Vi motions, commands, visual selection modes, and registers directly to filesystem manipulation.

Core Capabilities and Operational Architecture

Vifm blends the two-pane layout of classic tools (like Midnight Commander) with the modal power of Vim:

  • Dual-Pane Synchronisation: Work across two independent filesystem panes simultaneously, allowing rapid cross-directory copying, moving, and diff comparisons.
  • Vim Muscle Memory: Navigate using h, j, k, l, search with /, select visual blocks with v or V, and yank/delete with y and d.
  • Dotfile Configuration: Entirely configured through a single, well-structured ~/.config/vifm/vifmrc file that supports custom keymaps, file association handlers, and colour schemes.
  • Integrated File Previews: Native support for text, syntax-highlighted code, image thumbnails (via Chafa, Überzug, or Sixel), and directory tree previews.
  • FUSE Integration: Mount archives (tar, zip, iso), remote SSH targets (sshfs), or virtual filesystems as transparent directories.

Prerequisites and Package Availability

Vifm is packaged in the official repositories of all major Linux distributions:

  • Ubuntu / Debian / Mint:
    sudo apt update && sudo apt install vifm
  • Fedora / RHEL / AlmaLinux:
    sudo dnf install vifm
  • Arch Linux / Manjaro:
    sudo pacman -S vifm

To ensure rich syntax highlighting and media previews inside Vifm, install optional companion utilities: bat (syntax viewer), tree, and chafa (terminal image renderer).

Launching and Basic Navigation

Start the file manager by entering:

vifm

To open Vifm with specific initial paths loaded into the left and right panes:

vifm /var/log/ /etc/

Essential Navigation Keybindings

  • j / k: Move the cursor down and up through files and directories.
  • l (or Enter): Open directory or launch the associated application for the selected file.
  • h: Move up to the parent directory.
  • Tab: Toggle active focus between the left and right panes.
  • Space: Toggle visual selection tag on the highlighted file.
  • gg / G: Jump instantly to the top and bottom of the directory listing.
  • /pattern: Perform an interactive forward incremental search within the active pane.
  • Ctrl + w + s / v: Split pane horizontally or vertically.

Executing File Operations with Vim Registers

Vifm handles standard file manipulation through Vim-style yanking and putting:

  1. Copying Files: Highlight a file or select multiple items with Space or visual mode (v), then press y to yank. Switch to the opposite pane with Tab, navigate to the target directory, and press p to paste.
  2. Moving Files: Highlight the files, press d to mark them for moving (cutting). Switch to the destination pane and press p.
  3. Deleting Files: Press dd to send a file to Vifm’s trash directory. To permanently remove items without trashing, use the ex command :delete.
  4. Creating Directories: Type :mkdir folder_name and press Enter.
  5. Renaming Files: Press cw to edit the filename inline, or use visual block selection and :rename to batch-rename multiple items in your text editor.

Configuring File Viewers and Custom Commands in vifmrc

Customise Vifm by copying the sample configuration file into your user configuration directory if it is not present:

mkdir -p ~/.config/vifm
cp /usr/share/vifm/vifmrc ~/.config/vifm/vifmrc

Open ~/.config/vifm/vifmrc in your preferred editor. You can define file association rules that dictate which terminal or GUI tools launch when pressing l:

" Use bat for syntax-highlighted code preview
fileviewer *.sh,*.py,*.js,*.rs,*.c,*.cpp bat --style=numbers --color=always %c

" Use glow for Markdown preview
fileviewer *.md glow -s dark %c

" Associate text files with Neovim
filetype *.txt,*.md,*.json,*.yaml,*.yml,*.toml nvim %f

Exiting and Synchronising the Parent Shell

To exit Vifm, press ZZ or type :q. If you want your bash or zsh shell to automatically change its working directory to the directory you were browsing upon exit, add this helper alias to your ~/.bashrc or ~/.zshrc:

vicd() {
    local dst="$(command vifm --choose-dir - "$@")"
    if [ -z "$dst" ]; then
        return 0
    fi
    cd "$dst"
}

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.