Is there a shortcut for folding code? Please share?

The popular SciTE-based AutoHotkey Script Editor
automater
Posts: 20
Joined: 01 Jul 2022, 08:51

Is there a shortcut for folding code? Please share?

Post by automater » 01 Jul 2022, 09:03

Is there a shortcut to fold multiple lines of selected code?

i.e. To replace manually typing "{" and "}" before and after those lines/blocks of code.

Been Googling this for half-hour to no avail. Please help!

I tried writing a script for this too but it's not working:

Code: Select all


^u::
Send ^x			
Send `{			
Send %Clipboard%	
Send `n
Send `}
return


User avatar
DrReflex
Posts: 42
Joined: 25 May 2015, 02:57
Location: Greer, SC

Re: Is there a shortcut for folding code? Please share?

Post by DrReflex » 02 Feb 2023, 20:04

<Ctrl><Shift><LClick> on Fold column

cgx5871
Posts: 315
Joined: 26 Jul 2018, 14:02

Re: Is there a shortcut for folding code? Please share?

Post by cgx5871 » 04 Feb 2023, 03:09

User.propertes

Code: Select all

command.name.5.*=自定义折叠
command.mode.5.*=subsystem:lua,savebefore:no,groupundo
command.shortcut.5.*=Alt+z
command.5.*=CommentFold
userluascrpt.lua

Code: Select all

--~========================================================================
--Scite中, 用鼠标框选区域, 代码折叠.
--首尾添加注释代码;首:{  •••➤  尾:  ;}
function CommentFold()
    local p1=editor.SelectionStart
    local p2=editor.SelectionEnd
    local L1=editor:LineFromPosition(p1)
    local L2=editor:LineFromPosition(p2)
--~     符号 字节长=3
	local s = "\t;{ -----❄❄"
	local m = #s
    if L1~=L2 then
        local Asc = {[9]=1,[13]=1}
--~         local Asc = {[0]=1,[9]=1,[10]=1,[13]=1,[32]=1,[34]=1,[39]=1,[44]=1}
        --~停止字符集合: 9=Tab,13=Enter,  --[0]=1,[10]=1,[13]=1,[32]=1,[34]=1,[39]=1,[44]=1
        while Asc[editor.CharAt[p1]] == nil do
            p1 = p1 + 1
        end
		--~防止框选到最后一行时, 计算出错.
         while Asc[editor.CharAt[p2]] == nil and p2<editor.LineEndPosition[editor.LineCount ] do
            p2 = p2 + 1
        end
--~ 	print(p2)
        editor:InsertText(p1,s)
        editor:InsertText(p2+m,"\t;}")
		editor:GotoPos(p1+m-3)
		--~ 同时发送折叠命令
        editor:ToggleFold(L1)
    end
end

Post Reply

Return to “SciTE4AutoHotkey”