function AddTag() local m_end = 0; local senv, env; local lineNumber = editor:LineFromPosition(editor.CurrentPos); local posAtStartOfLine = editor:PositionFromLine(lineNumber); local posAlongLine = editor.CurrentPos - posAtStartOfLine; local str = editor:GetLine(lineNumber); local length = string.len(str); local etemp ="" local off = 0; local xtemp = string.sub(str,posAlongLine-1,posAlongLine)--check tag is not terminated with /> if (xtemp ~= "/>") and (xtemp ~= "/>\r\n") and (xtemp ~= "/>\n") and (xtemp ~= "/>\r") then --ignore newlines -- look for last repeat senv = env; m_start, m_end, env = string.find(str, '<(.-)>', m_end); if m_start then --check that just typed tag isn't an end etemp=string.sub(str,m_start,m_start+1) if ((etemp==" posAlongLine)) -- Do't go past current position -- add if(senv) and off==0 then --senv isn't empty and off is off editor:insert(editor.CurrentPos,"'); end; end end; function OnChar(char) if(char==">") then AddTag(); end; end;