Blame | Last modification | View Log | RSS feed
" Vim script file vim600:fdm=marker:" FileType: XML" Author: Devin Weaver <vim (at) tritarget.com>" Maintainer: Devin Weaver <vim (at) tritarget.com>" Last Change: $Date: 2005/05/14 22:13:22 $" Version: $Revision: 1.29 $" Location: http://www.vim.org/scripts/script.php?script_id=301" Licence: This program is free software; you can redistribute it" and/or modify it under the terms of the GNU General Public" License. See http://www.gnu.org/copyleft/gpl.txt" Credits: Brad Phelan <bphelan (at) mathworks.co.uk> for completing" tag matching and visual tag completion." Ma, Xiangjiang <Xiangjiang.Ma (at) broadvision.com> for" pointing out VIM 6.0 map <buffer> feature." Luc Hermitte <hermitte (at) free.fr> for testing the self" install documentation code and providing good bug fixes." Guo-Peng Wen for the self install documentation code." This script provides some convenience when editing XML (and some SGML)" formated documents." Section: Documentation" ----------------------"" Documentation should be available by ":help xml-plugin" command, once the" script has been copied in you .vim/plugin directory."" You still can read the documentation at the end of this file. Locate it by" searching the "xml-plugin" string (and set ft=help to have" appropriate syntaxic coloration)." Note: If you used the 5.x version of this file (xmledit.vim) you'll need to" comment out the section where you called it since it is no longer used in" version 6.x." TODO: Revamp ParseTag to pull appart a tag a rebuild it properly." a tag like: < test nowrap testatt=foo >" should be fixed to: <test nowrap="nowrap" testatt="foo"></test>"==============================================================================" Only do this when not done yet for this bufferif exists("b:did_ftplugin")finishendiflet b:did_ftplugin = 1" WrapTag -> Places an XML tag around a visual selection. {{{1" Brad Phelan: Wrap the argument in an XML tag" Added nice GUI support to the dialogs." Rewrote function to implement new algorythem that addresses several bugs.if !exists("*s:WrapTag")function s:WrapTag(text)if (line(".") < line("'<"))let insert_cmd = "o"elseif (col(".") < col("'<"))let insert_cmd = "a"elselet insert_cmd = "i"endifif strlen(a:text) > 10let input_text = strpart(a:text, 0, 10) . '...'elselet input_text = a:textendiflet wraptag = inputdialog('Tag to wrap "' . input_text . '" : ')if strlen(wraptag)==0if strlen(b:last_wrap_tag_used)==0undoreturnendiflet wraptag = b:last_wrap_tag_usedlet atts = b:last_wrap_atts_usedelselet atts = inputdialog('Attributes in <' . wraptag . '> : ')endifif (visualmode() ==# 'V')let text = strpart(a:text,0,strlen(a:text)-1)if (insert_cmd ==# "o")let eol_cmd = ""elselet eol_cmd = "\<Cr>"endifelselet text = a:textlet eol_cmd = ""endifif strlen(atts)==0let text = "<".wraptag.">".text."</".wraptag.">"let b:last_wrap_tag_used = wraptaglet b:last_wrap_atts_used = ""elselet text = "<".wraptag." ".atts.">".text."</".wraptag.">"let b:last_wrap_tag_used = wraptaglet b:last_wrap_atts_used = attsendifexecute "normal! ".insert_cmd.text.eol_cmdendfunctionendif" NewFileXML -> Inserts <?xml?> at top of new file. {{{1if !exists("*s:NewFileXML")function s:NewFileXML( )" Where is g:did_xhtmlcf_inits defined?if &filetype == 'xml' || (!exists ("g:did_xhtmlcf_inits") && exists ("g:xml_use_xhtml") && (&filetype == 'html' || &filetype == 'xhtml'))if append (0, '<?xml version="1.0"?>')normal! Gendifendifendfunctionendif" Callback -> Checks for tag callbacks and executes them. {{{1if !exists("*s:Callback")function s:Callback( xml_tag, isHtml )let text = 0if a:isHtml == 1 && exists ("*HtmlAttribCallback")let text = HtmlAttribCallback (a:xml_tag)elseif exists ("*XmlAttribCallback")let text = XmlAttribCallback (a:xml_tag)endifif text != '0'execute "normal! i " . text ."\<Esc>l"endifendfunctionendif" IsParsableTag -> Check to see if the tag is a real tag. {{{1if !exists("*s:IsParsableTag")function s:IsParsableTag( tag )" The "Should I parse?" flag.let parse = 1" make sure a:tag has a proper tag in it and is not a instruction or end tag.if a:tag !~ '^<[[:alnum:]_:\-].*>$'let parse = 0endif" make sure this tag isn't already closed.if strpart (a:tag, strlen (a:tag) - 2, 1) == '/'let parse = 0endifreturn parseendfunctionendif" ParseTag -> The major work hourse for tag completion. {{{1if !exists("*s:ParseTag")function s:ParseTag( )" Save registerslet old_reg_save = @"let old_save_x = @xif (!exists("g:xml_no_auto_nesting") && strpart (getline ("."), col (".") - 2, 2) == '>>')let multi_line = 1execute "normal! \"xX"elselet multi_line = 0endiflet @" = ""execute "normal! \"xy%%"let ltag = @"if (&filetype == 'html' || &filetype == 'xhtml') && (!exists ("g:xml_no_html"))let html_mode = 1let ltag = substitute (ltag, '[^[:graph:]]\+', ' ', 'g')let ltag = substitute (ltag, '<\s*\([^[:alnum:]_:\-[:blank:]]\=\)\s*\([[:alnum:]_:\-]\+\)\>', '<\1\2', '')elselet html_mode = 0endifif <SID>IsParsableTag (ltag)" find the break between tag name and atributes (or closing of tag)" Too bad I can't just grab the position index of a pattern in a string.let index = 1while index < strlen (ltag) && strpart (ltag, index, 1) =~ '[[:alnum:]_:\-]'let index = index + 1endwhilelet tag_name = strpart (ltag, 1, index - 1)if strpart (ltag, index) =~ '[^/>[:blank:]]'let has_attrib = 1elselet has_attrib = 0endif" That's (index - 1) + 2, 2 for the '</' and 1 for the extra character the" while includes (the '>' is ignored because <Esc> puts the curser on top" of the '>'let index = index + 2" print out the end tag and place the cursor back were it left offif html_mode && tag_name =~? '^\(img\|input\|param\|frame\|br\|hr\|meta\|link\|base\|area\)$'if has_attrib == 0call <SID>Callback (tag_name, html_mode)endifif exists ("g:xml_use_xhtml")execute "normal! i /\<Esc>l"endifelseif multi_line" Can't use \<Tab> because that indents 'tabstop' not 'shiftwidth'" Also >> doesn't shift on an empty line hence the temporary char 'x'let com_save = &commentsset comments-=n:>execute "normal! a\<Cr>\<Cr>\<Esc>kAx\<Esc>>>$\"xx"execute "set comments=" . com_save" restore registerslet @" = old_reg_savelet @x = old_save_xstartinsert!return ""elseif has_attrib == 0call <SID>Callback (tag_name, html_mode)endifexecute "normal! a</" . tag_name . ">\<Esc>" . index . "h"endifendifendif" restore registerslet @" = old_reg_savelet @x = old_save_xif col (".") < strlen (getline ("."))execute "normal! l"startinsertelsestartinsert!endifendfunctionendif" ParseTag2 -> Experimental function to replace ParseTag {{{1"if !exists("*s:ParseTag2")"function s:ParseTag2( )" My thought is to pull the tag out and reformat it to a normalized tag" and put it back."endfunction"endif" BuildTagName -> Grabs the tag's name for tag matching. {{{1if !exists("*s:BuildTagName")function s:BuildTagName( )"First check to see if we Are allready on the end of the tag. The / search"forwards command will jump to the next tag otherwise" Store contents of register x in a variablelet b:xreg = @xexec "normal! v\"xy"if @x=='>'" Don't do anythingelseexec "normal! />/\<Cr>"endif" Now we head back to the < to reach the beginning.exec "normal! ?<?\<Cr>"" Capture the tag (a > will be catured by the /$/ match)exec "normal! v/\\s\\|$/\<Cr>\"xy"" We need to strip off any junk at the end.let @x=strpart(@x, 0, match(@x, "[[:blank:]>\<C-J>]"))"remove <, >let @x=substitute(@x,'^<\|>$','','')" remove spaces.let @x=substitute(@x,'/\s*','/', '')let @x=substitute(@x,'^\s*','', '')" Swap @x and b:xreglet temp = @xlet @x = b:xreglet b:xreg = tempendfunctionendif" TagMatch1 -> First step in tag matching. {{{1" Brad Phelan: First step in tag matching.if !exists("*s:TagMatch1")function s:TagMatch1()" Save registerslet old_reg_save = @""Drop a marker here just in case we have a mismatched tag and"wish to return (:mark looses column position)normal! mzcall <SID>BuildTagName()"Check to see if it is an end tag. If it is place a 1 in endtagif match(b:xreg, '^/')==-1let endtag = 0elselet endtag = 1endif" Extract the tag from the whole tag block" eg if the block =" tag attrib1=blah attrib2=blah" we will end up with" tag" with no trailing or leading spaceslet b:xreg=substitute(b:xreg,'^/','','g')" Make sure the tag is valid." Malformed tags could be <?xml ?>, <![CDATA[]]>, etc.if match(b:xreg,'^[[:alnum:]_:\-]') != -1" Pass the tag to the matching" routinecall <SID>TagMatch2(b:xreg, endtag)endif" Restore registerslet @" = old_reg_saveendfunctionendif" TagMatch2 -> Second step in tag matching. {{{1" Brad Phelan: Second step in tag matching.if !exists("*s:TagMatch2")function s:TagMatch2(tag,endtag)let match_type=''" Build the pattern for searching for XML tags based" on the 'tag' type passed into the function." Note we search forwards for end tags and" backwards for start tagsif a:endtag==0"let nextMatch='normal /\(<\s*' . a:tag . '\(\s\+.\{-}\)*>\)\|\(<\/' . a:tag . '\s*>\)'let match_type = '/'else"let nextMatch='normal ?\(<\s*' . a:tag . '\(\s\+.\{-}\)*>\)\|\(<\/' . a:tag . '\s*>\)'let match_type = '?'endifif a:endtag==0let stk = 1elselet stk = 1end" wrapscan must be turned on. We'll recored the value and reset it afterward." We have it on because if we don't we'll get a nasty error if the search hits" BOF or EOF.let wrapval = &wrapscanlet &wrapscan = 1"Get the current location of the cursor so we can"detect if we wrap on ourselveslet lpos = line(".")let cpos = col(".")if a:endtag==0" If we are trying to find a start tag" then decrement when we find a start taglet iter = 1else" If we are trying to find an end tag" then increment when we find a start taglet iter = -1endif"Loop until stk == 0.while 1" exec search." Make sure to avoid />$/ as well as /\s$/ and /$/.exec "normal! " . match_type . '<\s*\/*\s*' . a:tag . '\([[:blank:]>]\|$\)' . "\<Cr>"" Check to see if our match makes sence.if a:endtag == 0if line(".") < lposcall <SID>MisMatchedTag (0, a:tag)breakelseif line(".") == lpos && col(".") <= cposcall <SID>MisMatchedTag (1, a:tag)breakendifelseif line(".") > lposcall <SID>MisMatchedTag (2, '/'.a:tag)breakelseif line(".") == lpos && col(".") >= cposcall <SID>MisMatchedTag (3, '/'.a:tag)breakendifendifcall <SID>BuildTagName()if match(b:xreg,'^/')==-1" Found start taglet stk = stk + iterelse" Found end taglet stk = stk - iterendifif stk == 0breakendifendwhilelet &wrapscan = wrapvalendfunctionendif" MisMatchedTag -> What to do if a tag is mismatched. {{{1if !exists("*s:MisMatchedTag")function s:MisMatchedTag( id, tag )"Jump back to our formor spotnormal! `znormal zzechohl WarningMsg" For debugging"echo "Mismatched tag " . a:id . ": <" . a:tag . ">"" For releaseecho "Mismatched tag <" . a:tag . ">"echohl Noneendfunctionendif" DeleteTag -> Deletes surrounding tags from cursor. {{{1" Modifies mark zif !exists("*s:DeleteTag")function s:DeleteTag( )if strpart (getline ("."), col (".") - 1, 1) == "<"normal! lendifif search ("<[^\/]", "bW") == 0returnendifnormal! mznormal \5normal! d%`zd%endfunctionendif" VisualTag -> Selects Tag body in a visual selection. {{{1" Modifies mark zif !exists("*s:VisualTag")function s:VisualTag( )if strpart (getline ("."), col (".") - 1, 1) == "<"normal! lendifif search ("<[^\/]", "bW") == 0returnendifnormal! mznormal \5normal! %exe "normal! " . visualmode()normal! `zendfunctionendif" Section: Doc installation {{{1" Function: s:XmlInstallDocumentation(full_name, revision) {{{2" Install help documentation." Arguments:" full_name: Full name of this vim plugin script, including path name." revision: Revision of the vim script. #version# mark in the document file" will be replaced with this string with 'v' prefix." Return:" 1 if new document installed, 0 otherwise." Note: Cleaned and generalized by guo-peng Wen"'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''function! s:XmlInstallDocumentation(full_name, revision)" Name of the document path based on the system we use:if (has("unix"))" On UNIX like system, using forward slash:let l:slash_char = '/'let l:mkdir_cmd = ':silent !mkdir -p 'else" On M$ system, use backslash. Also mkdir syntax is different." This should only work on W2K and up.let l:slash_char = '\'let l:mkdir_cmd = ':silent !mkdir 'endiflet l:doc_path = l:slash_char . 'doc'"let l:doc_home = l:slash_char . '.vim' . l:slash_char . 'doc'" Figure out document path based on full name of this script:let l:vim_plugin_path = fnamemodify(a:full_name, ':h')"let l:vim_doc_path = fnamemodify(a:full_name, ':h:h') . l:doc_pathlet l:vim_doc_path = matchstr(l:vim_plugin_path,\ '.\{-}\ze\%(\%(ft\)\=plugin\|macros\)') . l:doc_pathif (!(filewritable(l:vim_doc_path) == 2))echomsg "Doc path: " . l:vim_doc_pathexecute l:mkdir_cmd . l:vim_doc_pathif (!(filewritable(l:vim_doc_path) == 2))" Try a default configuration in user home:"let l:vim_doc_path = expand("~") . l:doc_homelet l:vim_doc_path = matchstr(&rtp,\ escape($HOME, '\') .'[/\\]\%(\.vim\|vimfiles\)')if (!(filewritable(l:vim_doc_path) == 2))execute l:mkdir_cmd . l:vim_doc_pathif (!(filewritable(l:vim_doc_path) == 2))" Put a warning:echomsg "Unable to open documentation directory"echomsg " type :help add-local-help for more informations."return 0endifendifendifendif" Exit if we have problem to access the document directory:if (!isdirectory(l:vim_plugin_path)\ || !isdirectory(l:vim_doc_path)\ || filewritable(l:vim_doc_path) != 2)return 0endif" Full name of script and documentation file:let l:script_name = 'xml.vim'let l:doc_name = 'xml-plugin.txt'let l:plugin_file = l:vim_plugin_path . l:slash_char . l:script_namelet l:doc_file = l:vim_doc_path . l:slash_char . l:doc_name" Bail out if document file is still up to date:if (filereadable(l:doc_file) &&\ getftime(l:plugin_file) < getftime(l:doc_file))return 0endif" Prepare window position restoring command:if (strlen(@%))let l:go_back = 'b ' . bufnr("%")elselet l:go_back = 'enew!'endif" Create a new buffer & read in the plugin file (me):setl nomodelineexe 'enew!'exe 'r ' . l:plugin_filesetl modelinelet l:buf = bufnr("%")setl noswapfile modifiablenorm zRnorm gg" Delete from first line to a line starts with" === START_DOC1,/^=\{3,}\s\+START_DOC\C/ d" Delete from a line starts with" === END_DOC" to the end of the documents:/^=\{3,}\s\+END_DOC\C/,$ d" Remove fold marks:% s/{\{3}[1-9]/ /" Add modeline for help doc: the modeline string is mangled intentionally" to avoid it be recognized by VIM:call append(line('$'), '')call append(line('$'), ' v' . 'im:tw=78:ts=8:ft=help:norl:')" Replace revision:exe "normal :1,5s/#version#/ v" . a:revision . "/\<CR>"" Save the help document:exe 'w! ' . l:doc_fileexe l:go_backexe 'bw ' . l:buf" Build help tags:exe 'helptags ' . l:vim_doc_pathreturn 1endfunction" }}}2let s:revision=\ substitute("$Revision: 1.29 $",'\$\S*: \([.0-9]\+\) \$','\1','')silent! let s:install_status =\ s:XmlInstallDocumentation(expand('<sfile>:p'), s:revision)if (s:install_status == 1)echom expand("<sfile>:t:r") . '-plugin v' . s:revision .\ ': Help-documentation installed.'endif" Mappings and Settings. {{{1" This makes the '%' jump between the start and end of a single tag.setlocal matchpairs+=<:>" Have this as an escape incase you want a literal '>' not to run the" ParseTag function.if !exists("g:xml_tag_completion_map")inoremap <buffer> <LocalLeader>. >inoremap <buffer> <LocalLeader>> >endif" Jump between the beggining and end tags.nnoremap <buffer> <LocalLeader>5 :call <SID>TagMatch1()<Cr>nnoremap <buffer> <LocalLeader>% :call <SID>TagMatch1()<Cr>vnoremap <buffer> <LocalLeader>5 <Esc>:call <SID>VisualTag()<Cr>vnoremap <buffer> <LocalLeader>% <Esc>:call <SID>VisualTag()<Cr>" Wrap selection in XML tagvnoremap <buffer> <LocalLeader>x "xx:call <SID>WrapTag(@x)<Cr>nnoremap <buffer> <LocalLeader>d :call <SID>DeleteTag()<Cr>" Parse the tag after pressing the close '>'.if !exists("g:xml_tag_completion_map")inoremap <buffer> > ><Esc>:call <SID>ParseTag()<Cr>elseexecute "inoremap <buffer> " . g:xml_tag_completion_map . " ><Esc>:call <SID>ParseTag()<Cr>"endifaugroup xmlau!au BufNewFile * call <SID>NewFileXML()augroup END"}}}1finish""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Section: Documentation content {{{1""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""=== START_DOC*xml-plugin.txt* Help edit XML and SGML documents. #version#XML Edit {{{2 ~A filetype plugin to help edit XML and SGML documents.This script provides some convenience when editing XML (and some SGMLincluding HTML) formated documents. It allows you to jump to the beginningor end of the tag block your cursor is in. '%' will jump between '<' and '>'within the tag your cursor is in. When in insert mode and you finish a tag(pressing '>') the tag will be completed. If you press '>' twice it willcomplete the tag and place the cursor in the middle of the tags on it's ownline (helps with nested tags).Usage: Place this file into your ftplugin directory. To add html supportSym-link or copy this file to html.vim in your ftplugin directory. To activtethe script place 'filetype plugin on' in your |.vimrc| file. See |ftplugins|for more information on this topic.If the file edited is of type "html" and "xml_use_html" is defined then thefollowing tags will not auto complete:<img>, <input>, <param>, <frame>, <br>, <hr>, <meta>, <link>, <base>, <area>If the file edited is of type 'html' and 'xml_use_xhtml' is defined the abovetags will autocomplete the xml closing staying xhtml compatable.ex. <hr> becomes <hr /> (see |xml-plugin-settings|)NOTE: If you used the VIM 5.x version of this file (xmledit.vim) you'll needto comment out the section where you called it. It is no longer used in theVIM 6.x version.Known Bugs {{{2 ~- This script will modify registers ". and "x; register "" will be restored.- < & > marks inside of a CDATA section are interpreted as actual XML tagseven if unmatched.- Although the script can handle leading spaces such as < tag></ tag> it isillegal XML syntax and considered very bad form.- Placing a literal `>' in an attribute value will auto complete dispite thatthe start tag isn't finished. This is poor XML anyway you should use> instead.- The matching algorithm can handle illegal tag characters where as the tagcompletion algorithm can not.------------------------------------------------------------------------------*xml-plugin-mappings*Mappings {{{2 ~<LocalLeader> is a setting in VIM that depicts a prefix for scripts andplugins to use. By default this is the backslash key `\'. See |mapleader|for details.<LocalLeader>xVisual - Place a custom XML tag to suround the selected text. Youneed to have selected text in visual mode before you can use thismapping. See |visual-mode| for details.<LocalLeader>. or <LocalLeader>>Insert - Place a literal '>' without parsing tag.<LocalLeader>5 or <LocalLeader>%Normal or Visual - Jump to the begining or end tag.<LocalLeader>dNormal - Deletes the surrounding tags from the cursor. ><tag1>outter <tag2>inner text</tag2> text</tag1>^< Turns to: >outter <tag2>inner text</tag2> text^<------------------------------------------------------------------------------*xml-plugin-settings*Options {{{2 ~(All options must be placed in your |.vimrc| prior to the |ftplugin|command.)xml_tag_completion_mapUse this setting to change the default mapping to auto complete atag. By default typing a literal `>' will cause the tag your editingto auto complete; pressing twice will auto nest the tag. By usingthis setting the `>' will be a literal `>' and you must use the newmapping to perform auto completion and auto nesting. For example ifyou wanted Control-L to perform auto completion inmstead of typing a`>' place the following into your .vimrc: >let xml_tag_completion_map = "<C-l>"<xml_no_auto_nestingThis turns off the auto nesting feature. After a completion is madeand another `>' is typed xml-edit automatically will break the tagaccross multiple lines and indent the curser to make creating nestedtqags easier. This feature turns it off. Enter the following in your.vimrc: >let xml_no_auto_nesting = 1<xml_use_xhtmlWhen editing HTML this will auto close the short tags to make validXML like <hr /> and <br />. Enter the following in your vimrc toturn this option on: >let xml_use_xhtml = 1<xml_no_htmlThis turns of the support for HTML specific tags. Place this in your.vimrc: >let xml_no_html = 1<------------------------------------------------------------------------------*xml-plugin-callbacks*Callback Functions {{{2 ~A callback function is a function used to customize features on a per tagbasis. For example say you wish to have a default set of attributs when youtype an empty tag like this:You type: <tag>You get: <tag default="attributes"></tag>This is for any script programmers who wish to add xml-plugin support tothere own filetype plugins.Callback functions recive one attribute variable which is the tag name. Theall must return either a string or the number zero. If it returns a stringthe plugin will place the string in the proper location. If it is a zero theplugin will ignore and continue as if no callback existed.The following are implemented callback functions:HtmlAttribCallbackThis is used to add default attributes to html tag. It is intendedfor HTML files only.XmlAttribCallbackThis is a generic callback for xml tags intended to add attributes.*xml-plugin-html*Callback Example {{{2 ~The following is an example of using XmlAttribCallback in your .vimrc>function XmlAttribCallback (xml_tag)if a:xml_tag ==? "my-xml-tag"return "attributes=\"my xml attributes\""elsereturn 0endifendfunction<The following is a sample html.vim file type plugin you could use:>" Vim script file vim600:fdm=marker:" FileType: HTML" Maintainer: Devin Weaver <vim (at) tritarget.com>" Location: http://www.vim.org/scripts/script.php?script_id=301" This is a wrapper script to add extra html support to xml documents." Original script can be seen in xml-plugin documentation." Only do this when not done yet for this bufferif exists("b:did_ftplugin")finishendif" Don't set 'b:did_ftplugin = 1' because that is xml.vim's responsability.let b:html_mode = 1if !exists("*HtmlAttribCallback")function HtmlAttribCallback( xml_tag )if a:xml_tag ==? "table"return "cellpadding=\"0\" cellspacing=\"0\" border=\"0\""elseif a:xml_tag ==? "link"return "href=\"/site.css\" rel=\"StyleSheet\" type=\"text/css\""elseif a:xml_tag ==? "body"return "bgcolor=\"white\""elseif a:xml_tag ==? "frame"return "name=\"NAME\" src=\"/\" scrolling=\"auto\" noresize"elseif a:xml_tag ==? "frameset"return "rows=\"0,*\" cols=\"*,0\" border=\"0\""elseif a:xml_tag ==? "img"return "src=\"\" width=\"0\" height=\"0\" border=\"0\" alt=\"\""elseif a:xml_tag ==? "a"if has("browse")" Look up a file to fill the href. Used in local relative file" links. typeing your own href before closing the tag with `>'" will override this.let cwd = getcwd()let cwd = substitute (cwd, "\\", "/", "g")let href = browse (0, "Link to href...", getcwd(), "")let href = substitute (href, cwd . "/", "", "")let href = substitute (href, " ", "%20", "g")elselet href = ""endifreturn "href=\"" . href . "\""elsereturn 0endifendfunctionendif" On to loading xml.vimruntime ftplugin/xml.vim<=== END_DOC""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" v im:tw=78:ts=8:ft=help:norl:" vim600: set foldmethod=marker tabstop=8 shiftwidth=2 softtabstop=2 smartindent smarttab :"fileencoding=iso-8859-15