User Activity

  • Posted a comment on discussion Help on Notepad++ Python Script

    To be honest, I don't think that reading a file once and using its content in a list is slower than opening the substitution file always, if you tested this with more than one file. But a general question, all that you want to do is to find some text and replace it, correct? If so, why not using ... notepad.open(fileName.encode('utf-8')) for s in sl editor.replace(s[0],s[1]) notepad.save() notepad.close() There is no need for doing findText, saving position ... first. Another hint, you can define...

  • Posted a comment on discussion Help on Notepad++ Python Script

    Well than you need to find out what encoding has been used, which, btw, cannot be done in a 100% save manner. Npp uses chardet to identify the encoding, chardet is also available as python module. If only utf8 with or without BOM is used, than you can use codecs module and do something like import codecs with codecs.open(u'FILENAME') as f: for l in f: if len(l) > 1: s = l.split() if s[0].startswith(codecs.BOM_UTF8): _s = s[0][len(codecs.BOM_UTF8):].decode('utf-8') else: _s = s[0] ... Cheers Clau...

  • Posted a comment on discussion Help on Notepad++ Python Script

    Why not converting your file to UTF-8 (without the BOM). Cheers Claudia

  • Posted a comment on discussion Help on Notepad++ Python Script

    yep, another possible way :-D

  • Posted a comment on discussion Help on Notepad++ Python Script

    get/setProperty is normally used to get/set lexer specific properties like allow folding etc... Recently npp added fold.quotes.python property to allow doc comments to be folded, this wasn't possible before unless you would have set it with python script for example. But this gaves also the possibility to add any info/value you want to a document and it is only avaliable through the lifetime of that document. Once document closes everything is gone and you don't have to take care of it.(well, in...

  • Posted a comment on discussion Help on Notepad++ Python Script

    Correct, setProperty is per document as globals() returns the current global scope which is used by every script you run as long as your in the same namespace. Scott, I think moon refers to my example where I used 42 in setProperty call.

  • Posted a comment on discussion Help on Notepad++ Python Script

    You could use the global namespace or the editor.setProperty function to save data need on subsequent calls global namespace: counter = globals().get('counter', 1) t = globals().get('t', 'set') print '{} {}'.format(t, counter) counter += 1 or editor.setProperty('MY_VAR','42') print editor.getProperty('MY_VAR')

  • Posted a comment on discussion Help on Notepad++ Python Script

    @Moon, After rereading my post I guess I was a bit unclear - yes, getTag(number) rerturns a submatch but there is no function to retrieve how many submatches were catched. Sorry for confusion.

View All

Personal Data

Username:
myxin2010
Joined:
2010-04-12 10:24:58

Projects

  • No projects to display.

Personal Tools