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