Skip to content
Myr

[vim] External terminal emulator for GVim

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

authored by Junegunn Choi · committed by Junegunn Choi · parent f58a53a · Browse files · 2 files+20 added−20 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+20 added−20 removed

  • other:+20 added−20 removed

2 files+20 added−20 removed

modified:plugin/fzf.vim+7 added-11 removed
22 unmodified lines
2324let s:min_tmux_width = 1025let s:min_tmux_height = 326let s:default_tmux_height = '40%'27let s:gui_supported = executable('bash') && executable('xterm')27let s:launcher = 'xterm -e bash -ic %s'2829let s:cpo_save = &cpo30set cpo&vim31
35 unmodified lines
67 return substitute(a:path, ' ', '\\ ', 'g')68endfunction6970function! fzf#run(...) abort71 if has('gui_running') && !s:gui_supported72 echohl Error73 echo 'bash and xterm required to run fzf in GVim'74 return []75 endif7671 let dict = exists('a:1') ? a:1 : {}72 let temps = { 'result': tempname() }73 let optstr = get(dict, 'options', '')74
43 unmodified lines
118function! s:execute(dict, command, temps)119 call s:pushd(a:dict)120 silent !clear121 if has('gui_running')128 let xterm_options = get(a:dict, 'xterm_options', get(g:, 'fzf_xterm_options', ''))129 execute "silent !xterm ".xterm_options.130 \ " -e bash -ic '".substitute(a:command, "'", "'\"'\"'", 'g')."'"122 let launcher = get(a:dict, 'launcher', get(g:, 'fzf_launcher', s:launcher))123 let command = printf(launcher, "'".substitute(a:command, "'", "'\"'\"'", 'g')."'")124 else132 execute 'silent !'.a:command125 let command = a:command126 endif127 execute 'silent !'.command128 redraw!129 if v:shell_error130 echohl Error131 echo 'Error running ' . command132 return []133 else134 return s:callback(a:dict, a:temps, 0)135 endif
94 unmodified lines
modified:README.md+13 added-9 removed
285 unmodified lines
286287Usage as Vim plugin288-------------------289290(Note: To use fzf in GVim, bash and xterm are required.)290(Note: To use fzf in GVim, an external terminal emulator is required.)291292### `:FZF[!]`293294If you have set up fzf for Vim, `:FZF` command will be added.
15 unmodified lines
310If you're on a tmux session, `:FZF` will launch fzf in a new split-window whose311height can be adjusted with `g:fzf_tmux_height` (default: '40%'). However, the312bang version (`:FZF!`) will always start in fullscreen.313314In GVim, `xterm` command will be used to launch fzf. You can set options to315`xterm` command with `g:fzf_xterm_options`. For example,314In GVim, you need an external terminal emulator to start fzf with. `xterm`315command is used by default, but you can customize it with `g:fzf_launcher`.316317```vim318let g:fzf_xterm_options = '-geometry 120x30'318" This is the default. %s is replaced with fzf command319let g:fzf_launcher = 'xterm -e bash -ic %s'320321" Use urxvt instead322let g:fzf_launcher = 'urxvt -geometry 120x30 -e sh -c %s'323```324325### `fzf#run([options])`326
11 unmodified lines
338| `options` | string | Options to fzf |339| `dir` | string | Working directory |340| `tmux_width` | number/string | Use tmux vertical split with the given height (e.g. `20`, `50%`) |341| `tmux_height` | number/string | Use tmux horizontal split with the given height (e.g. `20`, `50%`) |338| `xterm_options` | string | Options to `xterm` command (Only used in GVim) |342| `launcher` | string | External terminal emulator to start fzf with (Only used in GVim) |343344#### Examples345346If `sink` option is not given, `fzf#run` will simply return the list.
17 unmodified lines
364nnoremap <silent> <Leader>C :call fzf#run({365\ 'source':366\ map(split(globpath(&rtp, "colors/*.vim"), "\n"),367\ "substitute(fnamemodify(v:val, ':t'), '\\..\\{-}$', '', '')"),364\ 'sink': 'colo',365\ 'options': '+m',366\ 'tmux_width': 20,367\ 'xterm_options': '-geometry 20x30'368\ 'sink': 'colo',369\ 'options': '+m',370\ 'tmux_width': 20,371\ 'launcher': 'xterm -geometry 20x30 -e bash -ic %s'372\ })<CR>373```374375`sink` option can be a function reference. The following example creates a
176 unmodified lines