Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using gd to jump to the bibliography enty in the same file #2164

Closed
chenle02 opened this issue Sep 10, 2021 · 5 comments
Closed

Using gd to jump to the bibliography enty in the same file #2164

chenle02 opened this issue Sep 10, 2021 · 5 comments

Comments

@chenle02
Copy link

Here I can use the key binding gd over \ref{...} or \eqref{...} to jump to the definition of the equation. But over \cite{...} when I hit gd, it won't jump to the citation entry in the same file. I do not use separate file for bibliography. All bib entries are in the same latex file. I am wondering whether there is a quick way to jump to the bib entry?

Thanks a lot! I really love vimtex and am using it in a daily base.

@lervag
Copy link
Owner

lervag commented Sep 10, 2021

Good question. However, it would be much easier to reply if you can provide an example LaTeX file (not too large).

When your bib entries are in a .bib file, then the context menu can be useful. The default mapping for this is <cr>. But when the bib entries are in the same file I think this may not work.

Thanks a lot! I really love vimtex and am using it in a daily base.

Thanks, glad to hear it!

@chenle02
Copy link
Author

chenle02 commented Sep 11, 2021

Good question. However, it would be much easier to reply if you can provide an example LaTeX file (not too large).

When your bib entries are in a .bib file, then the context menu can be useful. The default mapping for this is <cr>. But when the bib entries are in the same file I think this may not work.

Thanks a lot! I really love vimtex and am using it in a daily base.

Thanks, glad to hear it!

Thanks a lot~! Below is a sample latex file.

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}

\title{How to use `gd' to jump to reference entry?}
\author{}
\date{}

\begin{document}
\maketitle

My cursor is over \cite{AF03}, by hitting `gd' in the normal mode, I wish the cursor could jump to line 25 of the document where the entry is defined.

\bigskip

Thanks a lot~!

\begin{thebibliography}{999}
  \bibitem[AF03]{AF03}
    Adams, Robert A. and John J. F. Fournier.
    \newblock {\em Sobolev spaces}~(2$^{\text{nd}}$ ed.).
    \newblock Elsevier/Academic Press, Amsterdam, 2003.
  \bibitem[AF03]{AF90}
    Adams, Robert A. and John J. F. Fournier.
    \newblock {\em Sobolev spaces}~(1$^{\text{st}}$ ed.).
    \newblock Elsevier/Academic Press, Amsterdam, 1990.
\end{thebibliography}
\end{document}

@lervag
Copy link
Owner

lervag commented Sep 11, 2021

Thanks for the sample.

gd is a Vim internal mapping that does local decleration search. VimTeX does not provide any additional enhancement of this mapping. See :help gd:

							*gd*
gd			Goto local Declaration.  When the cursor is on a local
			variable, this command will jump to its declaration.
			First Vim searches for the start of the current
			function, just like "[[".  If it is not found the
			search stops in line 1.  If it is found, Vim goes back
			until a blank line is found.  From this position Vim
			searches for the keyword under the cursor, like with
			"*", but lines that look like a comment are ignored
			(see 'comments' option).
			Note that this is not guaranteed to work, Vim does not
			really check the syntax, it only searches for a match
			with the keyword.  If included files also need to be
			searched use the commands listed in |include-search|.
			After this command |n| searches forward for the next
			match (not backward).

VimTeX does enhance the gf mapping and the :help include-search mappings by setting the 'include' and 'define' options. But that is not quite relevant here.

I've updated the 'define' option, so perhaps an alternative is to use the ]<c-d> mapping (see :help ]d and :help [_CTRL-D).

@lervag lervag closed this as completed Sep 11, 2021
lervag added a commit that referenced this issue Sep 11, 2021
@chenle02
Copy link
Author

Thanks for the sample.

gd is a Vim internal mapping that does local decleration search. VimTeX does not provide any additional enhancement of this mapping. See :help gd:

							*gd*
gd			Goto local Declaration.  When the cursor is on a local
			variable, this command will jump to its declaration.
			First Vim searches for the start of the current
			function, just like "[[".  If it is not found the
			search stops in line 1.  If it is found, Vim goes back
			until a blank line is found.  From this position Vim
			searches for the keyword under the cursor, like with
			"*", but lines that look like a comment are ignored
			(see 'comments' option).
			Note that this is not guaranteed to work, Vim does not
			really check the syntax, it only searches for a match
			with the keyword.  If included files also need to be
			searched use the commands listed in |include-search|.
			After this command |n| searches forward for the next
			match (not backward).

VimTeX does enhance the gf mapping and the :help include-search mappings by setting the 'include' and 'define' options. But that is not quite relevant here.

I've updated the 'define' option, so perhaps an alternative is to use the ]<c-d> mapping (see :help ]d and :help [_CTRL-D).

Thank you so much for the prompt help~! It works beautifully!!!

@lervag
Copy link
Owner

lervag commented Sep 12, 2021

Great, glad to hear it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants