' Ruby code completion script for PSPad. ' Save this file as "C:\Program Files\PSPad editor\Script\VBScript\Completion.vbs" ' Function: ' It automatically adds 'end' to 'class', 'def', 'while', 'if', 'do' statements ' It works when you press 'Enter'. ' Only for Ruby files with .rb extension. ' Author: Sung Soo Kim (sskim.box@gmail.com) ' Version: 0.001a ' Copyright: GPL ' Even though it is GPL, I don't care at least for this version. ' It is a too simple script anyway. :) Use this file and codes as you want. ' Just let me know if you know a better way or have suggestion. const module_name = "Ruby Code Completion" const module_ver = "0.001a" sub RubyCodeCompletion Set editor = newEditor() Set regEx = New RegExp editor.assignActiveEditor file = editor.fileName regEx.Pattern = ".rb" ' Only when the file is a ruby file. matched = regEx.Test(file) if matched Then matched = matched else editor.command "ecLineBreak" exit sub end if sel = editor.lineText regEx.Pattern = "^\s*(class)|(def)|(while)|(if)|((.*\s+)?do\s*(\|\s*[a_zA_Z0_9_]+\s*\|)?)" matched = regEx.Test(sel) if matched Then editor.command "ecLineEnd" editor.command "ecLineBreak" editor.command "ecLineBreak" editor.lineText editor.lineText & "end" editor.command "ecUp" editor.command "ecTab" else editor.command "ecLineBreak" exit sub end if end sub sub Init ' Set key binding addMenuItem "Ruby completion", "Code Completion", "RubyCodeCompletion" , "Enter" 'addMenuItem "", "", "RubyCodeCompletion" , "Enter" end sub