Skip to content

Instantly share code, notes, and snippets.

@patstew
Created March 8, 2017 13:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save patstew/8dc8a4c0b816e2f33204e3e15cd5497e to your computer and use it in GitHub Desktop.
Save patstew/8dc8a4c0b816e2f33204e3e15cd5497e 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