The Question Mark - blog by Mark Volkmann

Vifm

Overview

Vifm is a terminal-based file manager that uses Vim keybindings and is implemented in C. It is similar to Ranger, but is more heavily based on Vim.

For documentation see the Manual.

For key bindings see the Cheatsheet.

For color schemes see the Color Schemes.

Installing

See the “Download link” at the bottom of the home page for downloading the source or Windows executables.

To install Vifm in macOS, install Homebrew and enter brew install vifm.

Launching

To start Vifm, enter vifm.

The current directory is identified in the top line. A status bar at the bottom displays information about the file or directory under the cursor. This includes the read/write/execute permissions, owner:group, size, and last modified date and time.

Vifm displays two panes by default that are views of two directories. This makes it easy to copy and move files between directories. These directories can be specified as command-line arguments with vifm is started. If they are not specified, it starts with both panes showing the current directory. However, Vifm remembers the last directory visited in each pane and restores these in subsequent sessions. To force starting in the current directory, start with vifm ..

To exit Vifm, enter :q just like quitting Vim.

Help

For help, enter :help or just :h.

To open help and scroll to a specific command, enter :help command.

To exit help, enter :q.

DirectionKeys
next item in current directoryj or down arrow
previous item in current directoryk or up arrow
into child directoryl or right arrow or enter
into parent directoryh or left arrow

To open the item the cursor, press l, the right arrow, or return. Text files are displayed in the right column. Non-text files are opened by their default application. For example, in macOS image files are opened in the Preview app.

TODO: I tried to configure Nushell to use Preview app for images. TODO: I also tried to configure vifm to use imgcat. TODO: This works iTerm2, but not in tmux. There is issues file for this.

Functionality

To open the file under the cursor, press the return key. Text files are opened in Vim.

Commands

Vifm commands can entered by pressing : which opens a line at the bottom for typing a command just like in Vim.

Common tasks are described in the table below. The term “item” refers to a file or directory, often the one under the cursor.

TaskKey BindingNotes
bookmark - create:bmark namecreates bookmark for current directory
bookmark - list:bmarksbookmark for current directory
bookmark - go:bmgo name
directory - change:cd pathcan use environment variables in path
directory - create:mkdir name
file - create:touch name
file - editenter:q to quit editing
file - view when not in preview modeeq or :q to quit viewing
help - display:help
hidden items - hidezm
hidden items - showzo
item - copyyyfor yank
item - delete/cutdd
item - pastepafter a delete or copy
item - rename name and/or extensioncw
item - rename only namecW
item - toggle selectiontTODO: How can you operate on selections?
item - undo deleteu
mark - createm followed by letterremembers selected item in directory
mark - delete under cursor in listdd
mark - go to' followed by letter
mark - go to home directory'huses predefined mark
mark - list all:marks
move - to bottom of paneG
move - to top of panegg
pane - move to othertab
pane - show only one:only or ctrl-w o
pane - split horizontalsp or ctrl-w salso switches from 1 to 2 panes
pane - split verticalvs or ctrl-w valso switches from 1 to 2 panes
preview mode - togglewchanges 2nd pane to show preview of item
preview pane - toggle focusshift-tabcan navigate up and down in preview pane
shell - open in current directory:shellexit to return to vifm

Configuring

By default vifm is configured in the file ~/.vifm/vifmrc.

Color Schemes

Vifm provides predefined color schemes. To use these, download their .vifm files into the ~/.config/vifm/colors directory. Then edit ~/.config/vifm/vifmrc and change the colorscheme setting. For example, colorscheme desert. Finally, restart vifm for the change to take effect.

Icons

To display icons before files of specific types add lines like the following in the vifmrc configuration file and restart vifm. Note that file types are surrounded by single colons and file patterns are surrounded by double colons.

set classify='  :dir:'
set classify+='🏃 :exe:'
set classify+=' :link:' " link
set classify+=' ::*.css::' " CSS
set classify+=' ::*.go::' " Go
set classify+=' ::*.html::' " HTML
set classify+=' ::*.java::' " Java
set classify+=' ::*.js::' " JavaScript
set classify+=' ::*.md::' " Markdown
set classify+=' ::*.py::' " Python
set classify+=' ::*.rb::' " Ruby
set classify+=' ::*.rs::' " Rust
set classify+=' ::*.sass::' " Sass

Questions

How do you copy or delete multiple items as a group? See “item - toggle selection”.

How do you search/grep inside vifm?

How can you use fileviewer to configure image files to open in the Mac Preview app?