junegunn / fzf.vim

fzf :heart: vim
MIT License
9.52k stars 582 forks source link

Open pdf files in pdf viewer after search #1453

Open initzx opened 1 year ago

initzx commented 1 year ago

After search for a pdf, I would like to open the pdf in a viewer rather than to have a binary buffer opened in vim. For example it would be nice to somehow have fzf.vim recognize the filetype, and use xdg-open to open the file accordingly. Right now if I find a pdf file, then the pdf is opened in nvim as binary text.

freddiegar commented 1 year ago

No problem!, by example I open pdf files in browser from Vim(9) with this autocmd:

autocmd BufEnter *.pdf GoUrl(expand('<afile>')) | bwipeout

def GoUrl(uri: string): void
    silent execute "!/usr/bin/firefox '" .. shellescape(uri, 1) .. "'"

    silent redraw!
enddef

You can use zathura or whatever what do you want