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?
Add a comment
|
1 Answer
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
yiw
yank entire word:e library.bib<cr>
open library.bib in a new bufferq/p
will toggle search, and paste the aforementioned yanked word.
-
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 andw
will go to the beginning of the next word, not the end of the current word. I'd suggest replacingbvwy
withviwy
(visual mode, inner word, yank) oryiw
(yank inner word). The latter will leave the previous visual mode are untouched, which may be relevant to fans ofgv
and similar commands.– 8bittreeCommented Nov 16, 2016 at 20:51 -
Excellent addition! I didn't think about that.– user660080Commented Nov 17, 2016 at 16:59