Coder Social home page Coder Social logo

fzf.vim's Introduction


fzf ❤️ vim

Things you can do with fzf and Vim.

Rationale

fzf itself is not a Vim plugin, and the official repository only provides the basic wrapper function for Vim. It's up to the users to write their own Vim commands with it. However, I've learned that many users of fzf are not familiar with Vimscript and are looking for the "default" implementation of the features they can find in the alternative Vim plugins.

Why you should use fzf on Vim

Because you can and you love fzf.

fzf runs asynchronously and can be orders of magnitude faster than similar Vim plugins. However, the benefit may not be noticeable if the size of the input is small, which is the case for many of the commands provided here. Nevertheless I wrote them anyway since it's really easy to implement custom selector with fzf.

Installation

fzf.vim depends on the basic Vim plugin of the main fzf repository, which means you need to set up both "fzf" and "fzf.vim" on Vim. To learn more about fzf/Vim integration, see README-VIM.

Using vim-plug

Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'

fzf#install() makes sure that you have the latest binary, but it's optional, so you can omit it if you use a plugin manager that doesn't support hooks.

Dependencies

# Installing dependencies using Homebrew
brew install fzf bat ripgrep the_silver_searcher perl universal-ctags

Commands

Command List
:Files [PATH] Files (runs $FZF_DEFAULT_COMMAND if defined)
:GFiles [OPTS] Git files (git ls-files)
:GFiles? Git files (git status)
:Buffers Open buffers
:Colors Color schemes
:Ag [PATTERN] ag search result (ALT-A to select all, ALT-D to deselect all)
:Rg [PATTERN] rg search result (ALT-A to select all, ALT-D to deselect all)
:RG [PATTERN] rg search result; relaunch ripgrep on every keystroke
:Lines [QUERY] Lines in loaded buffers
:BLines [QUERY] Lines in the current buffer
:Tags [PREFIX] Tags in the project (ctags -R)
:BTags [QUERY] Tags in the current buffer
:Changes Changelist across all open buffers
:Marks Marks
:Jumps Jumps
:Windows Windows
:Locate PATTERN locate command output
:History v:oldfiles and open buffers
:History: Command history
:History/ Search history
:Snippets Snippets (UltiSnips)
:Commits [LOG_OPTS] Git commits (requires fugitive.vim)
:BCommits [LOG_OPTS] Git commits for the current buffer; visual-select lines to track changes in the range
:Commands Commands
:Maps Normal mode mappings
:Helptags Help tags 1
:Filetypes File types
  • 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
  • Bang-versions of the commands (e.g. Ag!) will open fzf in fullscreen
  • You can set g:fzf_vim.command_prefix to give the same prefix to the commands
    • e.g. let g:fzf_vim.command_prefix = 'Fzf' and you have FzfFiles, etc.

