[m-dev.] Script to improve tag searching under Vim

Ralph Becket rafe at cs.mu.OZ.AU
Fri Aug 12 15:09:39 AEST 2005

One problem I have with tags under Vim is that ^-] takes you to the
first match in the tags file.  This is often something less commonly
wanted like a structure field rather than a type definition or a pred
signature.  I've tried reordering the entries in the tags file based
on the kind information, but that doesn't make any difference.

The fix is to split the tags file up into separate files using the
attached script, do `:set tags=tags.types,tags.preds,tags.modes,tags.other'
and Vim will tag jump to the first match in the first file that contains
a match.

-- Ralph
-------------- next part --------------
#!/usr/bin/gawk -f

# vim:set ft=awk,ts=2,sw=2,et
# mtags produces a single, sorted tags file.  Vim will jump to the first
# match in the first tags file with a match.  Unfortunately, with a
# single tags file, this means you often jump to a field, say, when the
# "obvious" choice is to a type definition.  Rearranging matches on the
# kind field seems to make no difference to Vim.  This script splits a
# tags file into tags.types, tags.preds (includes functions), tags.modes
# (includes insts), and tags.other.

	system("rm -f tags.types tags.preds tags.modes tags.other")

/kind:type/ { print > "tags.types"; next }
/kind:func/ { print > "tags.preds"; next }
/kind:pred/ { print > "tags.preds"; next }
/kind:inst/ { print > "tags.modes"; next }
/kind:mode/ { print > "tags.modes"; next }
            { print > "tags.other"; next }

More information about the developers mailing list