ctags error "format error in tags file" - ctags

I work on c code base in Linux. I use perforce as source code repository. I had been using ctags and it was working fine. But recently when press ctrl ] in some symbol then I get below error. I removed tags file and recreated the tags file but the problem didn't solve. Any idea on how to resolve this issue?
E431: Format error in tags file "tags"
Before byte 53035586

If you are just using the ctags -R then try specifying the c language in the command like below. I had the same problem and when I specified the c language while generating the tags, the problem got resolved.
ctags -R --languages=C

There may be tags with large names in your repo. If you can live without those included in your ctags file, you can avoid this error and use rest of the ctags.
To avoid the files/folders, use this syntax
**ctags -R -V --exclude=#/path/to/ctags_ignore_file ./ **
ctags_ignore_file has the list of Folders to be excluded. You can use wildcard entries too.
This solved my problem.

TLDR; add export CSCOPE_EDITOR=vim to ~/.bashrc and close your terminal window.
In my case, setting vim as the default editor for cscope fixed the issue:
echo "export CSCOPE_EDITOR=vim" >> ~/.bashrc # Append to .bashrc
source ~/.bashrc # Load .bashrc into the current shell
After this, you may also use the following commands in your project directory for a quick reconfiguration of cscope and ctags:
ctags -R
cscope -R

Related

Change Bash filename autocompletion for aliases to be different than default

I have a custom alias for vim that I use for opening TeX files (allows proper functioning with vimtex:
alias vtex="vim --servername VIM"
It would be great if tab-completion of files only accepted .tex files — for example, if I'm in a directory with only one .tex file but many others, typing
vtex [TAB]
would automatically complete to
vtex file.tex
rather than all the other files vim is generally capable of editing.
I tried to use complete as follows
complete -f -X '!*.tex' vtex
but this didn't work.
Any suggestions? Thanks!

ctags error with mac

I have exuberant tags in my mac. Since, yesterday i am getting this error
ctags: illegal option -- R
usage: ctags [-BFadtuwvx] [-f tagsfile] file ...
I have followed the steps mentoned in this
After following the steps mentioned here i can run ctags -R from command line(iterm)
But when i execute the same command from a .sh (i have a shell script where i run the cscope and ctags command using it) file i get the above error again but not when i run ctags -R from iterm directly.
Any pointers on solving this issue will be really helpfull.
Thanks in advance
So, the above issue seems to be fixed. The issue being that inside the ~/.bash_profile PATH variable should be set correctly. Even though my PATH variable was pointing to /usr/local/bin but /usr/bin appeared ahead of /usr/local/bin , hence somehow the ctags (when run from shell script) was picking up /usr/bin and not /usr/local/bin (which i have set alias to). Just move /usr/local/bin ahead of /usr/bin and it worked fine.
Solution
Type this in terminal:
export PATH="/usr/local/bin:/usr/bin:$PATH"
Along with Neil answer you can simply add alias ctags='/usr/local/bin/ctags' to your .bashrc file.

Ctags not working

I'm trying to understand a large code base. I need ctags to generate some tags so that I can jump to the function definition with ctrl + ].
Unfortunately, after running ctags -R * in the source diretory where some python script files resides, then vi open the python script, then cursor on which I want to jump to definition of, but all prompts E426: tag not found.
I tried creating a ~/.vimrc file, and adding set tags=~/Downloads/fast-rcnn/tools/tags, but still does not work, and when I open the generated tags file in the directory, seems only have tens of lines.
Can someone help me?
turns out that set tags=~/Downloads/fast-rcnn/tools/tags missing colon :, adding it solve the problem, and follow the advice of Vim and Ctags tips and tricks
I change it to :set tags=./tags;/

ctags doesn't use my custom .ctags on Mac OS

I'm trying to use exuberant ctags on Mac OS. I've already installed exuberant ctags with homebrew. Here is my version :
$ ctags --version
Exuberant Ctags 5.8, Copyright (C) 1996-2009 Darren Hiebert
It seems that my custom $HOME/.ctags is not taken into account.
Here is my config :
$ cat ~/.ctags
--verbose=no
--recurse=yes
--tag-relative=yes
--langdef=scala
--langmap=scala:.scala
--regex-scala=/^\s*class\s*([a-zA-Z0-9_]+)/\1/c,classes/
…
When I launch ctags -R, no tags are generated for .scala files.
When I test with --options
$ctags -R --options=/Users/yamo/.ctags
ctags: cannot open option file "/Users/yamo/.ctags" : No such file or directory
$ll ~/.ctags
lrwxr-xr-x 1 yamo staff 36 Apr 13 21:29 /Users/yamo/.ctags# -> /Users/yamo/Projects/dotfiles/.ctags
The issue was due to BSD Regex.
I've just solved it by editing ~/.ctags in Vim :%s/\\s/[ \\t]/g
You should place your config files under ~/.ctags.d/ folder, according to the docs.
I got the same issue and doing that works for me:
$HOME/.ctags.d/*.ctags
$HOMEDRIVE$HOMEPATH/ctags.d/*.ctags (on MSWindows only)
.ctags.d/*.ctags
ctags.d/*.ctags
If any of these configuration files exist, each will be expected to contain a set of default options which are read in the order listed when ctags starts, but before the CTAGS
environment variable is read or any command line options are read. This makes it possible to set up personal or project-level defaults. It is possible to compile ctags to read
an additional configuration file before any of those shown above, which will be indicated if the output produced by the --version option lists the "custom-conf" feature.
Options appearing in the CTAGS environment variable or on the command line will override options specified in these files. Only options will be read from these files. Note
that the option files are read in line-oriented mode in which spaces are significant (since shell quoting is not possible) but spaces at the beginning of a line are ignored.
Each line of the file is read as one command line parameter (as if it were quoted with single quotes). Therefore, use new lines to indicate separate command-line arguments.
A line starting with '#' is treated as a comment.
*.ctags files in a directory are loaded in alphabetical order.
tags The default tag file created by ctags.
TAGS The default tag file created by etags.

ZSH complains about RVM __rvm_cleanse_variables: function definition file not found

When using the latest ZSH and RVM on Mac OS X 10.7.4 ZSH complains about this:
__rvm_cleanse_variables: function definition file not found
Running the following solved the problem:
rm ~/.zcompdump*
Note: The * is incase there are multiple .zcompdump files.
Sometime there is also ~/.zcompdump-<COMPUTER NAME>-<VERSION> file, so use:
rm -f ~/.zcompdump*
To disable the .zcompdump* file(s), you could look in your .zshrc (or /etc/zsh/* files) for compinit and add the -D flag.
This might be better than creating the files and deleting them at every login.
(source: http://www.csse.uwa.edu.au/programming/linux/zsh-doc/zsh_23.html)
My problem persisted even after the compinit -D and rm -f ~/.zcompdump*. I found this github issue and checked my .zplug directory and sure enough found some non-hidden zcompdump files (no preceding '.'). Deleted those and I was good to go. If you're using a zsh plugin manager like zgen or zplug, check their directories.
Add rm -f ~/.zcompdump{,.zwc} to .zlogin to automate it

Resources