mirror of
https://github.com/junegunn/fzf.vim.git
synced 2026-01-18 09:05:15 +08:00
Do not override existing commands
So that we don't have to use VimEnter autocmd to override the commands
This commit is contained in:
@@ -187,9 +187,31 @@ You can use autoload functions to define your own commands.
|
||||
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
|
||||
" Override Colors command. You can safely do this in your .vimrc as fzf.vim
|
||||
" will not override existing commands.
|
||||
command! Colors
|
||||
\ call fzf#vim#colors({'left': '15%', 'options': '--reverse --margin 30%,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
|
||||
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)
|
||||
<
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user