Help: ctags in vim ?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Help: ctags in vim ?

Kunal Chauhan
Hi Team,

below is my ctags related question in vim :

Q1: I added new functions to some code repo and run the below command
     For generating the ctags I used "ctags -R * " at vim but it is not working.
    still I did not compile my code yet.
Q2: Also my tags folder is not showing by date update in current source directory.

Q3: is ctags require the compilation of code for navigation.

Thanks
Kunal

--
Thanks with Regards!

Kunal Chauhan
Mob:09813614826
Mob:08860397903

--
--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CACEFAc1JN4o_%3DoSE-GLXGWwKhECRQzo1MM3O_fJRx2TL9t2Vsg%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Help: ctags in vim ?

Gary Johnson-4
On 2020-04-28, Kunal Chauhan wrote:
> Hi Team,
>
> below is my ctags related question in vim :
>
> Q1: I added new functions to some code repo and run the below command
>      For generating the ctags I used "ctags -R * " at vim but it is not
> working.
>     still I did not compile my code yet.

The asterisk (*) is not necessary.  You can execute just

    $ ctags -R

> Q2: Also my tags folder is not showing by date update in current source
> directory.

The tags do not go into a folder; they go into a regular file.  If
you have a folder named tags, you will need to either rename that
folder or tell ctags and vim to use a different name for the tags
file.

If you are executing "ctags -R *" or "ctags -R" within vim, try
executing it outside of vim, at the shell prompt.  That may let you
see any warnings more easily.

> Q3: is ctags require the compilation of code for navigation.

No, ctags does not require that the code be compiled.

However, some programs generate C source files from files written in
other languages, such as YACC.  You may need to compile your code
before ctags will find symbols defined in generated files.

Regards,
Gary

--
--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20200428174824.GA29220%40phoenix.
Reply | Threaded
Open this post in threaded view
|

Re: Help: ctags in vim ?

Kunal Chauhan
1. I have added simple a new function to my source dir and running the ctags - R but still at new functions tag is not working.?


2. At each time i opened my source code i need to execute ctags again ?

3. How Can I use  ctags and cscope while I have already opened my file in vim.

On 28 Apr 2020 11:19 p.m., "Gary Johnson" <[hidden email]> wrote:
On 2020-04-28, Kunal Chauhan wrote:
> Hi Team,
>
> below is my ctags related question in vim :
>
> Q1: I added new functions to some code repo and run the below command
>      For generating the ctags I used "ctags -R * " at vim but it is not
> working.
>     still I did not compile my code yet.

The asterisk (*) is not necessary.  You can execute just

    $ ctags -R

> Q2: Also my tags folder is not showing by date update in current source
> directory.

The tags do not go into a folder; they go into a regular file.  If
you have a folder named tags, you will need to either rename that
folder or tell ctags and vim to use a different name for the tags
file.

If you are executing "ctags -R *" or "ctags -R" within vim, try
executing it outside of vim, at the shell prompt.  That may let you
see any warnings more easily.

> Q3: is ctags require the compilation of code for navigation.

No, ctags does not require that the code be compiled.

However, some programs generate C source files from files written in
other languages, such as YACC.  You may need to compile your code
before ctags will find symbols defined in generated files.

Regards,
Gary

--
--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20200428174824.GA29220%40phoenix.

--
--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CACEFAc1MoK3Ysh%3Dg0pZzYwgjD4RZmAjHZ%3DBtMqrN%2Bz9jHo2G2A%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Help: ctags in vim ?

Gary Johnson-4
On 2020-04-29, Kunal Chauhan wrote:
> 1. I have added simple a new function to my source dir and running the ctags -
> R but still at new functions tag is not working.?

I don't know why that is.  Ctags usually "just works" without any
fussing so I don't have much experience fixing ctags problems.
I don't have enough information about your situation to make any
further guesses about what might be wrong.

> 2. At each time i opened my source code i need to execute ctags again ?

No.  You need to execute ctags again only after you have made
a change to your source code.

> 3. How Can I use  ctags and cscope while I have already opened my file in vim.

First, make sure that the working directory of the current vim
window is the directory that should contain your tags and cscope.out
files.  If you started vim in that directory, and you haven't
executed any :cd or :lcd commands, and 'autochdir' is off (the
default), then any window in vim should be using the correct working
directory.  You can check with the following command:

    :pwd

For ctags, simply execute the following command:

    :!ctags -R

For cscope, execute the following two commands:

    :!cscope -b -R
    :cs add

I think those last two commands are right.  I haven't used cscope in
years.  I've been using GNU Global instead, and I have plugins that
do a lot of stuff automatically so that I don't have to think about
it.

You can find out more about Vim's cscope commands here:

    :help cscope

HTH,
Gary

