Skip to content

Instantly share code, notes, and snippets.

@dogancelik
Forked from patstew/startup.py
Created February 9, 2021 22:58
Show Gist options
  • Save dogancelik/6f78d9af88698583a8b595786c153dac to your computer and use it in GitHub Desktop.
Save dogancelik/6f78d9af88698583a8b595786c153dac to your computer and use it in GitHub Desktop.
notepad++ startup.py
from Npp import *
def indent_auto_detect(arg):
for i in range(editor.getLineCount()):
pos = editor.positionFromLine(i)
indent = editor.getLineIndentPosition(i)-pos
if indent > 0:
if ord('\t') == editor.getCharAt(pos):
console.write("Indentation: Tabs\n")
editor.setUseTabs(True)
return
elif indent in [2, 3, 4, 8]:
console.write("Indentation: %d spaces\n" % indent)
editor.setUseTabs(False)
editor.setIndent(indent)
return
notepad.clearCallbacks([NOTIFICATION.BUFFERACTIVATED, NOTIFICATION.READY])
notepad.callback(indent_auto_detect, [NOTIFICATION.BUFFERACTIVATED])
notepad.callback(indent_auto_detect, [NOTIFICATION.READY])
console.write("Automatic indentation detection started\n")
indent_auto_detect(None)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment