Loading ...
Sorry, an error occurred while loading the content.

Re: HTML tag-jumping? (Was: quick and dirty mapping for "gd" or "gD" like behavior?)

Expand Messages
  • Antoine J. Mechelynck
    ... I see. Well, if some day I have nothing better to do fat chance! I may write some HTML plugin to jump to a definition by anything within
    Message 1 of 3 , Jun 23, 2003
    • 0 Attachment
      Benji Fisher <benji@...> wrote:
      > Antoine J. Mechelynck wrote:
      > > Benji Fisher <benji@...> wrote:
      > >
      > > > Gumnos (Tim Chase) wrote:
      > > >
      > > > > I've have gotten used to using gD to jump to my global
      > > > > definitions
      > > > > in my C/C++ files. However, I'm working with a moderatly large
      > > > > (currently around 500k, when completed, should be about a meg
      > > > > and a
      > > > > half) XML file in which it would be handy to have "gD" find the
      > > > > first instance of the word under the cursor (which it currently
      > > > > does). However, in this particular file the "definition" should
      > > > > always be in an attribute of the form
      > > > >
      > > > > id="definedTerm"
      > > > >
      > > > > The problem is that I have plenty of other attributes
      > > > > referencing
      > > > > it, of the form
      > > > >
      > > > > ref="definedTerm"
      > > >
      > >
      > > Talking of cross-fertilization:
      > >
      > > I see a similarity with HTML, where <a name="SomeName" ...> or
      > > <blahblah id="SomeName" ...> are "definitions", while <a
      > > href="#SomeName"> or <a href="somefile.htm#SomeName"> are
      > > "references". Has anyone thought to
      > > exploit those in some kind of tag-jumping scheme for Vim (Not that
      > > I'd use
      > > it much [or maybe I will, now that I think about it], and I don't
      > > have any external ctags that I know of, but it's good to know...).
      > > Note that unlike Vim helptags, the combination filename#tagname
      > > should be unique but the tagname by itself need not.
      >
      > You do not need a tags file to use [d and related commands. I
      > think that
      >
      > > let &l:define = '\<\(id\|name\)\s*=\s*'
      >
      > should work pretty well for the constructions you mention (untested).
      > Off hand, I cannot think of any way to handle "somefile.htm#SomeName"
      > : I think you have to put the cursor over the "SomeName" part of the
      > string. If you want to find '<a name="SomeName">' in somefile.htm
      > then you could also play with the 'include' option (untested by me).
      > Try something like
      >
      > > setlocal include=\\<href\\s*=\\s*
      >
      > You might want to add '"' at the end or '\c' at the beginning
      > (properly escaped). Note that this is far from perfect: it may also
      > find '<a name="SomeName">' in someotherfile.htm .
      >
      > For further (teted) examples of settings for 'define' and
      > 'include', see the default ftplugin/tex.vim .
      >
      > HTH --Benji Fisher

      I see. Well, if some day I have nothing better to do <smirk>fat
      chance!</smirk> I may write some HTML plugin to jump to a definition by
      anything within <> preceded by name= or id= and either within "" or with no
      intervening spaces, to jump to a reference within the same file by searching
      on #name, and (with the cursor on <a [space] [anything but >]
      href="pathfilename#tagname" with or w/o quotes [anything] >, to do ":edit
      pathfilename" followed (if successful) by / on the definition. (a path
      starting with anything but / and not containing : is relative to the dir
      containing the referencing file).

      Thanks,
      Tony.
    Your message has been successfully submitted and would be delivered to recipients shortly.