Skip to content

Instantly share code, notes, and snippets.

@jackcviers
Created March 19, 2012 23:12
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save jackcviers/2128247 to your computer and use it in GitHub Desktop.
Save jackcviers/2128247 to your computer and use it in GitHub Desktop.
.ctags description for JavaScript and Coffeescript
--langdef=js
--langmap=js:.js
--regex-js=/([A-Za-z0-9._$]+)[ \t]*[:=][ \t]*\{/\1/,object/
--regex-js=/([A-Za-z0-9._$()]+)[ \t]*[:=][ \t]*function[ \t]*\(/\1/,function/
--regex-js=/function[ \t]+([A-Za-z0-9._$]+)[ \t]*\(([^)])\)/\1/,function/
--regex-js=/([A-Za-z0-9._$]+)[ \t]*[:=][ \t]*\[/\1/,array/
--regex-js=/([^= ]+)[ \t]*=[ \t]*[^"]'[^']*/\1/,string/
--regex-js=/([^= ]+)[ \t]*=[ \t]*[^']"[^"]*/\1/,string/
--langdef=coffee
--langmap=coffee:.coffee
--regex-coffee=/^[ \t]*([A-Za-z.]+)[ \t]+=.*->.*$/\1/f,function/
--regex-coffee=/^[ \t]*([A-Za-z.]+)[ \t]+=[^->\n]*$/\1/v,variable/
--regex-coffee=/^[ \t]*((class ){1}[A-Za-z.]+)[ \t]+=[^->\n]*$/\1/v,object/
@jackcviers
Copy link
Author

This is my .ctags file for editing JavaScript and Coffeescript. This, combined with Exuberant CTags (etags) will generate pretty good tags for use with auto-complete-mode and -. (find-tag) and other tag- queries from the command buffer in Emacs. You can find the latest auto-complete-mode at http://cx4a.org/software/auto-complete/

I highly recommend using these to edit JS/CS, as they are the closest to in-browser debug console autocompletion that you'll find anywhere. Much thanks to @mads379 for his gist on coffeescript ctags regexes (https://gist.github.com/907245) and George V. Reilly for his post on JS ctags (http://weblogs.asp.net/george_v_reilly/archive/2009/03/24/exuberant-ctags-and-javascript.aspx). As you can see, I merely combined the two and added the class definition line to the coffeescript stuff. Fork away!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment