Skip to content
Myr

[vim] Add g:fzf_action for customizing key bindings

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Close #189

authored by Junegunn Choi · committed by Junegunn Choi · parent 2add45f · Browse files · 2 files+14 added−28 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+14 added−28 removed

  • other:+14 added−28 removed

2 files+14 added−28 removed

modified:plugin/fzf.vim+9 added-6 removed
306 unmodified lines
307308 return lines309endfunction310311let s:default_action = {312 \ 'ctrl-m': 'e',313 \ 'ctrl-t': 'tabedit',314 \ 'ctrl-x': 'split',315 \ 'ctrl-v': 'vsplit' }316317function! s:cmd_callback(lines) abort318 if empty(a:lines)319 return320 endif321 let key = remove(a:lines, 0)316 if key == 'ctrl-t' | let cmd = 'tabedit'317 elseif key == 'ctrl-x' | let cmd = 'split'318 elseif key == 'ctrl-v' | let cmd = 'vsplit'319 else | let cmd = 'e'320 endif322 let cmd = get(s:action, key, 'e')323 for item in a:lines324 execute cmd s:escape(item)325 endfor326endfunction327328function! s:cmd(bang, ...) abort327 let args = extend(['--expect=ctrl-t,ctrl-x,ctrl-v'], a:000)329 let s:action = get(g:, 'fzf_action', s:default_action)330 let args = extend(['--expect='.join(keys(s:action), ',')], a:000)331 let opts = {}332 if len(args) > 0 && isdirectory(expand(args[-1]))333 let opts.dir = remove(args, -1)334 endif
11 unmodified lines
modified:README.md+5 added-22 removed
274 unmodified lines
275:FZF ~276277" With options278:FZF --no-sort -m /tmp279280" Bang version starts in fullscreen instead of using tmux pane or Neovim split281:FZF!282```283284Similarly to [ctrlp.vim](https://github.com/kien/ctrlp.vim), use enter key,285`CTRL-T`, `CTRL-X` or `CTRL-V` to open selected files in the current window,286in new tabs, in horizontal splits, or in vertical splits respectively.287285Note that the environment variables `FZF_DEFAULT_COMMAND` and `FZF_DEFAULT_OPTS`286also apply here.288Note that the environment variables `FZF_DEFAULT_COMMAND` and289`FZF_DEFAULT_OPTS` also apply here.290288If you're on a tmux session or using Neovim, `:FZF` will launch fzf in a289split-window whose height can be adjusted with `g:fzf_height` (default:290'40%'). However, the bang version (`:FZF!`) will always start in fullscreen.291292In GVim, you need an external terminal emulator to start fzf with. `xterm`293command is used by default, but you can customize it with `g:fzf_launcher`.294295```vim296" This is the default. %s is replaced with fzf command297let g:fzf_launcher = 'xterm -e bash -ic %s'298299" Use urxvt instead300let g:fzf_launcher = 'urxvt -geometry 120x30 -e sh -c %s'301```302303If you're running MacVim on OSX, I recommend you to use iTerm2 as the launcher.304Refer to the [this wiki305page](https://github.com/junegunn/fzf/wiki/On-MacVim-with-iTerm2) to see how306to set up.307291#### `fzf#run([options])`292293For more advanced uses, you can call `fzf#run()` function which returns the list294of the selected items.
201 unmodified lines