(1: Helptags will shadow the command of the same name from pathogen. But its functionality is still available via call pathogen#helptags(). )

Customization

Configuration options of the base plugin

Every command in fzf.vim internally calls fzf#wrap function of the main repository which supports a set of global option variables. So please read through README-VIM to learn more about them.

Configuration options for fzf.vim

All configuration values for this plugin are stored in g:fzf_vim dictionary, so make sure to initialize it before assigning any configuration values to it.

" Initialize configuration dictionary
let g:fzf_vim = {}

Preview window

Some commands will show the preview window on the right. You can customize the behavior with g:fzf_vim.preview_window. Here are some examples:

" This is the default option:
"   - Preview window on the right with 50% width
"   - CTRL-/ will toggle preview window.
" - Note that this array is passed as arguments to fzf#vim#with_preview function.
" - To learn more about preview window options, see `--preview-window` section of `man fzf`.
let g:fzf_vim.preview_window = ['right,50%', 'ctrl-/']

" Preview window is hidden by default. You can toggle it with ctrl-/.
" It will show on the right with 50% width, but if the width is smaller
" than 70 columns, it will show above the candidate list
let g:fzf_vim.preview_window = ['hidden,right,50%,<70(up,40%)', 'ctrl-/']

" Empty value to disable preview window altogether
let g:fzf_vim.preview_window = []

" fzf.vim needs bash to display the preview window.
" On Windows, fzf.vim will first see if bash is in $PATH, then if
" Git bash (C:\Program Files\Git\bin\bash.exe) is available.
" If you want it to use a different bash, set this variable.
"   let g:fzf_vim = {}
"   let g:fzf_vim.preview_bash = 'C:\Git\bin\bash.exe'

Command-level options

" [Buffers] Jump to the existing window if possible
let g:fzf_vim.buffers_jump = 1

" [[B]Commits] Customize the options used by 'git log':
let g:fzf_vim.commits_log_options = '--graph --color=always --format="%C(auto)%h%d %s %C(black)%C(bold)%cr"'

" [Tags] Command to generate tags file
let g:fzf_vim.tags_command = 'ctags -R'

" [Commands] --expect expression for directly executing the command
let g:fzf_vim.commands_expect = 'alt-enter,ctrl-x'

List type to handle multiple selections

The following commands will fill the quickfix list when multiple entries are selected.

  • Ag
  • Rg / RG
  • Lines / BLines
  • Tags / BTags

By setting g:fzf_vim.listproc, you can make them use location list instead.

" Default: Use quickfix list
let g:fzf_vim.listproc = { list -> fzf#vim#listproc#quickfix(list) }

" Use location list instead of quickfix list
let g:fzf_vim.listproc = { list -> fzf#vim#listproc#location(list) }

You can customize the list type per command by defining variables named g:fzf_vim.listproc_{command_name_in_lowercase}.

" Command-wise customization
let g:fzf_vim.listproc_ag = { list -> fzf#vim#listproc#quickfix(list) }
let g:fzf_vim.listproc_rg = { list -> fzf#vim#listproc#location(list) }

You can further customize the behavior by providing a custom function to process the list instead of using the predefined fzf#vim#listproc#quickfix or fzf#vim#listproc#location.

" A customized version of fzf#vim#listproc#quickfix.
" The last two lines are commented out not to move to the first entry.
function! g:fzf_vim.listproc(list)
  call setqflist(a:list)
  copen
  wincmd p
  " cfirst
  " normal! zvzz
endfunction

Advanced customization

Vim functions

Each command in fzf.vim is backed by a Vim function. You can override a command or define a variation of it by calling its corresponding function.

Command Vim function
Files fzf#vim#files(dir, [spec dict], [fullscreen bool])
GFiles fzf#vim#gitfiles(git_options, [spec dict], [fullscreen bool])
GFiles? fzf#vim#gitfiles('?', [spec dict], [fullscreen bool])
Buffers fzf#vim#buffers([query string], [bufnrs list], [spec dict], [fullscreen bool])
Colors fzf#vim#colors([spec dict], [fullscreen bool])
Rg fzf#vim#grep(command, [spec dict], [fullscreen bool])
RG fzf#vim#grep2(command_prefix, query, [spec dict], [fullscreen bool])
... ...

(We can see that the last two optional arguments of each function are identical. They are directly passed to fzf#wrap function. If you haven't read README-VIM already, please read it before proceeding.)

Example: Customizing Files command

This is the default definition of Files command:

command! -bang -nargs=? -complete=dir Files call fzf#vim#files(<q-args>, <bang>0)

Let's say you want to a variation of it called ProjectFiles that only searches inside ~/projects directory. Then you can do it like this:

command! -bang ProjectFiles call fzf#vim#files('~/projects', <bang>0)

Or, if you want to override the command with different fzf options, just pass a custom spec to the function.

command! -bang -nargs=? -complete=dir Files
    \ call fzf#vim#files(<q-args>, {'options': ['--layout=reverse', '--info=inline']}, <bang>0)

Want a preview window?

command! -bang -nargs=? -complete=dir Files
    \ call fzf#vim#files(<q-args>, {'options': ['--layout=reverse', '--info=inline', '--preview', 'cat {}']}, <bang>0)

It kind of works, but you probably want a nicer previewer program than cat. fzf.vim ships a versatile preview script you can readily use. It internally executes bat for syntax highlighting, so make sure to install it.

command! -bang -nargs=? -complete=dir Files
    \ call fzf#vim#files(<q-args>, {'options': ['--layout=reverse', '--info=inline', '--preview', '~/.vim/plugged/fzf.vim/bin/preview.sh {}']}, <bang>0)

However, it's not ideal to hard-code the path to the script which can be different in different circumstances. So in order to make it easier to set up the previewer, fzf.vim provides fzf#vim#with_preview helper function. Similarly to fzf#wrap, it takes a spec dictionary and returns a copy of it with additional preview options.

command! -bang -nargs=? -complete=dir Files
    \ call fzf#vim#files(<q-args>, fzf#vim#with_preview({'options': ['--layout=reverse', '--info=inline']}), <bang>0)

You can just omit the spec argument if you only want the previewer.

command! -bang -nargs=? -complete=dir Files
    \ call fzf#vim#files(<q-args>, fzf#vim#with_preview(), <bang>0)

Example: git grep wrapper

The following example implements GGrep command that works similarly to predefined Ag or Rg using fzf#vim#grep.

  • We set the base directory to git root by setting dir attribute in spec dictionary.
  • The preview script supports grep format (FILE_PATH:LINE_NO:...), so we can just wrap the spec with fzf#vim#with_preview as before to enable previewer.
command! -bang -nargs=* GGrep
  \ call fzf#vim#grep(
  \   'git grep --line-number -- '.fzf#shellescape(<q-args>),
  \   fzf#vim#with_preview({'dir': systemlist('git rev-parse --show-toplevel')[0]}), <bang>0)

Mappings

Mapping Description
<plug>(fzf-maps-n) Normal mode mappings
<plug>(fzf-maps-i) Insert mode mappings
<plug>(fzf-maps-x) Visual mode mappings
<plug>(fzf-maps-o) Operator-pending mappings
<plug>(fzf-complete-word) cat /usr/share/dict/words
<plug>(fzf-complete-path) Path completion using find (file + dir)
<plug>(fzf-complete-file) File completion using find
<plug>(fzf-complete-line) Line completion (all open buffers)
<plug>(fzf-complete-buffer-line) Line completion (current buffer only)
" Mapping selecting mappings
nmap <leader><tab> <plug>(fzf-maps-n)
xmap <leader><tab> <plug>(fzf-maps-x)
omap <leader><tab> <plug>(fzf-maps-o)

" Insert mode completion
imap <c-x><c-k> <plug>(fzf-complete-word)
imap <c-x><c-f> <plug>(fzf-complete-path)
imap <c-x><c-l> <plug>(fzf-complete-line)

Completion functions

Function Description
fzf#vim#complete#path(command, [spec]) Path completion
fzf#vim#complete#word([spec]) Word completion
fzf#vim#complete#line([spec]) Line completion (all open buffers)
fzf#vim#complete#buffer_line([spec]) Line completion (current buffer only)
" Path completion with custom source command
inoremap <expr> <c-x><c-f> fzf#vim#complete#path('fd')
inoremap <expr> <c-x><c-f> fzf#vim#complete#path('rg --files')

" Word completion with custom spec with popup layout option
inoremap <expr> <c-x><c-k> fzf#vim#complete#word({'window': { 'width': 0.2, 'height': 0.9, 'xoffset': 1 }})

Custom completion

fzf#vim#complete is a helper function for creating custom fuzzy completion using fzf. If the first parameter is a command string or a Vim list, it will be used as the source.

" Replace the default dictionary completion with fzf-based fuzzy completion
inoremap <expr> <c-x><c-k> fzf#vim#complete('cat /usr/share/dict/words')

For advanced uses, you can pass an options dictionary to the function. The set of options is pretty much identical to that for fzf#run only with the following exceptions:

  • reducer (funcref)
    • Reducer transforms the output lines of fzf into a single string value
  • prefix (string or funcref; default: \k*$)
    • Regular expression pattern to extract the completion prefix
    • Or a function to extract completion prefix
  • Both source and options can be given as funcrefs that take the completion prefix as the argument and return the final value
  • sink or sink* are ignored
" Global line completion (not just open buffers. ripgrep required.)
inoremap <expr> <c-x><c-l> fzf#vim#complete(fzf#wrap({
  \ 'prefix': '^.*$',
  \ 'source': 'rg -n ^ --color always',
  \ 'options': '--ansi --delimiter : --nth 3..',
  \ 'reducer': { lines -> join(split(lines[0], ':\zs')[2:], '') }}))

Reducer example

function! s:make_sentence(lines)
  return substitute(join(a:lines), '^.', '\=toupper(submatch(0))', '').'.'
endfunction

inoremap <expr> <c-x><c-s> fzf#vim#complete({
  \ 'source':  'cat /usr/share/dict/words',
  \ 'reducer': function('<sid>make_sentence'),
  \ 'options': '--multi --reverse --margin 15%,0',
  \ 'left':    20})

Status line of terminal buffer

When fzf starts in a terminal buffer (see fzf/README-VIM.md), you may want to customize the statusline of the containing buffer.

Hide statusline

autocmd! FileType fzf set laststatus=0 noshowmode noruler
  \| autocmd BufLeave <buffer> set laststatus=2 showmode ruler

Custom statusline

function! s:fzf_statusline()
  " Override statusline as you like
  highlight fzf1 ctermfg=161 ctermbg=251
  highlight fzf2 ctermfg=23 ctermbg=251
  highlight fzf3 ctermfg=237 ctermbg=251
  setlocal statusline=%#fzf1#\ >\ %#fzf2#fz%#fzf3#f
endfunction

autocmd! User FzfStatusLine call <SID>fzf_statusline()

License

MIT

fzf.vim's People

Contributors

adnoc avatar alaaibrahim avatar andreasgerstmayr avatar andreypopp avatar andviro avatar antoinemadec avatar atn34 avatar balki avatar blueyed avatar bmundt6 avatar buztard avatar danihodovic avatar dguo avatar doronbehar avatar dprophete avatar dsh2 avatar dvdbng avatar dz84 avatar frederick888 avatar habamax avatar ingomeyer441 avatar janlazo avatar jiz4oh avatar joshpencheon avatar junegunn avatar kaworu avatar liskin avatar nkouevda avatar syphar avatar wookayin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fzf.vim's Issues

command "namespace"

Thanks for this plugin, it's great.

I'm here to make my usual request :) The plugin defines a bunch of commands like History and Lines. But for most users the "namespace pollution" is not worth it because fzf actions are generally bound to normal-mode commands.

For the case where a user wants to try something from the command line, "namespacing" helps the user discover the available commands. This can be done either by prefixing all fzf.vim commands (FzfLines, FzfHistory), or by having a single command that takes sub-commands (Fzf lines, Fzf history) similar to git, hg, etc.

I don't suggest wrapping the default commands in a if !exists('g:fzf_default_commands') guard because that's lame. 😅

Custom Locate

Hello,

I want to use a custom Locate and I've managed with: command! -nargs=+ Locate call fzf#run({'source': 'locate -Ai -0 '.<q-args>.' | grep -z -vE "~$"', 'sink': 'e', 'options': '--read0 -0 -1 -m --prompt "Locate> "'}).

That's fine but I'd also like to be able to use the special Ctrl-v/x/t keys. I 've tried copying s:expect() and others in after/plugin/fzf.vim but without much success. Can you help. :)

Cheers

Customizing fzf options for different commands?

What's the best way to use different options for the different commands? for example, I want to use extended search in Lines but fuzzy search in Commands.

Thanks for this great tool! I love it!

:BTags displays strange results

When I run ":BTags" on a Java file, I got

  check_webkit_exceptions_during_rendering                f       class:WebPageSnapshotter        file:                                                                                                                              ..
  check_resources_loaded_during_rendering                 f       class:WebPageSnapshotter        file:                                                                                                                              ..
  checkWebkitExceptionsDuringRendering                    f       class:WebPageSnapshotter        file:                                                                                                                              ..
  checkResourcesLoadedDuringRendering                     f       class:WebPageSnapshotter        file:                                                                                                                              ..





  DEFAdateRenICE_SPEC                                     f       class:WebPageSnapshotter        file:                                                                                                                              ..
  check_webkit_exceptions_during_rendering                f       class:WebPageSnapshotter        file:                                                                                                                              ..
  checkWebkitExceptionsDuringRendering                    f       class:WebPageSnapshotter        file:                                                                                                                              ..
  BNS_RESOLUTION_MILLIS                                   f       class:WebPageSnapshotter






> snapshotInternal                                        m       class:WebPageSnapshotter        file:                                                                                                                              ..
  1/33
BTags> inter

where I could only select the last one although there were 8 others display above it. There were also huge blank lines in the results. In this use case, what I wanted to select was the last one, so it is okay for now. But I think something is wrong.

Introduce search files only command

This more or less asks for reverting this commit: ee79457

Or at least it would be nice to have a variant of Ag, that searches only the content of the files. Also, I'm not really interested.

Also, it would be nice to shorten the path of the file a little bit. My paths often span 80% of the entire screen. This makes it hard to see if the match is the one I looked for. For me, only showing the name of the file would probably enough.

Recommended Way for Combining Several Sources

Given the super powers of fzf and your helper configurations here, it would be so great if one could easily combine several relevant sources, for example:

Is it possible to easily filter using fzf the outputs from Buffers, History (this includes buffers already) and Files?

Dosn't want to work for MacVim

In regular old terminal vim loads up just fine testing with :Files command, in macvim testing the :Files command it hangs for a second then goes back to the line I was on with zero output at all.

Toggle exact match

I just switched to fzf. I like the :Lines and :BLines commands - but I notice that they do not do an exact match. Is there a way to toggle between exact match and fuzzy match? Thanks for fzf and fzf.vim.

History: and History/ commands in Neovim

I am running the latest Neovim (NVIM 0.0.0-alpha+201509011923), fzf, and fzf.vim. When I issue the commands History: and History/, the terminal pops up for less than a second and then vanishes. Almost all of the other commands work as expected (I've not tried Windows or Marks, since I don't typically use those features).

I've used the following minimal .nvimrc file to make sure that this wasn't an issue with a different setting:

call plug#begin('~/.cleanvim/plugged')
Plug 'junegunn/vim-peekaboo'
Plug 'junegunn/fzf.vim'
call plug#end()
set rtp+=~/.fzf

De-duplicate :History

:History contains many duplicated files, for example package.json:

screen shot 2015-10-30 at 11 20 26

Can these be de-duplicated?

Tags it returns empty results

When i run Tags even if i have compiled the tags manualy or let the fzf create it, i have no results.

I am using vim in debian testing

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Aug 17 2015 03:37:50)
Included patches: 1-826

