Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top


I currently write research articles in LaTeX using Vim. I have bibtex keys in my articles like \cite{smith2000sometopic} and I have corresponding pdf versions of most articles in a subfolder of ~/lib e.g., ~/lib/topica/smith2000sometopic.pdf.


I'd like to be able to press a key in Vim when my cursor is over a bibtex key that:

  1. extracts the bibtex-key under the cursor
  2. performs a search for bibtex-key.pdf
  3. if the file is found, opens the file in a pdf viewer
  4. If the file is not found, indicate that this is the case


  • Has anyone already done something like this?
  • Are there any examples that would be useful to study?

Initial thoughts

I thought I could use something like:

 gnome-open `find ~/lib/ -iname "smith2000sometopic.pdf" | head -1`

and then experiment with some Vimscript to fine tune the interaction; but if anyone has any examples or suggestions, that would be most appreciated.

share|improve this question

Perhaps, I should have persisted a little longer before posting, but any suggestions for improvement are still more than welcome.

In the end I found this documentation useful from vimtips.

This was the Vim function I wrote:

function! OpenBibtexPDF()
    let s:word = expand("<cword>")
    let s:cmd = "!gnome-open `find ~/lib/ -iname '" . s:word . ".pdf' | head -1`"
    execute s:cmd
map <silent> <leader>bb :call OpenBibtexPDF()<cr>
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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