Toggle Block Comment
About
A simple plugin that allows you to quickly toggle comments around the text you have selected with a keyboard shortcutSupport My Work
If you liked my work and want to donate to me you can do so here
Source Code
local StudioService = game:GetService("StudioService")
local ScriptEditorService = game:GetService("ScriptEditorService")
local pluginAction = plugin:CreatePluginAction("ToggleBlockComment", "Toggle Block Comment", "Toggle selection block commenting")
pluginAction.Triggered:Connect(function()
if StudioService.ActiveScript == nil then return end
local scriptDocument = ScriptEditorService:FindScriptDocument(StudioService.ActiveScript)
if scriptDocument == nil then return end
if scriptDocument:HasSelectedText() == false then return end
local text = scriptDocument:GetSelectedText()
local startLine, startCharacter = scriptDocument:GetSelectionStart()
local endLine, endCharacter = scriptDocument:GetSelectionEnd()
local cursorLine, cursorCharacter, anchorLine, anchorCharacter = scriptDocument:GetSelection()
local curserlarger = cursorLine > anchorLine or cursorLine == anchorLine and cursorCharacter > anchorCharacter
local shiftSelection = if cursorLine == anchorLine then 6 else 2
if text:sub(1, 4) == "--[[" and text:sub(-2, -1) == "]]" then
if curserlarger then cursorCharacter -= shiftSelection else anchorCharacter -= shiftSelection end
scriptDocument:EditTextAsync(text:sub(5, -3), startLine, startCharacter, endLine, endCharacter)
else
if curserlarger then cursorCharacter += shiftSelection else anchorCharacter += shiftSelection end
scriptDocument:EditTextAsync("--[[" .. text .. "]]", startLine, startCharacter, endLine, endCharacter)
end
scriptDocument:RequestSetSelectionAsync(cursorLine, cursorCharacter, anchorLine, anchorCharacter)
end)
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted.
Other Projects
Infinite Terrain
Suphi’s DataStore Module
Infinite Scripter
Mesh Editor
Toggle Block Comment
Toggle Decomposition Geometry
Tag Explorer
Suphi’s Linked List Module
Suphi’s Hybrid Linked List Module
Suphi’s RemoteFunction Module