Unknown function: s:expect

When trying to run :GitFiles I am met with this error. I just updated fzf and fzf.vim and this started happening.

Error detected while processing function fzf#vim#gitfiles:                                                                                                                    
line    6:                                                                                                                                                                    
E117: Unknown function: s:expect                                                                                                                                              
E116: Invalid arguments for function <SNR>187_fzf 

Any insights?

Tags creation is not async

I just run :Tags in my home directory. It took forever to complete. During that time neovim was completely blocked. I had to kill the ctags process manually in order to give control back to neovim.

Consider window working directory for commands

I want that fzf respects my .gitignore files, therefore I have the following configured: https://github.com/junegunn/fzf#respecting-gitignore-hgignore-and-svnignore

However, this seems to consider only the .gitignore file of the working directory where vim (in my case neovim) is started. When I do a :lcd in order to change the working directory in vim and then run :Files, the .gitignore file of the newly configured working directory is not considered.

Fzf with arg or with word under cursor

Is it possible to call fzf or fzf#tags with the word under the cursor or pass an argument to fzf.vim so that it expands fzf with the argument? If not, how difficult would this be to implement?

:Files new file

Is it possible, while using :Files, to create a new file ?

ProjectFiles?

Do we have something automatically run "Files" on project root (if it has .git, .svn, etc), and yet act on current directory if it's not under a project.

Unite has a source called "UniteWithProjectDir", and I remember CtrlP has something similar too. Would be very convenient.

BLines/Lines doesn't respect vim's settings for whitespaces

I'm using following vim's settings:

set tabstop=2
set softtabstop=2
set shiftwidth=2
set noexpandtab

set listchars=tab:  ,trail:·,space:·,nbsp:·

But when I run :BLines or :Lines I can see that tab is expanded into 8 spaces which is pretty awful and it makes orientation among lines very hard for me.

Toggle selection

Only thing I miss from ctrlp.vim plugin is the toggle selection feature using CTRL-Z. Any chances to have that implemented?

Support for screen (like tmux)

This should be as easy asa simply changing the exec from tmux to screen. Could not find it in the documentation. I'd that supported?

Problem with :Files

I'm having an issue with the :Files command. I'm not 100% how to replicate it, but sometimes when I hit ,f (which is mapped to :Files) and hit enter on a file to open it... it doesn't open. This happens fairly frequently, but usually after I've used :Files to open 1-2 files.

It says at the bottom the file name, as if it opened it but the buffer doesn't seem to appear. Then, once I hit another key the buffer appears to flash and disappear.

Now, I am using neovim so that could be the issue but would love some input on how to resolve the issue as I'm really liking fzf so far!

