Skip to content

Instantly share code, notes, and snippets.

@carbolymer
Created April 21, 2020 10:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carbolymer/6bffdecb5afb426a1c24f80434e4d9be to your computer and use it in GitHub Desktop.
Save carbolymer/6bffdecb5afb426a1c24f80434e4d9be to your computer and use it in GitHub Desktop.
fff
" :Rg with default search for cword
function! s:p(bang, ...)
let preview_window = get(g:, 'fzf_preview_window', a:bang && &columns >= 80 || &columns >= 120 ? 'right': '')
if len(preview_window)
return call('fzf#vim#with_preview', add(copy(a:000), preview_window))
endif
return {}
endfunction
function! s:callRipgrep(txt)
if empty(a:txt)
let l:searchString = expand('<cword>')
else
let l:searchString = a:txt
endif
call fzf#vim#grep("rg --column --line-number --no-heading --color=always --smart-case ".shellescape(l:searchString), 1, s:p(!0), !0)
endfun
command! -bang -nargs=* Rg call s:callRipgrep(<q-args>)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment