Scite Tags

lua-users home
wiki

It is often necessary to navigate inside large projects, and ctags is a very effective tool for doing so. A popular version of ctags is known as the Exuberant Ctags [1] by Darren Hiebert that supports a healthy number of different languages. There are currently several scripts and therefore several methods available to provide SciteTags functionalities.

Basic readtags based version

The following SciteTags library is a small set of scripts for driving the supplied readtags program. See Files:wiki_insecure/editors/SciTE/ctags.lua.

Extended versions

These are extended experimental versions that only work with SciteExtMan. Note that these scripts doesn't need readtags and is a lot faster on slow machines.

This is the original version for SciteExtMan: <=> Files:wiki_insecure/editors/SciTE/ctagsx.lua

This is an alternative version that fixes a few problems with whitespace being present in the tag file... <=> Files:wiki_insecure/editors/SciTE/ctagsx_alt.lua

Yet another alternative version that dynamically searches and uses the nearest tags file relative to $FileDir path of the opened file. This version does not require specifying ctags.path.cxx in the properties file of SciTE and it is also able to cope with non Exuberant ctags as well <=> Files:wiki_insecure/editors/SciTE/ctagsdx.lua

Usage Illustrations

Obtaining ctags tools

http://home.mweb.co.za/sd/sdonovan/SciTE/ctags.zip includes a prebuilt Win32 version of ctags. Make sure that both ctags.exe and readtags.exe is on your path, and load ctags.lua as usual. (Under *nix, please note that there is often a program called 'ctags' which is not Exuberant!) Nevertheless, ctagsdx.lua is now able to cope with ctags, Exuberant or not.

Setting up SciTE

Put these in your properties files, unless you are using the extended versions ctagsx.lua or ctagsx_alt. All extended versions that work with SciteExtMan do not need the properties file:


ctags.path.cxx=<full path to tags file>

command.name.14.*=Find Tag
command.14.*=find_ctag $(CurrentWord)
command.subsystem.14.*=3
command.mode.14.*=savebefore:no
command.shortcut.14.*=Ctrl+.

command.name.15.*=Go to mark
command.15.*=goto_mark
command.subsystem.15.*=3
command.mode.15.*=savebefore:no
command.shortcut.15.*=Alt+.

command.name.16.*=Set Mark
command.16.*=set_mark
command.subsystem.16.*=3
command.mode.16.*=savebefore:no
command.shortcut.16.*=Ctrl+'

command.name.17.*=Select from Mark
command.17.*=select_mark
command.subsystem.17.*=3
command.mode.17.*=savebefore:no
command.shortcut.17.*=Ctrl+/


#ctags.exe --recurse --totals=yes --languages=c,c++ --verbose "d:\*" "c:\*"
command.name.18.*=rebuildTags
command.18.*=$(SciteDefaultHome)/ctags --recurse --totals=yes --languages=c,c++ "C:\Dokumente und Einstellungen\lars\Desktop\linux-2.6.15.7\*"
command.subsystem.18.*=0
command.mode.18.*=savebefore:no

Generating tags files

For instance, if you wanted to browse through the SciTE source, then to build a tags database you would say:
e:\scite> ctags src\*.cxx src\*.h win32\*.cxx win32\*.h
and then set ctags.path.cxx to e:\scite\tags

Finding tags (Applicable to all versions)

The basic operation is Find Tag, or Ctrl+., which works with the word under the cursor. This sets the mark, so you can immediately get back to your original position with Go to Mark, or Alt+. (I have had difficulties with setting shortcuts of this form with the GTK 1.2 version, so experiment. Your fingers will in any case find other shortcuts more comfortable).

As a bonus, Ctrl+' will Set Mark, and Ctrl+/ will select the text between the cursor and the mark position.

For the basic script, since it needs to run readtags, you will get a nasty flashing black box under Windows. A quick solution that doesn't require patching SciTE is the SciteOther library; SciteTags will automatically try to load this if it's available in the usual place. All extended versions ctagsx.lua, ctagsx_alt.lua do not have this issue, but you do have to put the script file in your scite_lua directory.

Extended features (Applicable to extended versions)

These features are only available for ctagsx.lua, ctagsx_alt.lua. When the search reveals more than one matching tag, all matching multiple tags will be presented in a drop-down list for selection. There is also the Alt+C key strokes feature that allows finding tags by name. An Alt+C followed by 't' allows one to find the tag name exactly as it has been typed. An Alt+C followed by 'f' allows finding tag name with the regular expression.
RecentChanges · preferences
edit · history
Last edited May 11, 2007 4:12 pm GMT (diff)