Buffers: switching to a term buffer cannot startinsert

I have have the following in my nvimrc. I want to be able to automatically start in insert mode whenever I select a term buffer from the Buffers command. However, I always end up in normal mode :(

   autocmd BufWinEnter,WinEnter term://* startinsert
   tnoremap <c-p><c-b> <c-\><c-n>:Buffers!<cr>

Customizing colors?

The colors for commands like :Ag end up unreadable on my dark terminal. Is there a way to customize these?

Extract core in separate plugin

Would it be possible to split your plugin in two -- async/sync core for nvim/vim/tmux with API to launch interactive commands and fzf built on top of that core?
Then core plugin would cover some neovim issues as introduce more relations with tmux.
At least it would allow to lauch zsh instead of :shell and ranger for interactive file choosing (it's more slow than fzf for project dirs, but faster for systemwide jumping), as many other interactive commands similar to old good :!, which neovim users currently lack of.
Currently I have extracted some of your code for zsh and ranger to fix my irritation from neovim, but it would be more appropriate to make such plugin by origin author.

Lines command not working

It seems like the "Lines" and "BLines" commands has stopped working properly (see screenshot)?
Tested with the latest version of Neovim.

Everything else works like a charm! :)

fzf

":Commands" lists vim commands with extra charaters

I run ":Commands" and get something like

â~@~GBCommitsâ~@~G   

for all the commands. It seems these are space characters. I am using "urxvt" terminal on Ubuntu. On my mac, it is ok and no such strange characters. I think maybe this is not an issue of fzf.vim, but some of my setting problem of urxvt. But I am not sure.

Is there a way to pass a path to :Ag?

This is about the only thing I miss from ag.vim, I used it often to search only sub-paths in my project. I looked at the fzf plugin source, doesn't look like it's there at the moment, would it be very difficult to add this?

One thing I like about this version is that I no longer have to include flags (like :Ag -Q "blah" web/server) but as I see it that might make it difficult to pass it a path. Problem is that the search/reduce once the :Ag pane is open doesn't also search against the filename/path

EDIT: just an edit to say thanks so much for fzf and this plugin, which removed a lot of stuff from my vimrc :)

