Hot answers tagged

6

The Vim fzf plug-in has a native feature to open the selected item in a new tab. If you type Ctrl+T inside the fzf selection window, it will tell Vim to open the item in a new tab (when applicable.) See here, below the table it says: Most commands support CTRL-T / CTRL-X / CTRL-V key bindings to open in a new tab, a new split, or in a new vertical split. ...


5

Another solution is to use an abbreviation: cnoreabbrev <expr> fzf (getcmdtype() == ':' && getcmdline() =~ '^fzf$')? 'FZF' : 'fzf' You check that the command line type is : and that you only have fzf in your command (to avoid messing with e.g :call fzf#vim#rg(...)) and if it is the case your replace your command with FZF otherwise you keep the ...


4

The arguments you pass to :FZF are split at spaces and tabs, because :FZF uses the escape sequence <f-args>. This means that Vim splits the arguments on these 2 spaces: :FZF --preview 'cat {}' ^ ^ ✔ ✘ You don't want Vim to split the arguments at the second space. Instead you want the space to be embedded into the ...


4

I'm not sure why this error occurs (I have exactly the same here), however there's a workaround. So this is not a direct answer, but I hope it helps nonetheless. You can set defaults options for FZF in your shell config file. In my case, my .bashrc holds those lines: export FZF_DEFAULT_OPTS="-m" FZF_DEFAULT_OPTS+=" --color='light'" FZF_DEFAULT_OPTS+=" --...


3

You can use :Files [PATH] for this. See the command reference. To pass in the directory: :Files %:p:h Alternatively, you can also use lcd to change the directory for the current window, then use FZF as normal.


3

You need to use an expr mapping: cnoremap <expr> fzf getcmdtype() isnot# ':' ? 'fzf' : 'FZF' You could also (maybe?) use a self-destroying mapping: augroup fzf_mapping autocmd! autocmd CmdlineEnter : cnoremap fzf FZF autocmd CmdlineLeave : cunmap fzf augroup END


2

Seems to be using the 'oldfiles' in vim where it's location can be determined by the following answer: https://vi.stackexchange.com/a/17260/13656 In my case it's ~/.local/share/nvim/shada/main.shada.


2

:History command operates on :oldfiles result which is stored in v:oldfiles variable that is loaded from viminfo. You can change it by changing viminfo, there might be better approach, but anyways: the value to adjust is '100 (default) check current value with :set viminfo (mine is: '100,<50,s10,h,rA:,rB:) change '100 to whatever you want, for example ...


2

how could I send the in word as an argument? expand('<cword>') Also see :h expand() for a full list of specials.


2

While I'm not entirely sure deleting this command is a great idea you can do it using an autocommand like this in your vimrc: augroup deletePluginCommand autocmd! autocmd VimEnter * delcommand Windows augroup END If you are not familiar with autocommands, they are a way to trigger some code on an event (see :h autocmd) and here we use the event ...


2

fzf.vim provides several commands suited for this task: :Rg which uses ripgrep :Ag which uses the Silver Searcher (ag) These are external tools, they must be installed on the system (e.g. install ripgrep on a Debian based system:) sudo apt install ripgrep It is also possible to use fzf as a wrapper for gitgrep. The link above provides a Ggrep command to ...


1

On MacOS and Linux, this seems to work in vim (but not neovim): :set noshelltemp Afterwards this works as hoped. :r ! echo -e 'foo\nbar\nbaz' | fzf -m


1

you can execute command in insert like that <C-o>:echo "test"<cr> : inoremap <leader>k <C-o>:fzf#vim#complete#word({'window': { 'width': 0.2, 'height': 0.9, 'xoffset': 1 }})<cr>


1

It turns out I was overthinking this and I also missed some of the documentation. fzf#run can accept an arbitrary command which returns a list of files. A working example without a preview window: command! GDomo \ call fzf#run({'source': 'git diff -w -M origin/main...HEAD --name-only', 'sink': 'e'}) A working example with a preview window: command! GDomo ...


1

Thanks to @d-ben-knoble, in my case I had vim-surround in my vimrc which was causing this behaviour I removed that and now is fixed.


1

I solved this problem by using neovim instead of vim. Neovim gave me a better error message: unkown option: --layout=reverse-list from there i realized that I was using an outdated version of fzf, and neovim updated and problem solved!


1

I assume the arguments of grep are similar to fzf#run. If that is the case you need to set: { 'dir': getcwd(), 'options': '-n 2'} The -n tells the column that is relevant for the search. You can do man fzf for more details.


1

You need :Windows instead of :Buffers because output of that command has a tab column.


1

You can do something like that: function! HandleFZF(file) echo a:file endfunction command! -nargs=1 HandleFZF :call HandleFZF(<f-args>) Then, to invoke fzf, run: call fzf#run({'sink': 'HandleFZF'})


1

No, it isn't the normal behavior for fzf.vim. I was able to backspace normally to delete typed text. Check your mappings by running :map <Backspace>.


Only top voted, non community-wiki answers of a minimum length are eligible