- download Python Script from http://npppythonscript.sourceforge.net/
- download nodejs from http://nodejs.org/
- install LESS compiler ( http://lesscss.org/usage/ )
- copy & paste code below into your startup.py
- change your Python Script initialisation to ATSTARTUP
- restart Notepad++ or run startup.py
- DONE. ヽ(´ー`)ノ
# Just in case, we'll clear all the existing callbacks
notepad.clearCallbacks([NOTIFICATION.FILEOPENED])
notepad.clearCallbacks([NOTIFICATION.FILESAVED])
class LessFileHelper:
# Define the function to call just after the file is opened
def fileOpened(self, args):
bufferID = args['bufferID']
filename = notepad.getBufferFilename(bufferID)
if filename[-5:] == '.less':
#console.write(filename)
notepad.activateBufferID(bufferID)
notepad.setLangType(LANGTYPE.CSS)
editor.setProperty('lexer.css.less.language', '1')
# Define the function to call just after the file is saved
def fileSaved(self, args):
bufferID = args['bufferID']
filename = notepad.getBufferFilename(bufferID)
if filename[-5:] == '.less':
#console.write(filename)
cmd = r'cmd /c %APPDATA%\npm\lessc.cmd -s "{0}" > "{1}.css"'.format(filename, filename[:-5])
console.write(cmd + "\n")
console.run(cmd)
lessFileHelper = LessFileHelper()
# ... and register the callback
notepad.callback(lessFileHelper.fileOpened, [NOTIFICATION.FILEOPENED])
notepad.callback(lessFileHelper.fileSaved, [NOTIFICATION.FILESAVED])