Statusbar background color

How do I change the background color of the status bar?

fzf

By the way, I have just removed ack.vim and ctrlp.vim plugins. Now I am using fzf.vim. Keep the good work!

Problem with :Tags

The only output I get is Binary file (standard input) matches.

I have hunted the issue to this line.

I get the same issue when I run it in my terminal though, so it might be a perl issue.

Registers?

Is it possible to hook up registers as a source? I tried the following:

function! s:mycommand_sink(cmd)
    let cmd = substitute(a:cmd, '\d..', '', 'g') 
    execute cmd
endfunction

function! s:commands(bang)
  redir => registers
  silent registers
  redir END
  let list = split(registers, '\n')
    call fzf#run({
                \ 'source':  reverse(extend(list[0:0], map(list[2:], 's:format_cmd(v:val)'))),
                \ 'sink':    function('s:mycommand_sink'),
                \ 'options': '--ansi -x --prompt "Registers> " ',
                \ 'window': 'aboveleft 20new'}, a:bang)
endfunction

command! -bang Registers call s:commands(<bang>0)

I don't really know VimScript though, so this code, not shockingly, does not work.

Open FZF in current pane

I've noticed a small annoyance with how FZF (and vim fuzzy file selectors in general) work. When I open a file, often I'll be reading the name of the file I want to open from a buffer. I'll split the window into two panes with Ctrl+w v, then open FZF. FZF will create a new pane at the bottom of the screen, often pushing the text containing the name of the thing I want to open off the screen. It's not uncommon for me to forget what the last word or phrase of the filename I'm looking for is, close FZF, read the text again, then open FZF again. All the text moving around abruptly makes me go blank sometimes.

