I am trying to create a macro which reproduces the behaviour of CtrlP as in this webpage: https://www.edwinwenink.xyz/posts/48-vim_fast_creating_and_linking_notes/.

However, even if fzf can easily select a file, I don't know how to get its result inside a function so as to insert a snippet (a markdown link in this case).

Any ideas ? Thanks

  • Welcome to Vi and Vim! Interesting question—doesn't fzf provide "sinks" as an abstraction for "do what you want with the result"? – D. Ben Knoble Apr 23 '20 at 13:41

You can do something like that:

function! HandleFZF(file)
    echo a:file
command! -nargs=1 HandleFZF :call HandleFZF(<f-args>)

Then, to invoke fzf, run:

call fzf#run({'sink': 'HandleFZF'})
  • Works great ! Thanks !! – fernando Apr 23 '20 at 20:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.