When using ctags, one can move back through the tag stack by using [count]CTRL-T or :[count]pop, and forward using :[count]tag

However, when using cscope instead of ctags and setting 'cscopetag', only the backwards direction works (that is, :[count]pop works, but :[count]tag gives E433: No tags file and E426: tag not found with the name of the tag at that point in the tagstack).

Is there a way to enable the forward direction when using cscope?

  • 1
    I haven't used cscope (didn't even know it existed!), but the documentation makes it sound like this is supposed to just work. Have you got csto set to zero? (the default) – Rich Feb 8 '15 at 10:39
  • I do: set csto? shows cscopetagorder=0 – John O'M. Feb 8 '15 at 14:21

Ensure setting the cscope using the following in your ~/.vimrc file:

set cscopetag
set cst
set csto=0
set tags=./tags,tags;/
cs add cscope.out

Once it is done, re-login into the terminal to run cscope.

Jump to a tag: Ctrl]

Jump back: CtrlO

Jump to a tag again: CtrlI

  • 1
    Welcome to Vi stack exchange! ctrl+o and ctrl+i walk the jump list. This works great so long as one doesn't jump around between tag switches, which is often the case when just walking through a couple function calls, so have an upvote. Unfortunately for me, I sometimes move around a lot at a given call level which breaks this, or bounce between different tags which can get the jump list out-of-sync with my tag stack. – John O'M. Sep 12 '17 at 3:36

Other than generate the cscope.out, you need to run ctags -L cscope.files to generate the tags file. With both of that you can move back and force in the cscope tagstack

New contributor
Eric Sun is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.