mirror of
https://github.com/junegunn/fzf.vim.git
synced 2026-01-30 14:45:30 +08:00
Add fzf#vim#with_preview function for previewing search result
Close #225
This commit is contained in:
30
README.md
30
README.md
@@ -152,18 +152,40 @@ let g:fzf_tags_command = 'ctags -R'
|
||||
let g:fzf_commands_expect = 'alt-enter,ctrl-x'
|
||||
```
|
||||
|
||||
#### Advanced customization using autoload functions
|
||||
#### Advanced customization
|
||||
|
||||
You can use autoload functions to define your own commands.
|
||||
|
||||
```vim
|
||||
" git grep
|
||||
" Command for git grep
|
||||
" - fzf#vim#grep(command, with_column, [options], [fullscreen])
|
||||
command! -bang -nargs=* GGrep
|
||||
\ call fzf#vim#grep('git grep --line-number '.shellescape(<q-args>), 0, <bang>0)
|
||||
|
||||
" We use VimEnter event so that the code is run after fzf.vim is loaded
|
||||
autocmd VimEnter * command! Colors
|
||||
\ call fzf#vim#colors({'left': '15%', 'options': '--reverse --margin 30%,0'})
|
||||
autocmd VimEnter * command! -bang Colors
|
||||
\ call fzf#vim#colors({'left': '15%', 'options': '--reverse --margin 30%,0'}, <bang>0)
|
||||
|
||||
" Augmenting Ag command using fzf#vim#with_preview function
|
||||
" * fzf#vim#with_preview([[options], preview window, [toggle keys...]])
|
||||
" * Preview script requires Ruby
|
||||
" * Install Highlight or CodeRay to enable syntax highlighting
|
||||
"
|
||||
" :Ag - Start fzf with hidden preview window that can be enabled with "?" key
|
||||
" :Ag! - Start fzf in fullscreen and display the preview window above
|
||||
autocmd VimEnter * command! -bang -nargs=* Ag
|
||||
\ call fzf#vim#ag(<q-args>,
|
||||
\ <bang>0 ? fzf#vim#with_preview('up:60%')
|
||||
\ : fzf#vim#with_preview('right:50%:hidden', '?'),
|
||||
\ <bang>0)
|
||||
|
||||
" Similarly, we can apply it to fzf#vim#grep. To use ripgrep instead of ag:
|
||||
command! -bang -nargs=* Rg
|
||||
\ call fzf#vim#grep(
|
||||
\ 'rg --column --line-number --no-heading --color=always '.shellescape(<q-args>), 1,
|
||||
\ <bang>0 ? fzf#vim#with_preview('up:60%')
|
||||
\ : fzf#vim#with_preview('right:50%:hidden', '?'),
|
||||
\ <bang>0)
|
||||
```
|
||||
|
||||
Mappings
|
||||
|
||||
Reference in New Issue
Block a user