forked from bruderstein/PythonScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.shtml
More file actions
92 lines (86 loc) · 6.19 KB
/
index.shtml
File metadata and controls
92 lines (86 loc) · 6.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<!--#include virtual="header.inc" -->
<h1>Python Script for Notepad++ </h1>
<h4>The scripting plugin</h4>
<iframe src="http://www.facebook.com/widgets/like.php?href=http://npppythonscript.sourceforge.net/"
scrolling="no" frameborder="0"
style="border:none; width:450px; height:80px"></iframe>
<ul>
<li>Full programmatic access to Notepad++ features and menus</li>
<li>Full programmatic access to all of Scintilla features</li>
<li>Call other plugin menu items</li>
<li>Assign menu items, shortcuts and toolbar icons to scripts</li>
<li>Process Notepad++ and Scintilla events, direct from a Python script</li>
<li>Python console built-in</li>
<li>Full regular expression support for search and replace - script Python regular expression replaces</li>
<li>Start external programs and pipe the output direct to a Notepad++ document, or filter it, or simply to the console window</li>
<li>Full <a href="docs/latest/">documentation</a> for all the objects and methods</li>
</ul>
<br/>
<br/><br/>
<i>Here's a sample...</i>
<br/><br/>
<span class="code">
<span class="sc1"># Simple search / replace</span>
<br/><span class="sc11">editor</span><span class="sc10">.</span><span class="sc11">replace</span><span class="sc10">(</span><span class="sc3">"old"</span><span class="sc10">,</span><span class="sc0"> </span><span class="sc3">"new"</span><span class="sc10">)</span>
<br/>
<br/><span class="sc1"># Regular expressions search and replace</span>
<br/><span class="sc11">editor</span><span class="sc10">.</span><span class="sc11">rereplace</span><span class="sc10">(</span><span class="sc3">r"^([A-Z]{3,5})--\1"</span><span class="sc10">,</span><span class="sc0"> </span><span class="sc3">r"CODE: \1"</span><span class="sc10">)</span>
<br/>
<br/><span class="sc1"># Call a Scintilla function</span>
<br/><span class="sc11">editor</span><span class="sc10">.</span><span class="sc11">appendText</span><span class="sc10">(</span><span class="sc3">"Changed codes\r\n"</span><span class="sc10">);</span>
<br/>
<br/><span class="sc1"># Save the file</span>
<br/><span class="sc11">newFilename</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc11">notepad</span><span class="sc10">.</span><span class="sc11">getCurrentFilename</span><span class="sc10">()</span><span class="sc0"> </span><span class="sc10">+</span><span class="sc0"> </span><span class="sc3">".changed"</span>
<br/><span class="sc11">notepad</span><span class="sc10">.</span><span class="sc11">saveAs</span><span class="sc10">(</span><span class="sc11">newFilename</span><span class="sc10">);</span>
<br/>
<br/><span class="sc1"># Write to the console window</span>
<br/><span class="sc11">console</span><span class="sc10">.</span><span class="sc11">write</span><span class="sc10">(</span><span class="sc3">"Saved as %s\n"</span><span class="sc0"> </span><span class="sc10">%</span><span class="sc0"> </span><span class="sc11">newFilename</span><span class="sc10">)</span>
<br/>
<br/><span class="sc1"># Create a new document</span>
<br/><span class="sc11">notepad</span><span class="sc10">.</span><span class="sc14">new</span><span class="sc10">()</span>
<br/>
<br/><span class="sc1"># Run a command on the file, and output results to the new file</span>
<br/><span class="sc11">console</span><span class="sc10">.</span><span class="sc11">run</span><span class="sc10">(</span><span class="sc4">'compiler.exe "%s"'</span><span class="sc0"> </span><span class="sc10">%</span><span class="sc0"> </span><span class="sc11">newFilename</span><span class="sc10">,</span><span class="sc0"> </span><span class="sc11">editor</span><span class="sc10">)</span>
</span>
<br/>
<br/>
<br/>
So, why <i>another</i> scripting plugin...
<br/>
<ol>
<li>It uses python.</li>
<li>See reason 1.</li>
<li>It's lightweight, a 2MB download, it doesn't start up until it's needed (which normally takes about 0.2 seconds), and it doesn't start anything extra (like webservers... :)</li>
<li>Full access to all of Scintilla features, and access to respond to events</li>
<li>Did I mention it uses Python?</li>
<li>Interoperable from other plugins - call Python function from your own plugin</li>
<li>Very quick and easy to create a new script, and add it to the menu</li>
<li>Python is so easy to learn, you'll be writing scripts that save you hours in no time</li>
</ol>
<br/>
<br/>
Python's a great choice for a scripting language - it's very easy to learn, very easy to read and write,
and <i>can</i> be object oriented (in fact, it has an excellent model), but doesn't need to be. A script that
looks like
<br/>
<pre>
notepad.open("c:\autoexec.bat")
</pre>
is just as valid as a full blown object oriented magic system that turns Notepad++ into a coffee-making spreadsheet application.
<br/>
<hr/>
<h2>Donations</h2>
<br/>
So, I do this for fun - Notepad++ is a great editor, but I missed not being able to script things properly, so I put this together.
<br/>I'm not after donations towards my coffee, but, my sister's a doctor, and is trying to <b>build a hospital in Ghana</b>. She's already raised enough
to send a load of equipment over to an existing hospital, which makes a terrific difference in a place where equipment is scarce.
She needs <b>100,000GBP</b> to build the hospital and fill it with decent equipment. It sounds like a lot, but it isn't really. If one in fifty
of the people that downloaded my last plugin (Plugin Manager) gave 1 pound each, that would be enough.
<br/>
It's not compulsory by any means (and specifically, for UK tax reasons, is not by way of payment for goods, you get the plugins for free),
but, it would bring some meaning to the months of work I put into this, and you know that you've made a difference
- and it's got to be a better cause than handing over hard earned cash to profit some software firm.
<br/><br/>
Visit the <a href="http://www.testashipti.comlu.com/1_12_Current-projects.html">charity</a>, or go straight to the <a href="https://www.charitychoice.co.uk/donation.asp?ref=154853">online donation page</a>
(whatever amount you can, every penny counts).
<!--#include virtual="footer.inc" -->