Skip to main content

Vifm

  • Managing files in the terminal

Why?

  • easier on my wrists to use keyboard rather than mouse
  • useful to have a CLI alternative to Finder if SSH-ing into a Mac remotely
    • I do this with my home media server, which is a Mac mini with a bunch of files on it

Useful commands

  • vifm — open Vifm to the folders it was open to when it was last closed
  • vifm . . — open the current folder in two panes
  • TAB or SPACE - switch panes
  • Find files in current directory:
    • /REGEX_PATTERN — search forward (down) in list
    • ?REGEX_PATTERN — search backward (up) in list
    • ENTER — select all results and jump to first occurrence
    • n — jump to next occurence (relative to search direction)
    • N — jump to previous occurrence (relative to search direction)
    • ESC — cancel search and deselect files
  • Select and deselect files:
    • t — select or unselect (tag) the current file
    • v + j/k — select a continuous group of files
      • ENTER to save selection + return to normal mode (can use t to add other files to the selection)
    • ESC or :noh — clear selection in current pane
    • /REGEX_PATTERN to search forward + n to go to next occurence + t to select it
  • Copy, move or delete selected file(s):
    • :move[?!] [ &] or :m[?!] [ &] — move selected files to directory in other pane
      • or: Y or yy + navigate to a different folder + P
    • :copy[?!] [ &] or :co[?!] [ &] — copy selected files to directory in other pane
      • or: Y or yy + navigate to a different folder + p
    • ? — prompt for destination file names in an editor
    • ! — force overwrite
    • & — run command in background (unblocks UI)
  • Delete selected files:
    • :delete[?!] [ &] or :d[?!] [ &] — move selected files to trash
      • & — run command in background (unblocks UI)
    • or: dd
  • Cancellable copying, moving and deleting (blocks UI):
    • select a file (or files) + dd - deletes file(s)
  • Background copying, moving and deleting (doesn’t block UI; can’t be cancelled):
    • select a file (or files) + :delete or :d — deletes file(s)
  • Create a directory:
    • :mkdir[!] dir — creates a directory named dir relative to the current directory; ! creates subfolders as needed; names containing spaces need to be surrounded by ""
  • Rename a file or directory:
    • :rename — without an argument, opens the selected file or directory name(s) in an editor (where they can be edited using vim keybindings); exit nvim editor with ZZ
    • :rename[!] file — renames the selected file or directory to file; ! overwrites existing files; names containing spaces need to be surrounded by `""
    • cw — edit file or directory name(s) (includes file extension)
    • cW — edit file or directory name(s) (excludes file extension)
  • :jobs — view background jobs; dd to cancel; ESC to exit
  • :empty - empties vifm’s trash (use system trash by following these instructions)
  • :restore — restore a file from the trash (~/.local/share/vifm/Trash)
  • za - toggle visibility of dot files
  • u — undo last change
  • Ctrl-R — redo last change
  • ga — update size shown next to selected directory name(s)
    • uses cached directory sizes when possible for better performance
  • gA — like ga, but forces recalculation
  • :⬆️ — scroll through recent commands; ENTER to run command again
  • Ctrl-G — show a dialog with detailed information about the selected file
  • %s/pattern/string/[flags] — substitute instances of pattern in file with string; flag options:
    • g — replace all occurrences in the file
    • i — ignore case
    • I — don’t ignore case
  • :cd - — change to the previous directory
  • :tree — show a tree view of the current directory (to reveal all nested files and folders)
  • :touch — create a new file

When to run commands in background

  • when copying, moving or deleting files on an external volume
  • why?
  • copy, move and delete operations are quick on the local hard drive
  • however, copy, move and delete operations on external volumes (e.g. a USB-connected external hard drive) can take awhile to complete
  • if you copy, move or delete files and folders in the usual way, the UI will freeze/hang until the operation completes
    • depending on the size of the files you’re modifying, that can take minutes or hours
  • running those commands in the background instead will allow you to continue managing other files while those operations complete
  • :j or :jobs: view a list of background jobs in progress
    • dd: cancel the selected job(s)
    • r: reload the :jobs list

Useful configuration

  • how to customize config…
  • default config works fine
  • my recommended config adjustments
    • sort
      • ignore case when sorting files in a directory
      • maybe don’t show all directories above all files…? weird in general but useful for my use case of updating show files
        • maybe apply this myself but don’t recommend it? or call it out as optional?
  • other config options
  • Configuration model - Vifm Wiki
  • Syntax highlighting file preview with bat (see my dotfiles)
  • Add custom nerd font file and folder icons using … (see my dotfiles)

Inbox