Thursday, February 13, 2014

Re: gd command doesn't go to definition of identifier

Hi,

Paul wrote:
> I a *test* file tmp.tex consisting solely of the following LaTeX code:
>
> Start LaTeX code
> ----------------
> \DeclareAcronym{myacro}{
> short = MYACRO,
> long = some longer expansion of myacro
> }
>
> \section
> {Big long section name that never ends but keeps going and going and}
> \subsection{\ac{myacro}}
> --------------
> End LaTeX code
>
> If I place my cursor on "myacro" on the last line and press "gd"
> (without quotes), cursor does not jump to the first occurance on the
> first line. However, if I attach the 4th last line "{Big long
> section..." to the preceding line "\section" with no adjoining space,
> then "gd" *does* work.
>
> Can anyone explain why? The problem exhibits itself even if the file
> is named tmp.txt, so it doesn't seem to be a language-specific syntax
> issue.

the description at ":help gd" seems to indicate that "gd" is intended to
be used on C-like code, i.e., languages that use curly braces to define
blocks. In a lot of places Vim assumes that a C function starts with an
opening curly brace in the first column. Vim does not actually have a
concept of programming language structures. With "gd" the search for
"myacro" will start at the curly brace that Vim *thinks* is the start of
a function. As long as your text "{Big long section name ..." is on a
line of its own, the search for "myacro" will start there and stop at
the place where your cursor is already located.

Maybe with LaTeX code "gD" might be a better alternative, although this
will always stop at the first occurrence of a word and ignore later
re-definitions.

Regards,
Jürgen

--
Sometimes I think the surest sign that intelligent life exists elsewhere
in the universe is that none of it has tried to contact us. (Calvin)

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment