" [n]ormal, [v]isual, [d]ialogue, [q]uick view, [m]enu, [c]ommand " Ctrl+k as Esc nnoremap vnoremap dnoremap qnoremap q mnoremap cnoremap " Quickly access command line nnoremap ; : vnoremap ; : mnoremap ; : " Run external command nnoremap ! :!! " Invert sorting order nnoremap r :invert o " Special filters with , nnoremap , z " Toggle explore qnoremap e q " Vifm unique mappings ============================================== " Open editor for command line nnoremap : q: " Toggle previewing "o[ther] viewer" nnoremap o :view qnoremap o :view vnoremap o :viewgv " Open sorting menu nnoremap s :sort " Open bash shell in cwd nnoremap :!/usr/bin/env IS_VIFM_NEST='T' bash -l nnoremap :!/usr/bin/env IS_VIFM_NEST='T' bash -l " Open cwd in finder nnoremap ofinder :!open . nnoremap ogadd :!git add %c " Logical conflict mappings " Navigate back from symlinks nnoremap H :cd - "nnoremap L l " Open file in existing instance of macvim nnoremap O :!mvim --remote-tab-silent %f " Windows and buffers =============================================== " Window control with leader "nnoremap w " Open and switch to split, like in vim nnoremap ws :split nnoremap wv :vsplit " Expand current window nnoremap wo :only " Close current window nnoremap wc :only " eXchange windows nnoremap wx x " Open a new tab nnoremap wT :tabnew " Close tab nnoremap wC :tabclose " Quick window switching. [N]ormal and [Q]uick view modes nnoremap l l nnoremap h h nnoremap j j nnoremap k k qnoremap l l qnoremap h h qnoremap j j qnoremap k k " Window movement nnoremap h H nnoremap j J nnoremap k K nnoremap l L " Window resizing " < increases, > decreases nnoremap , 4> nnoremap . 4< nnoremap , 4+ nnoremap . 4- " Set windows to be equally sized nnoremap = = " Emacs-like movements " Move by character cnoremap cnoremap " Delete by character. Note: not cnoremap cnoremap " Move by word cnoremap cnoremap " Delete left word cnoremap " Jump to end of line cnoremap cnoremap " Clipboard ============================================== " Copy file or directory paths to clipboard if executable('pbcopy') nnoremap yd :!echo %d | pbcopy nnoremap yf :!echo %c:p | pbcopy nnoremap yp :!echo %c:p | sed 's#'"${HOME}"'#~#' | pbcopy elseif executable('wl-copy') nnoremap yd :!echo %d | wl-copy nnoremap yf :!echo %c:p | wl-copy nnoremap yp :!echo %c:p | sed 's#'"${HOME}"'#~#' | wl-copy elseif executable('xclip') nnoremap yd :!echo %d | xclip %i nnoremap yf :!echo %c:p | xclip %i nnoremap yp :!echo %c:p | sed 's#'"${HOME}"'#~#' | xclip %i elseif executable('xsel') nnoremap yd :!echo -n %d | xsel --input --primary %i && \ echo -n %d | xsel --clipboard --input %i nnoremap yf :!echo -n %c:p | xsel --input --primary %i && \ echo -n %c:p | xsel --clipboard --input %i endif " Experimental =========================================== nnoremap m :sync %d " Toggle dotfiles "nnoremap gh :set dotfiles! "nnoremap . :set dotfiles! " Smaller scrolling movements "nnoremap 6k "vnoremap 6k "nnoremap 6j "vnoremap 6j nnoremap orestore :!git restore %c nnoremap oadd :!git add %c " Make and navigate to a directory in the other pane command! cddir :sync! | exe 'wincmd w' | mkdir "%d/%a" | cd "%d/%a" | exe 'wincmd w' "command! pngcopy :!osascript -e 'set the clipboard to (read (POSIX file "'.%c.'") as PNG picture)' " =================================================================== " Settings " =================================================================== " Don't use this directly. loads additional configs set shell='/usr/bin/env bash' set vicmd='nvim --' set syscalls "nosyscalls for third party tools like `cp` instead set vifminfo=dhistory,savedirs,chistory,state,tui,shistory, \phistory,fhistory,dirstack,registers,bookmarks,bmarks set trash " Required for moving files with dd/p set history=1000 " Directory history scrollback set undolevels=1000 " Maximum undos stored set nofollowlinks set sortnumbers set timefmt=%m/%d\ %H:%M " See `man date` or `man strftime` for details " Show list of matches on tab completion in command-line mode set wildmenu set wildstyle=popup set vimhelp " Extra highlighting with vim's help file format set nohlsearch " Don't highlight search results automatically set incsearch " Incremental highlights while typing set scrolloff=2 " Backwards compatibility. Enables without 't' set cpoptions="fs" set sort +size " Resolve symlinked paths like cd -P set chaselinks set tablabel="%t" set statusline="%16A %u:%-g %s (%d) -> %T" command! Light :colorscheme gruvbox-light Default Default-256 command! Dark :colorscheme gruvbox-dark Default Default-256 if system('colo.sh --tone') == 'light' Light else Dark endif " =================================================================== " Preload defaults " =================================================================== " :mark mark /full/directory/path [filename] " Common directories mark h ~/ mark c ~/.configs_pointer/ mark d ~/Downloads/ mark s ~/safe/ mark v ~/.config/vifm/ set millerview " =================================================================== " Commands " =================================================================== " Only 3 view modes are available. Full screen and 2 window splits " :only :split :vsplit command! hsplit :split command! duplicate :clone command! mview :set millerview! command! finder :!open . " Git-like shortcuts command! stash :norm! zR command! stashpop :norm! zM command! stashdrop :norm! zO " Vifm doesn't support escaping modfiers like `exe "norm! \h"`, so we use " a remap ahead of time nnoremap + h command! preview :tabnew | set nomillerview | vsplit | sync! | exe 'norm +' | exe ':24wincmd-' | view " i for image nnoremap i :preview nnoremap i :!~/.configs_pointer/bin/vii.sh &>/dev/null & " =================================================================== " Fzf intergration " https://github.com/vifm/vifm/issues/279#issuecomment-319980898 " =================================================================== " Write the current bookmarks to a file command! fzfreadbmarks :exe "normal! :bmarks\r:write ~/.config/vifm/fzf-read/bookmarks\rq" " Automatically navigate into directories and symlinks to directories command! navigateIfDir :if system('[[ ! -d '.expand('%c').' ]] || printf "T"') == 'T' | exe 'norm l' | endif " Prefer to use popup window. Requires 90 $COLUMNS and tmux >=3.2. Yabai on " MacOS causes it to crash regardless. Use full-screen as a fallback command! fzfbmarks \ :if $TMUX != '' && &columns > 90 && &lines >= 30 \ | exe 'cd "'.system('cat ~/.config/vifm/fzf-read/bookmarks | fzf-tmux -p 90,30 | sed "s/:.*//" ').'"' \ | else \ | exe 'cd "'.term('cat ~/.config/vifm/fzf-read/bookmarks | fzf 2>/dev/tty | sed "s/:.*//" ').'"' \ | endif command! fdcddir \ :if $TMUX != '' && &columns > 90 && &lines >= 30 \ | exe 'cd "'.system('fd -HE ''.git'' -t d . | fzf-tmux -p 90,30').'"' \ | else \ | exe 'cd "'.term('fd -HE ''.git'' -t d . | fzf 2>/dev/tty').'"' \ | endif command! fdeditfiles \ :if $TMUX != '' && &columns > 90 && &lines >= 30 \ | exe '!~/.configs_pointer/vifm/scripts/vifm_bg_open.sh "'.system('fd -HE ''.git'' -t f . | fzf-tmux -p 90,30').'"' \ | else \ | exe '!~/.configs_pointer/vifm/scripts/vifm_bg_open.sh "'.term('fd -HE ''.git'' -t f . | fzf 2>/dev/tty').'"' \ | endif command! fdmvcursor \ :if $TMUX != '' && &columns > 90 && &lines >= 30 \ | exe 'goto "'.system('fd --maxdepth=1 -HE ''.git'' . | fzf-tmux -p 90,30').'"' | navigateIfDir \ | else \ | exe 'goto "'.term('fd --maxdepth=1 -HE ''.git'' . | fzf 2>/dev/tty').'"' | navigateIfDir \ | endif " Read in latests bookmarks before fzfinding through them command! fzfmarks :fzfreadbmarks | fzfbmarks nnoremap r :fzfmarks nnoremap e :fdcddir nnoremap f :fdeditfiles nnoremap ; :fdmvcursor " =================================================================== " Defaults " =================================================================== " Directory-local options, see :h vifm-'sort' autocmd DirEnter ~/Downloads setlocal sort=-mtime " Tmux won't work with sixel at all. Alacritty is currently very unstable with " it and flickers a lot. Set $TMUX for blurrier faster version. Quanity on " MacOS with viu seems to get worse the more images you preview if $TMUX == '' fileviewer