Skip to content

Instantly share code, notes, and snippets.

@CennoxX
Forked from patstew/startup.py
Last active August 22, 2025 10:03
Show Gist options
  • Save CennoxX/f3486e8d8c9a7137ccf18d929ce3697a to your computer and use it in GitHub Desktop.
Save CennoxX/f3486e8d8c9a7137ccf18d929ce3697a to your computer and use it in GitHub Desktop.
notepad++ startup.lua
local function indent_auto_detect()
for i = 0, editor.LineCount - 1 do
local pos = editor:PositionFromLine(i)
local indent = editor.LineIndentPosition[i] - pos
if indent > 0 then
if string.byte("\t") == editor.CharAt[pos] then
print("Indentation: Tabs")
editor.UseTabs = true
return
elseif indent == 2 or indent == 3 or indent == 4 or indent == 8 then
print("Indentation: " .. indent .. " spaces")
editor.UseTabs = false
editor.Indent = indent
return
end
end
end
end
npp.AddEventHandler({"OnSwitchFile", "OnReady"}, indent_auto_detect)
print("Automatic indentation detection started")
indent_auto_detect()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment