📄 trimspaces.em
字号:
// This function trims white spaces from the ends of the selected lines
// in the current file buffer. If the selection is empty, it does the
// whole file.
macro TrimSpaces()
{
hbuf = GetCurrentBuf()
hwnd = GetCurrentWnd()
sel = GetWndSel(hwnd)
if (sel.fExtended)
{
// use selected lines
ln = sel.lnFirst
lnLim = sel.lnLast + 1
}
else
{
// process the whole file buffer
ln = 0
lnLim = GetBufLineCount(hbuf)
}
// do for each line....
while (ln < lnLim)
{
s = GetBufLine(hbuf, ln)
sTrim = StrTrimSpaces(s)
if (s != sTrim)
PutBufLine(hbuf, ln, sTrim)
ln = ln + 1
}
}
// Helper function: trims white space from the string s.
// Returns resulting string.
macro StrTrimSpaces(s)
{
cch = strlen(s)
ich = cch - 1
chTab = CharFromAscii(9)
while (ich >= 0)
{
ch = s[ich]
if (ch != " " && ch != chTab)
return strmid(s, 0, ich + 1)
ich = ich - 1
}
return ""
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -