1

I write in pandoc markdown, which uses bibligraphic keys from biblatex that look like @smith_foo_1999, where "Smith" is the author name, "Foo" is the title, and 1999 is the year of publication. This corresponds to an entry in my library.bib file that starts @article{smith_foo_1999. I use unite-bibtex and vim-pandoc, which both have great autocompletion for these keys, but what I'd really like to be able to do is to jump to my bibliographic entry in my library.bib file when I position the cursor over the key @smith_foo_1999, and press some key combination like gf or <C-]>. Is there a way to do that?

1 Answer 1

3

You could make a mapping in vim that opens the file, and searched for the selected word. Lets assume the following file structure:

.
..
img/
library.bib
markdownfile.md

a simple mapping could do most of the work then,

map <leader>bib yiw:e library.bib<CR>q/p

Place your cursor on the word, e.g. @mybib_2015 and press <leader>bib.

This mapping will

  1. yiw yank entire word
  2. :e library.bib<cr> open library.bib in a new buffer
  3. q/p will toggle search, and paste the aforementioned yanked word.
2
  • bvwy has a couple problems, I think. b will go to the beginning of the previous word if the cursor is on the first character of the current word and w will go to the beginning of the next word, not the end of the current word. I'd suggest replacing bvwy with viwy (visual mode, inner word, yank) or yiw (yank inner word). The latter will leave the previous visual mode are untouched, which may be relevant to fans of gv and similar commands.
    – 8bittree
    Commented Nov 16, 2016 at 20:51
  • Excellent addition! I didn't think about that.
    – user660080
    Commented Nov 17, 2016 at 16:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .