Search code examples
bashvimfile-extensionctags

ctags for shell scripts without extensions


I'm working on a Bash script that is designed to be run 'as a tool' so has a name without an extension and a #!/usr/bin/bash line at the top.

My script has a number of functions, so it would be nice if I could use Vim's tagging support to jump around the code, but I can't get ctags to tag the file. ctags mytool produces a tags file that is blank except for the comment section at the top.

If I rename my file to mytool.sh, ctags mytool.sh works perfectly.

Is there a way to force ctags to tag a file without an extension? I've tried a number of options that I found in the ctags manual that seem to relate to file extensions, but without joy.


Solution

  • If you're using "Exuberant Ctags", you can use the --language-force option:

    ctags --language-force=sh mytool
    

    This is documented explicitly in the man page.