Created
March 8, 2017 13:03
-
-
Save patstew/8dc8a4c0b816e2f33204e3e15cd5497e to your computer and use it in GitHub Desktop.
notepad++ startup.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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