-- TIME_STAMP 2016-01-25 22:37:26 SemiColonHit = EventClass:new(Common) local iTargetcol = (tonumber(props['Comment.Autopos.*.au3']) or 100) -1 function SemiColonHit:OnKey(_keycode, _shift, _ctrl, _alt) if props['FileExt']:upper() ~= 'AU3' then return nil end if _keycode == 188 and _shift and not _ctrl and not _alt then local iPosCurrent = editor.CurrentPos local iCol = editor.Column[iPosCurrent] -- do nothing, if cursor at line start or behind target column if iCol == 0 or iCol >= iTargetcol then return nil end -- check if style is 0 if editor.StyleAt[iPosCurrent] ~= 0 then return nil end -- check if only spaces/tabs left from cursor local iLine = editor:LineFromPosition(iPosCurrent) local iPosStart = editor:PositionFromLine(iLine) editor:SetSelection(iPosStart,iPosCurrent) local sSel = editor:GetSelText() editor.CurrentPos = iPosCurrent if sSel:gsub('%s*', '') == '' then return nil end -- check if no text right from cursor editor:LineEnd() local iPosEnd = editor.CurrentPos editor:SetSelection(iPosCurrent,iPosEnd) local sSel = editor:GetSelText() editor.CurrentPos = iPosCurrent if sSel:gsub('[%s\n]*', '') ~= '' then return nil end -- calculate difference to target column, fill with spaces local iDiff = iTargetcol - iCol editor:BeginUndoAction() editor:insert(iPosCurrent, (' '):rep(iDiff)..'; ') editor:LineEnd() editor:EndUndoAction() return true else return nil end end