Page 1 of 1
Is there a shortcut for folding code? Please share?
Posted: 01 Jul 2022, 09:03
by automater
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
Re: Is there a shortcut for folding code? Please share?
Posted: 02 Feb 2023, 20:04
by DrReflex
<Ctrl><Shift><LClick> on Fold column
Re: Is there a shortcut for folding code? Please share?
Posted: 04 Feb 2023, 03:09
by cgx5871
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