【发布时间】:2016-02-09 11:21:46
【问题描述】:
我正在尝试为 notepad++ 构建一个 pythonscript 宏,它可以自动突出显示几个单词的搜索对话框。
很遗憾,我找不到“突出显示”的必要功能。脚本应该和我使用 Ctrl+F 对话框一样,选中“Wrap around”并按“Mark All”。
这个类似,虽然它不使用 pythonscript: notepad++ mark style with macro
有了可用的文档,我可以做到以下几点:
# Function for marking a line if a certain pattern was found
def bookmarks(lineText, lineNumber, totalLines):
patterns = ['word1','word2']
for p in patterns:
if lineText.find(p) > -1:
editor.markerAdd(lineNumber, 24)
return 1
# mark interesting lines:
editor.markerDeleteAll(24);
editor.forEachLine(bookmarks);
这将为当前文件中包含“word1”或“word2”的所有行创建书签。但是,我想像“标记所有”一样突出显示出现的情况,并且我想在所有打开的文件中这样做。
也许我缺少文档资源,或者是因为我不太了解 python。至少我找不到合适的功能来突出显示匹配项。我确实使用了谷歌,并查阅了以下文档页面。 此外,任何有关更有价值文档的提示都非常感谢!
http://npppythonscript.sourceforge.net/docs/latest/index.html http://sourceforge.net/p/npppythonscript/wiki/Home/
【问题讨论】: