[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
Provenance
- Commit
853012c- Tree
b79651d- Author
Junegunn Choi <junegunn.c@gmail.com>- Committer
Junegunn Choi <junegunn.c@gmail.com>- Parent
2add45f
2 files changed+14 added−28 removed
modified:plugin/fzf.vim+9 added-6 removed
306 unmodified lines307 308 return lines309 endfunction310 311+let s:default_action = {312+ \ 'ctrl-m': 'e',313+ \ 'ctrl-t': 'tabedit',314+ \ 'ctrl-x': 'split',315+ \ 'ctrl-v': 'vsplit' }316+317 function! 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 endfor326 endfunction327 328 function! 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 endif11 unmodified linesmodified:README.md+5 added-22 removed
274 unmodified lines275 :FZF ~276 277 " With options278 :FZF --no-sort -m /tmp279+280+" Bang version starts in fullscreen instead of using tmux pane or Neovim split281+:FZF!282 ```283 284 Similarly 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,286 in new tabs, in horizontal splits, or in vertical splits respectively.287 285-Note that the environment variables `FZF_DEFAULT_COMMAND` and `FZF_DEFAULT_OPTS`286-also apply here.288+Note that the environment variables `FZF_DEFAULT_COMMAND` and289+`FZF_DEFAULT_OPTS` also apply here.290 288-If you're on a tmux session or using Neovim, `:FZF` will launch fzf in a289-split-window whose height can be adjusted with `g:fzf_height` (default:290-'40%'). However, the bang version (`:FZF!`) will always start in fullscreen.291-292-In GVim, you need an external terminal emulator to start fzf with. `xterm`293-command is used by default, but you can customize it with `g:fzf_launcher`.294-295-```vim296-" This is the default. %s is replaced with fzf command297-let g:fzf_launcher = 'xterm -e bash -ic %s'298-299-" Use urxvt instead300-let g:fzf_launcher = 'urxvt -geometry 120x30 -e sh -c %s'301-```302-303-If you're running MacVim on OSX, I recommend you to use iTerm2 as the launcher.304-Refer to the [this wiki305-page](https://github.com/junegunn/fzf/wiki/On-MacVim-with-iTerm2) to see how306-to set up.307-291 #### `fzf#run([options])`292 293 For more advanced uses, you can call `fzf#run()` function which returns the list294 of the selected items.201 unmodified lines