Need a way to navigate/browse XSLT files easily with Vim. Similar to the way ctags can be used with C/C++ source code. A good solution would allow installing scripts etc only for self or running them directly from inside Vim. Hate having to step out of vim just to search for a function definition or "text" search.
Searched for a few hours and came up with some good leads like 'ack'. Apparently this can be integrated with vim using ack.vim. Yet to test this out properly.
Essentially I should be able to go through a maze of .xsl files which include other .xsl files and use functions, templates. Any suggestions?
I found the kipelovets' and GuruM's answers to be useful and worked out this solution that combines their advice.:
.ctags file:
--langdef=xslt
--langmap=xslt:.xsl
--regex-xslt=/<xsl:template[^>]+name=\"([-a-zA-Z0-9_:]+)\"( +mode="([^"]+)")?/\1 \2/n,namedtemplate/i
--regex-xslt=/<xsl:template[^>]+match=\"([^"]+)\"( +mode="([^"]+)")?/\1 \2/m,matchedtemplate/i
--regex-xslt=/<xsl:apply-templates +select="([^"]{2,})"( +mode="([^"]+)")?/\1 \2/a,applytemplate/i
--regex-xslt=/<xsl:call-template +select="([^"]+)"( +mode="([^"]+)")?/\1 \2/c,calltemplate/i
--regex-xslt=/<xsl:variable[^>]+name=\"([-a-zA-Z0-9_]+)\"/\1/v,variable/i
--regex-xslt=/<xsl:function[^>]+name=\"([-a-zA-Z0-9_:]+)\"/\1/f,function/i
--regex-xslt=/<xsl:param[^>]+name=\"([-a-zA-Z0-9_:]+)\"/\1/p,parameter/i
vim tagbar settings (which some people may find useful):
let g:tagbar_type_xslt = {
\ 'ctagstype' : 'xslt',
\ 'kinds' : [
\ 'n:templates (named)',
\ 'm:templates (matched)',
\ 'a:applied templates',
\ 'c:called templates',
\ 'f:functions',
\ 'p:parameters',
\ 'v:variables'
\ ]
\ }
It's better, but some issues I am still having include:
A better approach to try in future:
thanks for your question and answer @GuruM
though your version of ~/.ctags didn't work for me, i used following:
--langdef=xslt
--langmap=xslt:.xsl
--regex-xslt=/<xsl:template[^>]+name=\"([-a-zA-Z0-9_:]+)\"/\1/f,function/i
it works perfectly with AutoTag plugin and requires only one following line for TagList plugin:
let s:tlist_def_xslt_settings = 'xslt;f:function'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With