Vulpes-Vulpeos

vifm config

Jul 22nd, 2025
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.47 KB | Software | 0 0
  1. " vim: filetype=vifm :
  2.  
  3. " ------------------------------------------------------------------------------
  4. " Main settings
  5. " ------------------------------------------------------------------------------
  6.  
  7. " Command used to edit files in various contexts. The default is vim.
  8. if executable('nvim')
  9. set vicmd=nvim
  10. elseif executable('hx')
  11. set vicmd=hx
  12. elseif executable('nano')
  13. set vicmd=nano
  14. elseif $EDITOR != ''
  15. echo 'Note: using `'.$EDITOR.'` as an editor'
  16. let &vicmd = $EDITOR
  17. endif
  18.  
  19. " This makes vifm perform file operations on its own instead of relying on
  20. " standard utilities like `cp`. While using `cp` and alike is a more universal
  21. " solution, it's also much slower when processing large amounts of files and
  22. " doesn't support progress measuring.
  23. set syscalls
  24.  
  25. " Trash Directory
  26. " The default is to move files that are deleted with dd or :d to
  27. " the trash directory. If you change this you will not be able to move
  28. " files by deleting them and then using p to put the file in the new location.
  29. " I recommend not changing this until you are familiar with vifm.
  30. " This probably shouldn't be an option.
  31. set trash
  32.  
  33. " What should be saved automatically on restarting vifm. Drop "savedirs"
  34. " value if you don't want vifm to remember last visited directories for you.
  35. set vifminfo=dhistory,savedirs,chistory,state,tui,shistory,
  36. \phistory,fhistory,dirstack,registers,bookmarks,bmarks
  37.  
  38. " This is how many directories to store in the directory history.
  39. set history=100
  40.  
  41. " Automatically resolve symbolic links on l or Enter.
  42. set nofollowlinks
  43.  
  44. " Natural sort of (version) numbers within text.
  45. set sortnumbers
  46.  
  47. " Maximum number of changes that can be undone.
  48. set undolevels=100
  49.  
  50. " Use Vim's format of help file (has highlighting and "hyperlinks").
  51. " If you would rather use a plain text help file set novimhelp.
  52. set vimhelp
  53.  
  54. " If you would like to run an executable file when you
  55. " press Enter, l or Right Arrow, set this.
  56. set norunexec
  57.  
  58. " Format for displaying time in file list. For example:
  59. " TIME_STAMP_FORMAT=%m/%d-%H:%M
  60. " See man date or man strftime for details.
  61. set timefmt='%Y.%m.%d %H:%M'
  62.  
  63. " Show list of matches on tab completion in command-line mode
  64. set wildmenu
  65.  
  66. " Display completions in a form of popup with descriptions of the matches (bar/popup)
  67. set wildstyle=bar
  68.  
  69. " Display suggestions in normal, visual and view modes for keys, marks and
  70. " registers (at most 5 files). In other view, when available.
  71. set suggestoptions=normal,visual,view,otherpane,keys,marks,registers
  72.  
  73. " Ignore case in search patterns unless it contains at least one uppercase
  74. " letter
  75. set ignorecase
  76. set smartcase
  77.  
  78. " Don't highlight search results automatically
  79. set nohlsearch
  80.  
  81. " Use increment searching (search while typing)
  82. set incsearch
  83.  
  84. " Try to leave some space from cursor to upper/lower border in lists
  85. set scrolloff=4
  86.  
  87. " Don't do too many requests to slow file systems
  88. if !has('win')
  89. set slowfs=curlftpfs
  90. endif
  91.  
  92. " Set custom status line look
  93. "set statusline=" Hint: %z%= %A %10u:%-7g %15s %20d "
  94. set statusline=" %= %A %10u:%-7g %15E %20d "
  95.  
  96. " List of color schemes to try (picks the first one supported by the terminal)
  97. colorscheme ayu1nord Default
  98. " Set sort to a-z with case ignore
  99. set sort=+iname
  100.  
  101. " Make bash aliases work in vifm
  102. set shellcmdflag=-ic
  103.  
  104. " Make copying faster
  105. "set iooptions-=datasync
  106.  
  107. " Enable mouse
  108. "set mouse=a
  109.  
  110. " ------------------------------------------------------------------------------
  111. " Bookmarks
  112. " ------------------------------------------------------------------------------
  113.  
  114. " :mark mark /full/directory/path [filename]
  115.  
  116. mark h ~/
  117.  
  118. " ------------------------------------------------------------------------------
  119. " Commands
  120. " ------------------------------------------------------------------------------
  121.  
  122. " :com[mand][!] command_name action
  123. "
  124. " These are some of the macros that can be used in the action part:
  125. " %a for user arguments
  126. " %c for current file under the cursor
  127. " %C for current file under the cursor of inactive pane
  128. " %f for selected file(s)
  129. " %F for selected file(s) of inactive pane
  130. " %b is the same as %f %F
  131. " %d for current directory name
  132. " %D for current directory name of inactive pane
  133. " %r{x} for list of files in register {x}
  134. " %m runs the command in a menu window
  135. " %u uses command's output to build a file list
  136. " see `:help vifm-macros` and `:help vifm-filename-modifiers` for more
  137.  
  138. command! df df -h %m 2> /dev/null
  139. command! diff vim -d %f %F
  140. command! zip zip -r %c.zip %f
  141. command! run !! ./%f
  142. command! make !!make %a
  143. command! mkcd :mkdir %a | cd %a
  144. command! vgrep vim "+grep %a"
  145. command! reload :write | restart full
  146.  
  147. command! suedit !sudoedit %f
  148. command! sumv !sudo mv %f %D ; echo ""
  149. command! surm !sudo rm -rv %f ; echo ""
  150. command! extract !7z x %f > /dev/null 2>&1
  151. command! compress !7z a -r "archive.zip" %f > /dev/null 2>&1
  152.  
  153. " ------------------------------------------------------------------------------
  154. " File types association
  155. " ------------------------------------------------------------------------------
  156.  
  157. " :filetype pattern1,pattern2 defaultprogram,program2
  158. " :fileviewer pattern1,pattern2 consoleviewer
  159. "
  160. " The first entry is the default program to be used with a matching file.
  161. " The other programs for the file type can be accessed via :file command.
  162. " The command macros like %f, %F, %d, %D may be used in the commands.
  163. " The %a macro is ignored. To use a % you must put %%.
  164. " Spaces in an app name must be escaped, for example: QuickTime\ Player.app
  165.  
  166. " Pdf
  167. filextype {*.pdf},<application/pdf> zathura %c %i
  168. fileviewer {*.pdf},<application/pdf> pdftotext -nopgbrk %c -
  169.  
  170. " Djvu
  171. filextype {*.djvu},<image/vnd.djvu> zathura %f
  172.  
  173. " Audio
  174. filetype {*.wav,*.mp3,*.flac,*.m4a,*.wma,*.ape,*.ac3,*.og[agx],*.spx,*.opus,
  175. \*.aac,*.mpga},<audio/*>
  176. \ {Play using ffplay}
  177. \ ffplay -nodisp -hide_banner -autoexit %c,
  178. \ {Play using mpv}
  179. \ mpv --no-video %f %s,
  180. fileviewer {*.wav,*.mp3,*.flac,*.m4a,*.wma,*.ape,*.ac3,*.og[agx],*.spx,*.opus,
  181. \*.aac,*.mpga},<audio/*>
  182. \ ffprobe -hide_banner -pretty %c 2>&1;
  183.  
  184. " Video
  185. filetype {*.avi,*.mp4,*.wmv,*.dat,*.3gp,*.ogv,*.mkv,*.mpg,*.mpeg,*.vob,
  186. \*.fl[icv],*.m2v,*.mov,*.webm,*.ts,*.mts,*.m4v,*.r[am],*.qt,*.divx,
  187. \*.as[fx],*.unknown_video},<video/*>
  188. \ open -a iina.app %f ; echo ""
  189. fileviewer {*.avi,*.mp4,*.wmv,*.dat,*.3gp,*.ogv,*.mkv,*.mpg,*.mpeg,*.vob,
  190. \*.fl[icv],*.m2v,*.mov,*.webm,*.ts,*.mts,*.m4v,*.r[am],*.qt,*.divx,
  191. \*.as[fx],*.unknown_video},<video/*>
  192. \ ffprobe -hide_banner -pretty %c 2>&1
  193.  
  194. " Web
  195. filextype {*.xhtml,*.html,*.htm},<text/html>
  196. \ {Open with firefox}
  197. \ firefox %f &,
  198. filetype {*.xhtml,*.html,*.htm},<text/html> links, lynx
  199.  
  200. " Object
  201. filetype {*.o},<application/x-object> nm %f | less
  202.  
  203. " Man page
  204. filetype {*.[1-8]},<text/troff> man ./%c
  205. fileviewer {*.[1-8]},<text/troff> man ./%c | col -b
  206.  
  207. " Images
  208. filextype {*.svg,*.svgz},<image/svg+xml>
  209. \ {Edit in Inkscape}
  210. \ inkscape %f,
  211. \ {View in Inkview}
  212. \ inkview %f,
  213. filetype {*.bmp,*.jpg,*.jpeg,*.png,*.gif,*.xpm},<image/*>
  214. \ open -a Preview.app %f ; echo ""
  215. fileviewer {*.bmp,*.jpg,*.jpeg,*.png,*.gif,*.xpm},<image/*>
  216. \ show-sixel %c %pw %ph %pd,
  217. \ chafa --format=sixels --size=%pwx%ph --polite=on %c %pd %N,
  218. \ timg -p q -g%pwx%ph %c %pd
  219.  
  220. " MD5
  221. filetype *.md5
  222. \ {Check MD5 hash sum}
  223. \ md5sum -c %f %S,
  224.  
  225. " SHA1
  226. filetype *.sha1
  227. \ {Check SHA1 hash sum}
  228. \ sha1sum -c %f %S,
  229.  
  230. " SHA256
  231. filetype *.sha256
  232. \ {Check SHA256 hash sum}
  233. \ sha256sum -c %f %S,
  234.  
  235. " SHA512
  236. filetype *.sha512
  237. \ {Check SHA512 hash sum}
  238. \ sha512sum -c %f %S,
  239.  
  240. " GPG signature
  241. filetype {*.asc},<application/pgp-signature>
  242. \ {Check signature}
  243. \ !!gpg --verify %c,
  244.  
  245. " Torrent
  246. filetype {*.torrent},<application/x-bittorrent> ktorrent %f &
  247. fileviewer {*.torrent},<application/x-bittorrent>
  248. \ dumptorrent -v %c,
  249. \ transmission-show %c
  250.  
  251. " FuseZipMount
  252. filetype {*.zip,*.jar,*.war,*.ear,*.oxt,*.apkg},
  253. \<application/zip,application/java-archive>
  254. \ {Mount with fuse-zip}
  255. \ FUSE_MOUNT|fuse-zip %SOURCE_FILE %DESTINATION_DIR,
  256. \ {View contents}
  257. \ unzip -l %f | less,
  258. \ {Extract here}
  259. \ unzip %c,
  260. fileviewer *.zip,*.jar,*.war,*.ear,*.oxt unzip -l %f
  261.  
  262. " ArchiveMount
  263. filetype {*.tar,*.tar.bz2,*.tbz2,*.tgz,*.tar.gz,*.tar.xz,*.txz,*.tar.zst,
  264. \*.tzst},
  265. \<application/x-tar>
  266. \ {Mount with archivemount}
  267. \ FUSE_MOUNT|archivemount %SOURCE_FILE %DESTINATION_DIR,
  268. fileviewer *.tgz,*.tar.gz tar -tzf %c
  269. fileviewer *.tar.bz2,*.tbz2 tar -tjf %c
  270. fileviewer *.tar.xz,*.txz tar -tJf %c
  271. fileviewer *.tar.zst,*.tzst tar -t --zstd -f %c
  272. fileviewer {*.tar},<application/x-tar> tar -tf %c
  273.  
  274. " Rar2FsMount and rar archives
  275. filetype {*.rar},<application/x-rar>
  276. \ {Mount with rar2fs}
  277. \ FUSE_MOUNT|rar2fs %SOURCE_FILE %DESTINATION_DIR,
  278. fileviewer {*.rar},<application/x-rar> unrar v %c
  279.  
  280. " IsoMount
  281. filetype {*.iso},<application/x-iso9660-image>
  282. \ {Mount with fuseiso}
  283. \ FUSE_MOUNT|fuseiso %SOURCE_FILE %DESTINATION_DIR,
  284.  
  285. " SshMount
  286. filetype *.ssh
  287. \ {Mount with sshfs}
  288. \ FUSE_MOUNT2|sshfs %PARAM %DESTINATION_DIR %FOREGROUND,
  289.  
  290. " FtpMount
  291. filetype *.ftp
  292. \ {Mount with curlftpfs}
  293. \ FUSE_MOUNT2|curlftpfs -o ftp_port=-,,disable_eprt %PARAM %DESTINATION_DIR %FOREGROUND,
  294.  
  295. " Fuse7z and 7z archives
  296. filetype {*.7z},<application/x-7z-compressed>
  297. \ {Mount with fuse-7z}
  298. \ FUSE_MOUNT|fuse-7z %SOURCE_FILE %DESTINATION_DIR,
  299. fileviewer {*.7z},<application/x-7z-compressed> 7z l %c
  300.  
  301. " Office files
  302. filextype {*.odt,*.doc,*.docx,*.xls,*.xlsx,*.odp,*.pptx,*.ppt},
  303. \<application/vnd.openxmlformats-officedocument.*,
  304. \application/msword,
  305. \application/vnd.ms-excel>
  306. \ libreoffice %f &
  307. fileviewer {*.doc},<application/msword> catdoc %c
  308. fileviewer {*.docx},
  309. \<application/
  310. \vnd.openxmlformats-officedocument.wordprocessingml.document>
  311. \ docx2txt.pl %f -
  312.  
  313. " TuDu files
  314. filetype *.tudu tudu -f %c
  315.  
  316. " Syntax highlighting in preview
  317. "
  318. " Explicitly set highlight type for some extensions
  319. "
  320. " 256-color terminal
  321. " fileviewer *.[ch],*.[ch]pp highlight -O xterm256 -s dante --syntax c %c
  322. " fileviewer Makefile,Makefile.* highlight -O xterm256 -s dante --syntax make %c
  323. "
  324. " 16-color terminal
  325. " fileviewer *.c,*.h highlight -O ansi -s dante %c
  326. "
  327. " Or leave it for automatic detection
  328. " fileviewer *[^/] pygmentize -O style=monokai -f console256 -g
  329.  
  330. " Displaying pictures in terminal
  331. " fileviewer *.jpg,*.png shellpic %c
  332.  
  333. " Open all other files with default system programs (you can also remove all
  334. " :file[x]type commands above to ensure they don't interfere with system-wide
  335. " settings). By default all unknown files are opened with 'vi[x]cmd'
  336. " uncommenting one of lines below will result in ignoring 'vi[x]cmd' option
  337. " for unknown file types.
  338. " For *nix:
  339. " filetype * xdg-open
  340. " For OS X:
  341. " filetype * open
  342. " For Windows:
  343. " filetype * explorer %"f &
  344.  
  345. " ------------------------------------------------------------------------------
  346. " Panel configuration examples
  347. " ------------------------------------------------------------------------------
  348.  
  349. " Customize view columns a bit (enable ellipsis for truncated file names)
  350. " set viewcolumns=-{name}..,6{}.
  351.  
  352. " Hide side borders
  353. set tuioptions-=s
  354.  
  355. " Show vertical border
  356. " set fillchars=vborder:"│",hborder:"─"
  357.  
  358. " Filter-out build and temporary files
  359. " filter! {*.lo,*.o,*.d,*.class,*.pyc,*.pyo,.*~}
  360.  
  361. " ------------------------------------------------------------------------------
  362. " Sample keyboard mappings
  363. " ------------------------------------------------------------------------------
  364.  
  365. " Start shell in current directory
  366. nnoremap s :shell<cr>
  367.  
  368. " Display sorting dialog
  369. nnoremap S :sort<cr>
  370.  
  371. " Toggle visibility of preview window
  372. nnoremap <space> :view<cr>
  373. vnoremap <space> :view<cr>gv
  374.  
  375. if $DISPLAY != '' && executable('gvim')
  376. " Open file in existing instance of gvim
  377. nnoremap o :!gvim --remote-tab-silent %f<cr>
  378. " Open file in new instance of gvim
  379. nnoremap O :!gvim %f<cr>
  380. endif
  381.  
  382. " Open file in the background using its default program
  383. nnoremap gb :file &<cr>l
  384.  
  385. " Interaction with system clipboard
  386. if has('win')
  387. " Yank current directory path to Windows clipboard with forward slashes
  388. nnoremap yp :!echo %"d:gs!\!/! %i | clip<cr>
  389. " Yank path to current file to Windows clipboard with forward slashes
  390. nnoremap yf :!echo %"c:gs!\!/! %i | clip<cr>
  391. elseif $WAYLAND_DISPLAY != ''
  392. if executable('wl-copy')
  393. " Yank current directory path into primary and selection clipboards
  394. nnoremap yd :!echo -n %d | wl-copy %i &&
  395. \ echo -n %d | wl-copy -p %i<cr>
  396. " Yank current file path into into primary and selection clipboards
  397. nnoremap yf :!echo -n %c:p | wl-copy %i &&
  398. \ echo -n %c:p | wl-copy -p %i<cr>
  399. endif
  400. elseif $DISPLAY != ''
  401. if executable('xclip')
  402. " Yank current directory path into the clipboard
  403. nnoremap yd :!echo %d | xclip %i<cr>
  404. " Yank current file path into the clipboard
  405. nnoremap yf :!echo %c:p | xclip %i<cr>
  406. elseif executable('xsel')
  407. " Yank current directory path into primary and selection clipboards
  408. nnoremap yd :!echo -n %d | xsel --input --primary %i &&
  409. \ echo -n %d | xsel --clipboard --input %i<cr>
  410. " Yank current file path into into primary and selection clipboards
  411. nnoremap yf :!echo -n %c:p | xsel --input --primary %i &&
  412. \ echo -n %c:p | xsel --clipboard --input %i<cr>
  413. endif
  414. " macOS integration
  415. elseif $DISPLAY == ''
  416. if executable('pbcopy')
  417. " current directory path
  418. nnoremap yd :!echo -n %d | pbcopy %i<cr>:echo expand('%"d') "is yanked to clipboard"<cr>
  419. " current file path
  420. nnoremap yf :!echo -n %c:p | pbcopy %i<cr>:echo expand('%"c:p') "is yanked to clipboard"<cr>
  421. " current filename without path
  422. nnoremap yn :!echo -n %c | pbcopy %i<cr>:echo expand('%"c') "is yanked to clipboard"<cr>
  423. " root of current file's name
  424. nnoremap yr :!echo -n %c:r | pbcopy %i<cr>:echo expand('%"c:r') "is yanked to clipboard"<cr>
  425. endif
  426. endif
  427.  
  428. " Mappings for faster renaming
  429. nnoremap I cw<c-a>
  430. nnoremap cc cw<c-u>
  431. nnoremap A cw
  432.  
  433. " Open console in current directory
  434. if $DISPLAY != '' && executable('xterm')
  435. nnoremap ,t :!xterm &<cr>
  436. elseif $TERMINAL != ''
  437. nnoremap ,t :!$TERMINAL &<cr>
  438. endif
  439.  
  440. " Open editor to edit vifmrc and apply settings after returning to vifm
  441. nnoremap ,c :write | edit $MYVIFMRC | restart full<cr>
  442.  
  443. " Open gvim to edit vifmrc
  444. if $DISPLAY != '' && executable('gvim')
  445. nnoremap ,C :!gvim --remote-tab-silent $MYVIFMRC &<cr>
  446. endif
  447.  
  448. " Toggle wrap setting on ,w key
  449. nnoremap ,w :set wrap!<cr>
  450.  
  451. " Example of standard two-panel file managers mappings
  452. nnoremap <f3> :!less %f<cr>
  453. nnoremap <f4> :edit<cr>
  454. nnoremap <f5> :copy<cr>
  455. nnoremap <f6> :move<cr>
  456. nnoremap <f7> :mkdir<space>
  457. nnoremap <f8> :delete<cr>
  458.  
  459. " Midnight commander alike mappings
  460. " Open current directory in the other pane
  461. nnoremap <a-i> :sync<cr>
  462. " Open directory under cursor in the other pane
  463. nnoremap <a-o> :sync %c<cr>
  464. " Swap panes
  465. nnoremap <c-u> <c-w>x
  466.  
  467. " Show console output
  468. nnoremap <c-o> :hide<cr>
  469.  
Tags: vifm
Add Comment
Please, Sign In to add comment