Mistake Leading to Awesome Insertion Phenomenon
- Dominant language
- Vim Script
- Stars
- 10.3k
- Forks
- 608
- Avg merge
- 5d 8h
- Merged PRs (30d)
- 2
Description
## Checklist
### Documentation Check
- [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
### `fzf` Version Information
```
> fzf --version
0.20.0
```
### OS Info
```
/:-------------:\ cedarprince@obsidian
:-------------------:: --------------------
:-----------/shhOHbmp---:\ OS: Fedora x86_64
/-----------omMMMNNNMMD ---: Host: XPS 15 7590
:-----------sMMMMNMNMP. ---: Kernel: 5.6.13-100.fc30.x86_64
:-----------:MMMdP------- ---\ Uptime: 20 hours, 31 mins
,------------:MMMd-------- ---: Shell: zsh
:------------:MMMd------- .---: Resolution: 1920x1080
:---- oNMMMMMMMMMNho .----: DE: Plasma
:-- .+shhhMMMmhhy++ .------/ WM Theme: Sweet-Dark-transparent
:- -------:MMMd--------------: CPU: Intel i7-9750H (12) @ 4.500GHz
:- --------/MMMd-------------; Memory: 5931MiB / 15639MiB
:- ------/hMMMy------------:
:-- :dMNdhhdNMMNo------------;
:---:sdNMMMMNds:------------:
:------:://:-------------::
:---------------------://
```
### Vim Info
```
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Apr 17 2020 05:10:37)
Included patches: 1-587
Modified by
Compiled by
```
## Background
This is a great extension @junegunn ! I absolutely love it! :heart:
I accidentally made an error with setting up my `.vimrc` and discovered a pleasant result that I was wondering if I could help with implementing correctly! I was following the documentation found in the `README-VIM` to configure path completion. I decided to experiment and ran the following line in my set-up:
`inoremap fzf#vim#complete#path('rg .')`
To my surprise, not only did this "work" I also had a fascinating result where it inserted the selected line from `fzf` into my current file. Here is an example of this behavior:

## Problem
I am trying to implement this behavior "correctly" now where I use `fzf#vim#grep` to both have this insertion behavior as well as a contextual preview of the file I am looking at.
So far, I have attempted this as a command:
```vim
command! -bang -nargs=* RgTest
\ call fzf#vim#grep(
\ 'rg --column --line-number --no-heading --color=always --smart-case -- '.shellescape(), 1,
\ fzf#vim#with_preview(), 0)
```
Which I then have tried converting to a map:
`inoremap fzf#vim#grep('rg .'.shellescape(), 1, fzf#vim#with_preview(), 0)`
However, I continue to fail to both render a preview of the file using `fzf#vim#with_preview()` and have the insertion behavior.
Could anyone help me with achieving this behavior as I am unsure of what to do? Thanks!
## Minimal `.vimrc`
```vim
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" VIM SETTINGS
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" TURNS LINE NUMBERING ON
set nu
" ENABLES A SYSTEM-WIDE VIMRC
set nocompatible
" ENSURES DEFAULT VIM SYNTAX HIGHLIGHTING
syntax on
set encoding=utf-8
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" PLUGINS
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" ENABLES PLUGINS TO WORK
filetype plugin on
" Command line fuzzy finder
Plug 'junegunn/fzf', { 'do': './install --bin' } "Checks latest fzf binary
Plug 'junegunn/fzf.vim'
call plug#end()
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" KEY REMAPS
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Enables ripgrep for file completion via fzf
inoremap fzf#vim#complete#path('rg --files')
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.