This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Enabling Ctags Tree Wide for GCC


On Wed, 11 Sep 2019 at 12:50, Hi-Angel <hiangel999@gmail.com> wrote:
>
> On Wed, 11 Sep 2019 at 09:55, Nicholas Krause <xerofoify@gmail.com> wrote:
> >
> >
> > On 9/11/19 2:30 AM, Andreas Schwab wrote:
> > > On Sep 11 2019, Nicholas Krause <xerofoify@gmail.com> wrote:
> > >
> > >> I was wondering what is the easiest way to allow source tree wide
> > >> ctags.
> > > There is make TAGS, which uses etags.
>
> Note: over time on the internet appeared quite a few different "ctags"
> projects (exuberant ctags universal ctags, anjuta-ctags, you named
> it), AFAIK the currently maintained and developed project with the
> most number of supported languages is universal ctags, so I recommend
> using it.
>
> > Is there no way to build it for vim as thats what I would prefer to stay
> > with.
>
> (disclaimer: I'm just a random reader of the ML)
>
> Using ctags with any project is as simple as `ctags -R` in base
> directory of sources (add -e option if you use Emacs).
>
> There's no need for any complex setup, because the "tags" format is
> very dumb. It's just "tag name" (e.g. name of a function, struct,
> macro), line number, and the whole line where that name is defined.
> So, in particular, if you have 2 functions foo() defined, and you jump
> to a tag "foo()", there's no way a text editor can figure out which
> one "foo()" is that you wanted, so it would either jump to the first
> occurrence (vim does that, you need to use :tn :tp to navigate
> further) or present you with a list of occurences (Emacs does this).
>
> So, I doubt there's a "make tags" command, because it's one symbol
> bigger than "ctags -R" ;-)

Worth noting btw, that ctags are a great thing if you want to quickly
dive in to a project, and you're okay with their downsides, such as
not being able to resolve foo() as in example. This even especially
emphasized by the fact my local Universal Ctags support 100 (!!!)
languages (`ctags --list-languages | wc -l`)

But in the long run, if you work with a project a lot, I'd recommend
looking at setting up an LSP server. All modern editors support it,
including vim and emacs (some natively, some through extensions). It
doesn't have the downsides of tags format, and can also provide you
with things like completion or error highlighting as you type.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]