Is it possible to open FZF in the active pane, then put the selected buffer into the same pane?

Here's terrible ascii art kinda showing what I'm asking.

Initial editor pane state, the same buffer open in each pane, with the cursor in top pane.
+-----+
|1    |
+-----+
|1    |
|     |
|     |
+-----+

Now, I open FZF.

What happens now:
+-----+
|1    |
+-----+
|1    |
+-----|
|FZF  |
+-----+

+-----+
|2    |
+-----+
|1    |
|     |
|     |
+-----+


Desired:
+-----+
|FZF  |
+-----+
|1    |
|     |
|     |
+-----+

+-----+
|2    |
+-----+
|1    |
|     |
|     |
+-----+

[vim 7.3] Cannot open files.

Not too sure what I am doing wrong but I installed fzf.vim and it works great.

Then I mapped
nnoremap <silent> <Leader><Leader> :Files<CR>
Which also works perfectly.

The problem is that when I choose a file I get this.

Error detected while processing function fzf#vim#files..73_fzf..fzf#run..38_execute..38_callback:
line 27:
Vim(call):E117: Unknown function: s:common_sink
Press ENTER or type command to continue

No fzf#run function?

Steps to reproduce.

% /usr/bin/vim -u NONE -c 'source fzf.vim' -c 'Files'

Error detected while processing function <SNR>1_files..<SNR>1_fzf:
line    1:
E117: Unknown function: fzf#run
E15: Invalid expression: fzf#run(extend(a:opts, a:bang ? {} : get(g:, 'fzf_window', s:default_window)))

This function does not appear to be defined in this plugin unlike that in the fzf repo.

Is this expected to be user defined?

Split-size is not kept

When you have 3 splits, layed out like this :

capture

and you run :FZF to open an other file in the top-left split, the bottom split is moved up.

This happens only on "neovim", but I'm not sure whether it should be implemented correctly by neovim or by fzf.vim

capture

In my case, the bottom split is actually a "quick-fix" split, but the bug also happens with normal buffers.

:Ag doesn't handle autochdir

Select a bunch of files, open the first one and the second won't open because it's a relative path and the current working directory has changed. ag.vim handles this correctly somehow (remember the original directory in the quickfix window?).

Command history

It would be nice to search the command line mode history.

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.