fzf 配置指南

警告
本文最后更新于 2023-04-16,文中内容可能已过时。

配置

快捷键

  • ctr-n 向下移动
  • ctr-p 向上移动

tmux

zsh

  • ctr-t
  • ctr-r
  • alt-c

vim

  • vim ** <tab>: 进入模糊匹配
  • ;ff
 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
"fzf
" This is the default option:
"   - Preview window on the right with 50% width
"   - CTRL-/ will toggle preview window.
" - Note that this array is passed as arguments to fzf#vim#with_preview function.
" - To learn more about preview window options, see `--preview-window` section of `man fzf`.
let g:fzf_preview_window = ['right:50%', 'ctrl-/']
" Preview window on the upper side of the window with 40% height,
" hidden by default, ctrl-/ to toggle
let g:fzf_preview_window = ['up:40%:hidden', 'ctrl-/']
" Empty value to disable preview window altogether
let g:fzf_preview_window = []
" [Buffers] Jump to the existing window if possible
let g:fzf_buffers_jump = 1
" [[B]Commits] Customize the options used by 'git log':
let g:fzf_commits_log_options = '--graph --color=always --format="%C(auto)%h%d %s %C(black)%C(bold)%cr"'
" [Tags] Command to generate tags file
let g:fzf_tags_command = 'ctags -R'
" [Commands] --expect expression for directly executing the command
let g:fzf_commands_expect = 'alt-enter,ctrl-x'
" Mapping selecting mappings
nmap <leader><tab> <plug>(fzf-maps-n)
xmap <leader><tab> <plug>(fzf-maps-x)
omap <leader><tab> <plug>(fzf-maps-o)
nmap <C-p> :Files<CR>
nmap <C-e> :Buffers<CR>
nmap <leader>ff :Files<CR>
let g:fzf_action = { 'ctrl-e': 'edit'  }

" Insert mode completion
imap <c-x><c-k> <plug>(fzf-complete-word)
imap <c-x><c-f> <plug>(fzf-complete-path)
imap <c-x><c-l> <plug>(fzf-complete-line)
" call fzf

预览窗口

1
2
3
4
5
6
## install highlight
sudo apt-get install highlight

antigen bundle unixorn/fzf-zsh-plugin@main
export FZF_DEFAULT_COMMAND="--exclude={.git,.idea,.vscode,.sass-cache,node_modules,build}"
export FZF_DEFAULT_OPTS="--height 40% --layout=reverse --preview '(highlight -O ansi {} || cat {}) 2> /dev/null | head -500'"

相关内容

william 支付宝支付宝
william 微信微信
0%