-
Notifications
You must be signed in to change notification settings - Fork 5
/
vifmrc
312 lines (255 loc) · 10.8 KB
/
vifmrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
" vim: filetype=vim ts=24 fdm=expr fdl=0
" HINTS:
" :!!ls -- using 2 !'s pauses
" :%s/foo/bar/ -- munges filenames!
" :tree (and then "zd" on ".git") is nice sometimes, to get a feel for what actually is in that tree!
" ------------------------------------------------------------------------------
" settings that need to be BEFORE .local
colorscheme sitaram-user
" ------------------------------------------------------------------------------
" local settings
source "$HOME/.config/vifm/vifmrc.local"
" ------------------------------------------------------------------------------
" basic settings
set vicmd=vim
" Trash Directory
" I recommend not changing this until you are familiar with vifm.
" This probably shouldn't be an option.
set trash
set history=100
set fastrun
set sortnumbers
set undolevels=100
set vimhelp
set norunexec
set ignorecase
set smartcase
set hlsearch
set incsearch
set scrolloff=4
set dotdirs=rootparent
set dotfiles
set dirsize=nitems
" ------------------------------------------------------------------------------
" slightly advanced settings
" Don't do too many requests to slow file systems
if !has('win')
set slowfs=curlftpfs
endif
set timefmt=%F\ %T
" Show list of matches on tab completion in command-line mode
set wildmenu
" Display completions in a form of popup with descriptions of the matches
set wildstyle=popup
" Display suggestions in normal, visual and view modes for keys, marks and
" registers (at most 5 files). In other view, when available.
set suggestoptions=normal,visual,view,otherpane,keys,marks,registers
set statusline="%A %7u %7g %7s %d %T (%7E) %{&sort}"
set rulerformat='%2l / %S%[ +%x%]'
set trashdir=%r/.vifm-Trash-%u,$HOME/.cache/vifm/trash
set vifminfo=bmarks,bookmarks,dhistory,chistory,shistory,phistory,fhistory,registers,
let &syncregs = $USER
screen!
" ------------------------------------------------------------------------------
" custom commands
" :com[mand][!] command_name action
" The following macros can be used in a command
" %a is replaced with the user arguments.
" %c the current file under the cursor.
" %C the current file under the cursor in the other directory.
" %f the current selected file, or files.
" %F the current selected file, or files in the other directory.
" note: this *includes* %D/
" %b same as %f %F.
" %d the current directory name.
" %D the other window directory name.
" %m run the command in a menu window
" we start them with uppercase letters so when you hit ":<TAB>" they're at the top
command! Tar tar cf %c.tar %c
command! Tgz tar zcf %c.tgz %c
command! Mkcd :mkdir! %a | cd %a
command! xc :set viewcolumns=*{name}..,24{mtime}| zzzInternalXC %a
command! xm :set viewcolumns=*{name}..,24{mtime}| zzzInternalXM %a
command! xs :set viewcolumns=*{name}..,8{size}| zzzInternalXS %a
command! zzzInternalXC git log --name-only --format=%%n -- %d| CDUP=`git rev-parse --show-cdup` perl -lne 'print if /./ and s(^)($ENV{CDUP}) and -f and not $seen{$_}++' | head -%a %U
command! zzzInternalXM find -type f -printf '%%TF.%%TT\t%%p\n' | rg -v stversions | sort -k1r | cut -f2 | head -%a %U
command! zzzInternalXS find -type f -printf '%%12s\t%%p\n' | rg -v stversions | sort -k1rn | cut -f2 | head -%a %U
" from https://wiki.vifm.info/index.php/How_to_integrate_fzf_for_fuzzy_finding
" variation that automatically enters directories
command! FZFcd : set noquickview
\| let $FZF_PICK = term('find | grep -v stversions | fzf 2>/dev/tty')
\| if $FZF_PICK != ''
\| execute system('[ -f "$FZF_PICK" ] && echo goto || echo cd') fnameescape($FZF_PICK)
\| endif
" ------------------------------------------------------------------------------
" viewers and pre-viewers
" HINT: use, f.e., ":f g" on an image to get geeqie to run (default is sxiv)
" Pdf etc
filextype *.epub,*.pdf,*.ps {okular}okular %f %i &, mupdf %f %i &,
fileviewer *.epub $HOME/bin/preview-epub
fileviewer *.pdf pdftotext -nopgbrk %c -
" Audio
filetype *.wav,*.mp3,*.flac,*.m4a,*.wma,*.ac3,*.og[agx] mpv %f %i &
fileviewer *.mp3 mediainfo
" Video
filextype *.avi,*.mp4,*.wmv,*.3gp,*.ogv,*.mkv,*.mpg,*.mpeg,*.vob,
\*.fl[icv],*.m2v,*.mov,*.webm,*.ts,*.mts,*.m4v,*.r[am],*.qt,*.divx,
\*.as[fx]
\ {View using mpv}
\ mpv %f %i &,
fileviewer *.avi,*.mp4,*.wmv,*.dat,*.3gp,*.ogv,*.mkv,*.mpg,*.mpeg,*.vob,
\*.fl[icv],*.m2v,*.mov,*.webm,*.ts,*.mts,*.m4v,*.r[am],*.qt,*.divx,
\*.as[fx]
\ exiftool-filtered %c 2>&1
" Web
filextype *.html,*.htm
\ {Open with firefox}
\ firefox %f &,
filetype *.html,*.htm links, lynx
" Man page
filetype *.[1-8] man -l %c
fileviewer *.[1-8] man -l %c | col -b
filetype *.[1-8].gz man -l %c
fileviewer *.[1-8].gz man -l %c | col -b
" Images
" - note we use `--browse` in the single file mode because our pqivrc already has it, and it is a toggle
filextype *.bmp,*.jpg,*.jpeg,*.png,*.gif,*.xpm,*.tif,*.tiff
\ {Single file pqiv}
\ pqiv --max-depth=0 --disable-backends=archive %f 2>/tmp/vifm.pqiv.error.$USER &,
\ {Unrestricted pqiv/image under cursor is repeated}
\ env D=%D pqiv --browse %c 2>/tmp/vifm.pqiv.error.$USER &,
\ {exiftool filtered}
\ exiftool-filtered %f %m 2>&1,
fileviewer *.bmp,*.jpg,*.jpeg,*.png,*.gif,*.xpm,*.tif,*.tiff
\ exiftool-filtered %c,
" notes: pqiv max-depth=0 assumes "browse=1" in pqivrc
" the D=%D assumes something in pqiv's config which will move/copy a file to "$D"
" XXX doesn't seem to work: fileviewer *.jpg,*.png shellpic %c
" GPG signature
filetype *.asc
\ {Check signature}
\ !!gpg --verify %c,
" zip files
filetype *.zip
\ {Vim!}
\ vim %c,
\ {View contents}
\ unzip -l %c | less,
\ {Extract in %D}
\ unzip -d %D %c | less
fileviewer *.zip,*.jar,*.war,*.ear,*.oxt unzip -l %c
" tar files
filetype *.tar,*.tar.bz2,*.tbz2,*.tgz,*.tar.gz,*.tar.xz,*.txz
\ {Vim!}
\ vim %c,
\ {View contents}
\ tar -tvf %c | less,
\ {Extract in %D}
\ tar -C %D -xf %c | less,
fileviewer *.tar,*.tar.bz2,*.tbz2,*.tgz,*.tar.gz,*.tar.xz,*.txz tar -tvf %c
" rare formats; only view
fileviewer *.rar unrar v %c
fileviewer *.7z 7z l %c
" Office files
filextype *.odt,*.doc,*.docx,*.ods,*.xls,*.xlsx,*.odp,*.ppt,*.pptx libreoffice %f 2>/dev/null &
" ??? fileviewer *.doc catdoc %c
fileviewer *.odt,*.doc,*.docx unoconv -f text --stdout %c
fileviewer *.ods,*.xls,*.xlsx unoconv -f csv --stdout %c
" Everything else
" NO: filetype * xdg-open
" do not use this; if DISPLAY is unset (like in a remote connection), this
" causes even vim to misbehave (contention between vim and vifm for terminal!)
" Preview should syntax highlight if possible
fileviewer *[^/] highlight -O xterm256 --force -s pablo %c
" 'l' toggles showing a git log of entry (whether it is a directory or a file)
nnoremap l :if &previewprg == '' | set previewprg='git -c color.status=always s; git log --stat --decorate=short --color -- %c 2>&1' | view! | else | set previewprg='' | view | endif<cr>
nnoremap <c-f> :FZFcd<cr>
" ------------------------------------------------------------------------------
" Mappings
" HELP: l -- show git log for file or dir
" HELP: <C-F> -- find file or dir using fzf and go to it
" HELP: <Del> -- delete selected files
" HELP: VV select -- select all
" HELP: J|K move -- move cursor in other pane
" HELP: o display -- sort menu
" HELP: ss display -- sort by size
" HELP: w display -- preview mode toggle
" HELP: W display -- preview mode -- wrap toggle
" HELP: x _play -- run mpv on file and subtitle
" HELP: <|> display -- inc/dec pane width
" HELP: SPC display -- select file and move down
" HELP: c* display -- compare -- by name/contents, list dups/unique, one/two panes
" HELP: rw display -- switch windows to regular from custom
" HELP: cd nav -- cd elsewhere
" HELP: gr find -- files by content (grep)
" HELP: // find -- files by name (locate, with a custom locateprg)
" HELP: E edit -- selected files in gvim remote
" HELP: cp change -- cp current file *with* parents to other side
" HELP: dv change -- run vimdiff on %c %D/%c
" HELP: dV change -- run vimdiff on %c %C
" HELP: I change -- rename by adding prefix
" HELP: A change -- rename by adding suffix
" HELP: yd extern -- clip directory name TODO: DOES NOT WORK
" HELP: yf extern -- clip file name TODO: DOES NOT WORK
" HELP: b extern -- start a shell, setting $c, $C, $f, and $D
" HELP: ! extern -- :!! raf <cursor> %c
" HELP: @ extern -- :!!
nnoremap <delete> :!ls -ald %f; echo -n "remove these files? "; vifm-pause; rm -rf %f %n<cr>
nnoremap VV :%select<cr>
nnoremap <silent> J <space>j<space>
nnoremap <silent> K <space>k<space>
nnoremap o :sort<cr>
" this one starts a bg task; wait a bit and run it again or just run "Ss" again
nnoremap ss :%select<CR>ga:set sort=-size,+dir<cr>
nnoremap w :view<cr>
nnoremap W :set wrap!<cr>
nnoremap x :!dm __ _play %f &<cr>
" bloody thing does not work without the "&"
nnoremap < <c-w>4<
nnoremap > <c-w>4>
nmap <space> tj
nnoremap cc :compare<CR>
nnoremap cd1 :compare bycontents listdups ofone<CR>
nnoremap cd2 :compare bycontents listdups ofboth<CR>
nnoremap cu1 :compare bycontents listunique ofone<CR>
nnoremap cu2 :compare bycontents listunique ofboth<CR>
nnoremap ca1 :compare bycontents listall ofone<CR>
nnoremap ca2 :compare bycontents listall ofboth<CR>
nnoremap cnd1 :compare byname listdups ofone<CR>
nnoremap cnd2 :compare byname listdups ofboth<CR>
nnoremap cnu1 :compare byname listunique ofone<CR>
nnoremap cnu2 :compare byname listunique ofboth<CR>
nnoremap cna1 :compare byname listall ofone<CR>
nnoremap cna2 :compare byname listall ofboth<CR>
nnoremap rw :set viewcolumns=|regular<cr>
nnoremap cd :cd<space>
nnoremap gr :!vim "+VG "<Left>
set locateprg="find | grep -i %a | sort"
nnoremap // :locate<space>
" HINT: using "enter" will open it in a new gvim (for text-ish files anyway)
nnoremap E :!gvim --remote-silent %f<cr>
" Open file in the background using its default program
" ??? nnoremap gb :file &<cr>l
" nnoremap cp :!!cp -v -r --parents %f %D<CR>
nnoremap dv :!vimdiff %c %D/%c<CR>
nnoremap dV :!vimdiff %c %C<CR>
nnoremap I cw<c-a>
nnoremap A cw
" nnoremap cc cw<c-u>
nnoremap yd :!echo %d | xsel -b %i<cr>
nnoremap yf :!echo %c:p | xsel -b %i<cr>
" if needed, use this, maybe with a different map:
" nnoremap yf :!printf "%%s\n" %f:p | xclip -selection clipboard %i<cr>
nnoremap sh :shell<cr>
nnoremap b :!env c="%c" C="%C" f="%f" D="%D" $SHELL<cr>
nnoremap ! :!! raf %c<Left><Left>
nnoremap @ :!
nnoremap qq :quit<cr>
" Example of standard two-panel file managers mappings
nnoremap <f3> :!less -c %f<cr>
nnoremap <f4> :edit<cr>
nnoremap <f5> :copy &<cr>
nnoremap <f6> :move &<cr>
nnoremap <f7> :mkdir!<space>
nnoremap <f8> :delete<cr>
nnoremap B :bmarks