junegunn / junegunn/fzf.vim

Help needed: advanced vim configuration

Open
#1,443 2 comments 3 reactions 0 assignees View on GitHub
Dominant language
Vim Script
Stars
10.3k
Forks
608
Avg merge
5d 8h
Merged PRs (30d)
2

Description

- [x] I have fzf 0.30.0 or above
- [x] I have read through https://github.com/junegunn/fzf.vim/blob/master/README.md
- [x] I have read through https://github.com/junegunn/fzf/blob/master/README-VIM.md
- [x] I have read through the manual page of fzf (`man fzf`)
- [x] I have searched through the existing issues

**Too stupid for customized RG Command in vim - help needed please.**

Hey guys, i am having trouble adapting an advanced vim command explained in your Readme file already and i cannot get it to run as i'd like to.

The following snippet is from my vimrc and it should introduce 2 shortcuts if `rg` is available as a bash command:
1. Cmd-F should open an interactive search window where i can enter a search term followed by an optional path e.g. `C-F foo app/` should open the interactive search window, i enter the phrase foo as a search keyword and want to limit the search results on the app directory
2. `K` should act the same as Cmd-F with the difference that it has already a search term prefilled (the full word under the cursor)

Everything works as expected except the limitation to the given directory. What am i doing wrong here?

```
if executable("rg")
function! RipgrepFzf(query, fullscreen)
let command_fmt = 'rg --column --line-number --no-heading --color=always --smart-case -- %s || true'
let initial_command = printf(command_fmt, shellescape(a:query))
let reload_command = printf(command_fmt, '{q}')
let spec = {'options': ['--phony', '--query', a:query, '--bind', 'change:reload:'.reload_command]}
call fzf#vim#grep(initial_command, 1, fzf#vim#with_preview(spec), a:fullscreen)
endfunction

command! -nargs=* -bang RG call RipgrepFzf(, 0)

noremap :RG
nnoremap K :RG
endif
```

Any help or suggestions are appreciated (even if it's only coding style due to me being new in vim and configuring it)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.