--
--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20200429153936.GB29220%40phoenix.
Reply | Threaded
Open this post in threaded view
|

Re: Help: ctags in vim ?

Kunal Chauhan
If we talk about gnu global is it far better than cscope.

If yes how can i install and use it on my ubuntu machine . 

On 29 Apr 2020 21:10, "Gary Johnson" <[hidden email]> wrote:
On 2020-04-29, Kunal Chauhan wrote:
> 1. I have added simple a new function to my source dir and running the ctags -
> R but still at new functions tag is not working.?

I don't know why that is.  Ctags usually "just works" without any
fussing so I don't have much experience fixing ctags problems.
I don't have enough information about your situation to make any
further guesses about what might be wrong.

> 2. At each time i opened my source code i need to execute ctags again ?

No.  You need to execute ctags again only after you have made
a change to your source code.

> 3. How Can I use  ctags and cscope while I have already opened my file in vim.

First, make sure that the working directory of the current vim
window is the directory that should contain your tags and cscope.out
files.  If you started vim in that directory, and you haven't
executed any :cd or :lcd commands, and 'autochdir' is off (the
default), then any window in vim should be using the correct working
directory.  You can check with the following command:

    :pwd

For ctags, simply execute the following command:

    :!ctags -R

For cscope, execute the following two commands:

    :!cscope -b -R
    :cs add

I think those last two commands are right.  I haven't used cscope in
years.  I've been using GNU Global instead, and I have plugins that
do a lot of stuff automatically so that I don't have to think about
it.

You can find out more about Vim's cscope commands here:

    :help cscope

HTH,
Gary

--
--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20200429153936.GB29220%40phoenix.

--
--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CACEFAc26ZtT039Tn5K0D5Y-idu-Y9B0Jr%3D2hWHRywe9s5LrZGA%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Help: ctags in vim ?

Gary Johnson-4
On 2020-04-29, Kunal Chauhan wrote:
> If we talk about gnu global is it far better than cscope.

It's better at most things; worse at some.

It does a better job than cscope at understanding C++ files.  Cscope
apparently understands only C; some C++ constructs confuse it.

There was a bug in cscope some years ago that prevented it from
identifying certain forms of function definitions used by some of my
co-workers.  I wrote to the maintainer about it.  He tried to fix it
but said that the parser became many times larger and didn't think
the fix was worth that.

Cscope has some features that GNU Global lacks, such as finding
functions that are called by the current function.

GNU Global is almost a drop-in replacement for cscope.  There is
a gtags.vim plugin that comes with GNU Global.  On Ubuntu, it's
/usr/share/doc/global/examples/gtags.vim.gz.  There is also
a tutorial at https://www.gnu.org/software/global/globaldoc_toc.html
that explains how to use GNU Global with Vim, either with or without
the plugin.  I recommend reading the tutorial.

> If yes how can i install and use it on my ubuntu machine . 

    $ sudo apt install global

In your project directory (wherever you normally execute ctags), to
generate the database:

    $ gtags

In vim:

    :set csprg=gtags-cscope
    :cs add GTAGS

Then use it as you would cscope.

Regards,
Gary

--
--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20200429182718.GC29220%40phoenix.
Reply | Threaded
Open this post in threaded view
|

Re: Help: ctags in vim ?

Charles Campbell-2
In reply to this post by Kunal Chauhan
Kunal Chauhan wrote:
> 1. I have added simple a new function to my source dir and running the
> ctags - R but still at new functions tag is not working.?
>
>
> 2. At each time i opened my source code i need to execute ctags again ?
>
> 3. How Can I use  ctags and cscope while I have already opened my file
> in vim.
>
1: As I understand things, you haven't compiled your code (yet). Simple
syntax errors, typically caught by a compiler, can occasionally cause
problems for ctags.  Assuming that you've gotten rid of your "tags"
folder so that the ctags can successfully generate a "tags" file, try
running ctags on your C files one at a time.  Does that work (ie. tags
are produced)?  Note that each invocation of ctags will wipe out the
previous work, so this is not a suggestion of how to generate all the
tags you want, rather a way to find what files are causing issues for ctags.

2. Only when you feel the need -- ie. when you've installed new
functions, changed functions' argument lists/types, etc.  Of course,
ctags can tag more than just functions -- local typedefs, etc.

3. When in vim, and editing one of your source files, use  :tag
FUNCTIONNAME , for example, with FUNCTIONNAME being one of your
functions' names.  That will exercise your ctags feature (assuming you
have +tag_binary as a feature).
   For cscope, first check that you have +cscope as a feature (vim
--version).  If you do, then read up on  :help cscope.

Regards,
Chip Campbell

--
--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/f990da08-a941-496b-446e-331fd4f256b1%40drchip.org.