diff --git a/README.md b/README.md index 4b37d30..380a3b4 100644 --- a/README.md +++ b/README.md @@ -69,8 +69,10 @@ Commands | `Helptags` | Help tags [1](#helptags) | - Most commands support `CTRL-T` / `CTRL-X` / `CTRL-V` key - bindings to open in a new tab, a new split, or in a new vertical split. + bindings to open in a new tab, a new split, or in a new vertical split - Bang-versions of the commands (e.g. `Ag!`) will open fzf in fullscreen +- You can set `g:fzf_command_prefix` to give the same prefix to the commands + - e.g. `let g:fzf_command_prefix = 'Fzf'` and you have `FzfFiles`, etc. (1: `Helptags` will shadow the command of the same name from [pathogen][pat]. But its functionality is still available via `call diff --git a/doc/fzf-vim.txt b/doc/fzf-vim.txt index ff4e945..3a346bb 100644 --- a/doc/fzf-vim.txt +++ b/doc/fzf-vim.txt @@ -96,8 +96,10 @@ COMMANDS *fzf-vim-commands* -----------------+--------------------------------------------------------------------- - Most commands support CTRL-T / CTRL-X / CTRL-V key bindings to open in a new - tab, a new split, or in a new vertical split. + tab, a new split, or in a new vertical split - Bang-versions of the commands (e.g. `Ag!`) will open fzf in fullscreen + - You can set `g:fzf_command_prefix` to give the same prefix to the commands + - e.g. `let g:fzf_command_prefix = 'Fzf'` and you have `FzfFiles`, etc. (1: `Helptags` will shadow the command of the same name from {pathogen}{8}. But its functionality is still available via `call pathogen#helptags()`.) diff --git a/plugin/fzf.vim b/plugin/fzf.vim index 1a9e64b..218c11c 100644 --- a/plugin/fzf.vim +++ b/plugin/fzf.vim @@ -30,22 +30,34 @@ function! s:w(bang) return a:bang ? {} : copy(get(g:, 'fzf_layout', g:fzf#vim#default_layout)) endfunction -command! -bang -nargs=? -complete=dir Files call fzf#vim#files(, s:w(0)) -command! -bang Buffers call fzf#vim#buffers(s:w(0)) -command! -bang Lines call fzf#vim#lines(s:w(0)) -command! -bang BLines call fzf#vim#buffer_lines(s:w(0)) -command! -bang Colors call fzf#vim#colors(s:w(0)) -command! -bang -nargs=1 Locate call fzf#vim#locate(, s:w(0)) -command! -bang -nargs=* Ag call fzf#vim#ag(, s:w(0)) -command! -bang Tags call fzf#vim#tags(s:w(0)) -command! -bang BTags call fzf#vim#buffer_tags(s:w(0)) -command! -bang Snippets call fzf#vim#snippets(s:w(0)) -command! -bang Commands call fzf#vim#commands(s:w(0)) -command! -bang Marks call fzf#vim#marks(s:w(0)) -command! -bang Helptags call fzf#vim#helptags(s:w(0)) -command! -bang Windows call fzf#vim#windows(s:w(0)) -command! -bang Commits call fzf#vim#commits(s:w(0)) -command! -bang BCommits call fzf#vim#buffer_commits(s:w(0)) +function! s:defs(commands) + let prefix = get(g:, 'fzf_command_prefix', '') + if prefix =~# '^[^A-Z]' + echoerr 'g:fzf_command_prefix must start with an uppercase letter' + return + endif + for command in a:commands + execute substitute(command, '\ze\C[A-Z]', prefix, '') + endfor +endfunction + +call s:defs([ +\'command! -bang -nargs=? -complete=dir Files call fzf#vim#files(, s:w(0))', +\'command! -bang Buffers call fzf#vim#buffers(s:w(0))', +\'command! -bang Lines call fzf#vim#lines(s:w(0))', +\'command! -bang BLines call fzf#vim#buffer_lines(s:w(0))', +\'command! -bang Colors call fzf#vim#colors(s:w(0))', +\'command! -bang -nargs=1 Locate call fzf#vim#locate(, s:w(0))', +\'command! -bang -nargs=* Ag call fzf#vim#ag(, s:w(0))', +\'command! -bang Tags call fzf#vim#tags(s:w(0))', +\'command! -bang BTags call fzf#vim#buffer_tags(s:w(0))', +\'command! -bang Snippets call fzf#vim#snippets(s:w(0))', +\'command! -bang Commands call fzf#vim#commands(s:w(0))', +\'command! -bang Marks call fzf#vim#marks(s:w(0))', +\'command! -bang Helptags call fzf#vim#helptags(s:w(0))', +\'command! -bang Windows call fzf#vim#windows(s:w(0))', +\'command! -bang Commits call fzf#vim#commits(s:w(0))', +\'command! -bang BCommits call fzf#vim#buffer_commits(s:w(0))']) function! s:history(arg, bang) let bang = a:bang || a:arg[len(a:arg)-1] == '!'