I've just started working with Notepad++ Plugins, and my first will a simple scripting system to process text. Why simple? Because I don't have much experience with writing parsers, so this is the best I can come up with. I'm calling it SimpleScript in order to distinguish it from the currently nonexistent advanced scripting system that I'm still hoping that someone will design later.
I originally designed it to help me convert plain text e-books to HTML without having to repeat the same sequence of steps over and over again (I think I've replaced "\r\n" with "</p>\r\n<p>" on a couple of hundred documents). I wrote a couple of standalone programs that would help me do this automatically, but ever since I started using Notepad++ I've wished I could have some kind of generic scripting tool built in that I could use for this and other purposes, to make Notepad++ my all-in-one toolbox. The old adage "if you want something done, you gotta do it yourself," applies, so that's why I'm designing this. You'll notice that some of the functions lend themselves well to formatting e-books.
This system should be generic enough that it can be used not just for converting e-books, but for a variety of other purposes. It will also be very simple to use. Like I said earlier, I lack the skill to write an advanced parser, but I think this will be useful anyway.
The basic idea is this:
You select "Simple Script" from the menu, and it opens a window where you can type in a script. A script is just a sequence of functions with parameters, one function per line. No branching, no looping, no nested functions, no variables. When you execute the script, it will grab the currently selected text in the document (or the entire document if no text is selected), run the functions one at a time on it, then export the end result back out to replace either the selected text or the entire document. Some of the functions operate on specific lines, some of them operate on every line in the text, and some of them operate on the relationships between the lines.
I plan to include the ability to save the scripts out to files for later retrieval, and to internally maintain a list of your favorite scripts, perhaps in an .ini file, so that you can just choose them off a list instead of having to search for the file. And of course, copy and paste to and from the script window.
I'm going to have some time over the weekend to work on it, and I hope to have the basic framework done in that time. Then it's just a matter of writing the functions themselves.
So far I have fifteen functions planned:
add(text): Adds a line of text to the end of the document.
beginline(text): Appends text to the beginning of every line.
delete(linestart,lineend): Deletes all lines between linestart and lineend.
endline(text): Appends text to the end of every line.
insert(text,linenumber): Inserts a line of text at the specified line number.
replace(oldtext,newtext): Replaces all instances of oldtext with newtext.
replacecase(oldtext,newtext): Replaces all instances of oldtext with newtext, but with case-sensitive matching.
replaceline(text,linenumber): Replaces a line of text at the specified line number.
setblanks(minblank,maxblank,threshhold): Changes the number of blank lines between lines.
sort(): Sorts all lines in the document.
trim(badchars): Strips all badchars from the beginning and end of every line.
trimleft(badchars): Strips all badchars from the beginning of every line.
trimright(badchars): Strips all badchars from the end of every line.
unwrap(blanklinecount,spacecount,tabcount): Strips hard returns based upon the parameters.
wrap(columncount,splitwords): Adds hard returns to force columns to a certain width.
And before you ask, yes, I plan to include \r, \n, and \t in the replace and replacecase functions. No regular expressions though, sorry. At least not unless someone is willing to do the programming for me (I should warn you, I use Delphi, not C).
I have a more detailed writeup of the above functions that will be included in the readme file, but I haven't posted it here, so you may be thinking "what the heck?" on some of them. If you want more clarification, just let me know.
Right now, I'd like to know what other functions people might like. Any ideas?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I figured I'd better give you all an update so you don't think this plugin is DOA.
Version 0.9 will probably be uploaded this weekend some time. I still haven't finished all the testing yet; I got lazy over Thanksgiving vacation. So there might be a few bugs still.
In the mean time, I've played around a little with parsing nested functions, and I think I might be able to come up with a more advanced scripting system for version 2.0, but that's probably a few months down the line. Here's a tentative plan:
Version 0.9
First publicly released version (beta).
Version 1.0
Testing and bug fixing.
Version 1.1
Adding new functions.
Version 1.2
Storing parameters.
Working on a subset of lines. startsubset(startline,endline), endsubset() functions
Add interface to edit SimpleScript.ini
Version 1.3
Other ideas I may get between now and then.
Version 2.0
More robust scripting system.
Nested functions, returning values from functions, branching, looping, variables.
*This may break backward compatibility. I'll probably allow you to choose between basic and advanced scripting.
Possibly provide a custom user-defined language file so you can use Notepad++ to design scripts.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
lowercase(): Converts the entire document to lowercase letters.
reverselines(): Reverses the order of all the lines.
setlineformat(style)*: 1=Windows, 2=Unix, 3=Mac
sortcase(): like sort, but case-sensitive.
uppercase(): Converts the entire document to uppercase letters.
upperfirst(): Capitalizes the first letter of every word, lowercases all other letters.
*I included this as a workaround because some of the functions use Delphi's TStringList type, which means that any calls to those functions will convert the text to Windows Format. You can run this function at the end of a script to convert it back to your favorite style.
And here are some that I haven't worked on yet, but should make it into the final product. These are probably useful for converting between fixed-length and delimited text files.
splitlines(delimiter): splits each line into multiple lines based on the chosen delimiter
unwrapdelim(blanklinecount,spacecount,tabcount,delimiter): like unwrap, but converts line breaks to delimiters.
stripleft(text): For each line, if the beginning of the line matches the text, strip off that text.
stripright(text): For each line, if the end of the line matches the text, strip off that text.
cutleft(count): Removes count characters from the beginning of each line.
cutright(count): Removes count characters from the end of each line.
shortenleft(length): Removes characters from the beginning of each line if the line is too long
shortenright(length): Removes characters from the end of each line if the line is too long
padleft(padchar,length): Pads the beginning of each line with padchar to extend the length where necessary
padright(padchar,length): Pads the end of each line with padchar to extend the length where necessary
sizeleft(padchar,length): Pads or cuts the beginning of each line to make it the exact length
sizeright(padchar,length): Pads or cuts the end of each line to make it the exact length
It's actually going faster than I had anticipated; I might even have a working plugin some time this weekend.
Any other ideas for functions you would like to see?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I might play around with those a little in my programming for myself, but unfortunately, since I'm using a template that Zobo sent me that's licensed under the GPL, I can't release my plugin unless it only uses code that's under a GPL-compatible license. Neither of the ones you linked to fit the criteria.
Thanks anyway, though. I appreciate the effort.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
About scripting functions. Please look at the AWK (or GAWK) - it has VERY usefull functions and functionality such as gsub(), index(), split(), sprintf(), substr(), $0 ($1, $2, ...) and so on. It would be great if you implement such features in your plugin.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I looked through the GAWK online manual, and there are some good ideas there. Unfortunately, most of the interesting stuff there really only applies to a more advanced control structure with nested functions, etc.
If I'm feeling particularly ambitious a little later I might create a more advanced parser, and then I'll revisit it. That's probably at least several months away, if ever. Right now I want to concentrate on getting this linear scripting system up and running.
If there are any functions in particular that you would like to see, let me know. Just keep in mind that I can't implement anything that returns a value, only things that alter text.
Thanks for your help though.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm just about finished with the Simple Script plugin, although I'm still open for suggestions on functions that people would like to see.
I have one more question for everyone. I've created a menu option for "Repeat Last Script" which is convenient for running the same script on multiple files. This menu option is just begging for a hot key. I've decided on ALT-SHIFT-R, the only combination of CTRL, ALT, and SHIFT with either R (for Repeat) or S (for Script) that isn't already being used by default. Of course, I haven't downloaded every plugin, so I don't know if it conflicts with anything that others are using.
Any objections to me using ALT-SHIFT-R for "Repeat Last Script"?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Never mind. I added the ability to map the shortcut key in the .ini file. It will be ALT-SHIFT-R by default, but you can change it if you would prefer a different key combination. You can also map Run Script, though it will have no default shortcut.
I would have liked to use the built-in Notepad++ Shortcuts Mapper in order to keep the shortcuts centralized, but I'll have to hold off on that until I can do a little more testing to figure out if it would even work.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
How about clipboard actions like:
CopyToClipBoardIfContain(text): copy the whole line is it contain a text
CopyToClipBoardIfNotContain(text) : copy if don't contain text
CutToClipBoardIfContain(text): Cut the whole line is it contain a text
CutToClipBoardIfNotContain(text) : Cut if don't contain text
Also as you have:
setblanks(minblank,maxblank,threshhold): Changes the number of blank lines between lines.
It might be usfule to add
setSpaces(minSpace,maxSpace,threshhold): Changes the number of Spaces.
so that if you have
X = 7
Y = 6
Z = 9
you can change it to
X = 7
Y = 6
Z = 9
regards
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It seems that the editor removes the extra spaces, what i ment (lines represent spaces):
X = _________________________7
Y = ______6
Z = _____________________________________9
you can change it to
X = 7
Y = 6
Z = 9
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Your idea about using the clipboard is interesting. I'm wondering what kinds of applications this could have? If you can give me an example of how you might use this, I think I can probably implement it.
On your SetSpaces idea, I just want to confirm that you're thinking the same thing I'm thinking. The SetBlanks function sets the number of blank lines between paragraphs to Minblank, unless it already has at least a number of blank lines indicated by Threshhold, in which case it will set the number of blank lines at that position to Maxblank.
For example, if you have a double-spaced document that you want to convert to a single-spaced document, you would use setblanks(0,1,2). This means that all of those single blank lines between rows of text would be converted to 0 blank lines (Minblank=1). In cases where there are 2 or more blank lines (Threshold=2), it would assume this is a major break, and set it to 1 blank line between rows of text (Maxblank=1).
Is this the sort of thing you had in mind for SetSpaces?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes, This would be a good implementation, so this would be what i need in setSpaces, and thinking about it again may be we can generalize the functionality to setChars(char,Min,Max,threshold), so for an example if a java programmer wants to be sure he/she don't have 2 or more semi commas, for example:
if (appData == null){
return false;;
}
you can say setChars(';',0,1,2)
so for simplicity you might have 3 function: setBlanks,setSpaces and setChars you can use setChars to do the functionality of the first 2, but they are there if you don't know how to do that
Regarding your question about where to use copytoClipBoard, say you have an SQL file which contain many amny active and remarked lines, something like:
insert into ROLE(ROLE_ID,NAME) values(0001,'Administrator');
--insert into ROLE(ROLE_ID,NAME) values(0002,'Power User');
--insert into ROLE(ROLE_ID,NAME) values(0003,'Manager');
insert into ROLE(ROLE_ID,NAME) values(0004,'Commercial User');
and you want to copy only the active lines to run them, what i do know is
* copy '--' to clipboard
* hide lines using tidyfx vis
* select all
* copy visible selection (using Tidy also)
* paste in new text documnet
* copy all the text again
* replace text in the old document
all those steps can be simply done by selecting all lines and choosing:
cutToClipBordWhenContain('--')
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I see. In your CopyIfContain function, you were talking about checking on a per-line basis. That actually makes quite a bit of sense. I was under the mistaken impression that you meant that it only checked once for the entire selected text.
I may not get it in for the 1.0 version, but it's definitely on the list for the next version. When you first mentioned the clipboard, that started me thinking about what other clipboard functions I could implement, so I've got about a dozen of them planned now.
On the SetChars, your description also makes sense. Basically it would force all sequences of a particular character to be one of exactly two potential lengths. I like it. Again, probably not in the 1.0 version, but I'll keep it in mind.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
> I added the ability to map the shortcut key in the .ini file.
Notepad++ supports altering these shortcuts natively, as long as you support the Shortcut object for the menu item (FuncItem). You can even set all members of the Shortcut object to NULL and by default there will be no assignment, but the plugin will be listed in the shortcut mapper (it's hacky but I found it to work without any problems). Have you seens Jenz' PluginTemplate? It should have a proper example.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I just looked in the shortcut mapper, and with my plugin installed, "Repeat Last Script" is already there, so apparently I set it up right without even realizing it. I just have to tweak "Run Script" a little and it should work too.
It seems like every day I discover some new feature about Notepad++.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Rather than try to put linestart and lineend in so many commands, why not put in a select line(s) command that all subsequent commands will work on. You don't need a deselect if you just make "0", the deselect. The commands would look as follows:
Then, all subsequent commands, including sort and uppercase and so on would act only on the selected lines. It would also free up the syntax of the other commands so that you would need fewer commands.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
That's an intriguing idea. Right now I have no place to store any settings between lines of the script, so it probably won't go into the 1.0 version because I would have to rewrite a significant portion of the plugin to get it to work. Right now I'm just waiting to hear back from Jens to see if I can get this listed on the Notepad++ Plugins Project, so there's no time to do any major changes. Right now I'm just testing, not implementing any new features.
Once we start down that road, it opens up all kinds of interesting possibilities. A lot of the script functions (and now I've got almost 50 completed with a couple dozen more planned) use similar parameters. It would be nice to store these parameters and not have to set them in each function call. Things like:
Line start
Line end
Case-sensitive matching and sorting (on or off)
Pad character
Delimiter
Line format (Windows, Unix, Mac)
It also sounds like your idea would be better implemented by actually storing a subset of lines to work on which would then be passed back into the working text, which would then be passed back into the open Notepad++ document.
It of course brings up some questions as well. Nothing that can't be resolved, but I'll have to put some thought into them. For example:
How should you set up the parameters?
How persistent should they be? (Reset between scripts, remain until you close Notepad++, or even remember them from previous sessions)
How should the script handle defaults? (i.e. if the parameters haven't been set already)
How do you tell a function whether to use the pre-defined parameters as opposed to setting them in the function call?
How do you tell a function to work only on the selected subset and not the whole text?
Since this would allow me to reduce the number of functions, how important is backward-compatibility? (e.g. Should I leave in the sortcase function?)
Those are just the ones I thought up off the top of my head. I'll have to think about this some more to see if I can work it into a later version.
Thanks for the idea!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
How about replace_characters(begin, end) on a line, all through the file, though not necessarily unform in characters but in position. Take a look at Better File Rename as it has many options that would be nice in notepad++
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Regarding your replace_characters, are you talking about overwriting portions of every line with certain text? I'm planning a replaceinline(text,position) function that does exactly that. That also suggests the idea of an insertinline function as well.
As far as looking at Better File Rename, I'm not familiar with that particular program, but I'm assuming it's some kind of file renaming program. I've downloaded some freeware programs like that, and I think you're on to something there. There's an obvious similarity between renaming files and renaming a series of lines, so I'll have to look into them and see what kinds of things would be useful.
Thanks, and keep the ideas coming.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Version 0.9 is finished. I just sent the files to Jens to add to the Notepad++ Plugins project, so look for it there soon. I'll put a link in this thread as soon as I see it there.
I'm calling it version 0.9 not because it's not done, but because I haven't finished rigorously testing each function. There are no known bugs at the moment, so once it's uploaded, feel free to start using it.
I haven't added all of the functions I have in mind, but from now until the 1.0 version, I'm not working on any new features, just testing and bug fixing. But I'm still open to ideas for version 1.1.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've just started working with Notepad++ Plugins, and my first will a simple scripting system to process text. Why simple? Because I don't have much experience with writing parsers, so this is the best I can come up with. I'm calling it SimpleScript in order to distinguish it from the currently nonexistent advanced scripting system that I'm still hoping that someone will design later.
I originally designed it to help me convert plain text e-books to HTML without having to repeat the same sequence of steps over and over again (I think I've replaced "\r\n" with "</p>\r\n<p>" on a couple of hundred documents). I wrote a couple of standalone programs that would help me do this automatically, but ever since I started using Notepad++ I've wished I could have some kind of generic scripting tool built in that I could use for this and other purposes, to make Notepad++ my all-in-one toolbox. The old adage "if you want something done, you gotta do it yourself," applies, so that's why I'm designing this. You'll notice that some of the functions lend themselves well to formatting e-books.
This system should be generic enough that it can be used not just for converting e-books, but for a variety of other purposes. It will also be very simple to use. Like I said earlier, I lack the skill to write an advanced parser, but I think this will be useful anyway.
The basic idea is this:
You select "Simple Script" from the menu, and it opens a window where you can type in a script. A script is just a sequence of functions with parameters, one function per line. No branching, no looping, no nested functions, no variables. When you execute the script, it will grab the currently selected text in the document (or the entire document if no text is selected), run the functions one at a time on it, then export the end result back out to replace either the selected text or the entire document. Some of the functions operate on specific lines, some of them operate on every line in the text, and some of them operate on the relationships between the lines.
I plan to include the ability to save the scripts out to files for later retrieval, and to internally maintain a list of your favorite scripts, perhaps in an .ini file, so that you can just choose them off a list instead of having to search for the file. And of course, copy and paste to and from the script window.
I'm going to have some time over the weekend to work on it, and I hope to have the basic framework done in that time. Then it's just a matter of writing the functions themselves.
So far I have fifteen functions planned:
add(text): Adds a line of text to the end of the document.
beginline(text): Appends text to the beginning of every line.
delete(linestart,lineend): Deletes all lines between linestart and lineend.
endline(text): Appends text to the end of every line.
insert(text,linenumber): Inserts a line of text at the specified line number.
replace(oldtext,newtext): Replaces all instances of oldtext with newtext.
replacecase(oldtext,newtext): Replaces all instances of oldtext with newtext, but with case-sensitive matching.
replaceline(text,linenumber): Replaces a line of text at the specified line number.
setblanks(minblank,maxblank,threshhold): Changes the number of blank lines between lines.
sort(): Sorts all lines in the document.
trim(badchars): Strips all badchars from the beginning and end of every line.
trimleft(badchars): Strips all badchars from the beginning of every line.
trimright(badchars): Strips all badchars from the end of every line.
unwrap(blanklinecount,spacecount,tabcount): Strips hard returns based upon the parameters.
wrap(columncount,splitwords): Adds hard returns to force columns to a certain width.
And before you ask, yes, I plan to include \r, \n, and \t in the replace and replacecase functions. No regular expressions though, sorry. At least not unless someone is willing to do the programming for me (I should warn you, I use Delphi, not C).
I have a more detailed writeup of the above functions that will be included in the readme file, but I haven't posted it here, so you may be thinking "what the heck?" on some of them. If you want more clarification, just let me know.
Right now, I'd like to know what other functions people might like. Any ideas?
I figured I'd better give you all an update so you don't think this plugin is DOA.
Version 0.9 will probably be uploaded this weekend some time. I still haven't finished all the testing yet; I got lazy over Thanksgiving vacation. So there might be a few bugs still.
In the mean time, I've played around a little with parsing nested functions, and I think I might be able to come up with a more advanced scripting system for version 2.0, but that's probably a few months down the line. Here's a tentative plan:
Version 0.9
First publicly released version (beta).
Version 1.0
Testing and bug fixing.
Version 1.1
Adding new functions.
Version 1.2
Storing parameters.
Working on a subset of lines. startsubset(startline,endline), endsubset() functions
Add interface to edit SimpleScript.ini
Version 1.3
Other ideas I may get between now and then.
Version 2.0
More robust scripting system.
Nested functions, returning values from functions, branching, looping, variables.
*This may break backward compatibility. I'll probably allow you to choose between basic and advanced scripting.
Possibly provide a custom user-defined language file so you can use Notepad++ to design scripts.
I've got a few more functions at least started:
lowercase(): Converts the entire document to lowercase letters.
reverselines(): Reverses the order of all the lines.
setlineformat(style)*: 1=Windows, 2=Unix, 3=Mac
sortcase(): like sort, but case-sensitive.
uppercase(): Converts the entire document to uppercase letters.
upperfirst(): Capitalizes the first letter of every word, lowercases all other letters.
*I included this as a workaround because some of the functions use Delphi's TStringList type, which means that any calls to those functions will convert the text to Windows Format. You can run this function at the end of a script to convert it back to your favorite style.
And here are some that I haven't worked on yet, but should make it into the final product. These are probably useful for converting between fixed-length and delimited text files.
splitlines(delimiter): splits each line into multiple lines based on the chosen delimiter
unwrapdelim(blanklinecount,spacecount,tabcount,delimiter): like unwrap, but converts line breaks to delimiters.
stripleft(text): For each line, if the beginning of the line matches the text, strip off that text.
stripright(text): For each line, if the end of the line matches the text, strip off that text.
cutleft(count): Removes count characters from the beginning of each line.
cutright(count): Removes count characters from the end of each line.
shortenleft(length): Removes characters from the beginning of each line if the line is too long
shortenright(length): Removes characters from the end of each line if the line is too long
padleft(padchar,length): Pads the beginning of each line with padchar to extend the length where necessary
padright(padchar,length): Pads the end of each line with padchar to extend the length where necessary
sizeleft(padchar,length): Pads or cuts the beginning of each line to make it the exact length
sizeright(padchar,length): Pads or cuts the end of each line to make it the exact length
It's actually going faster than I had anticipated; I might even have a working plugin some time this weekend.
Any other ideas for functions you would like to see?
on regular expression in delphi check:
http://www.regexpstudio.com/TRegExpr/TRegExpr.html
and
http://www.yunqa.de/delphi/doku.php/products/regex/index
Thanks for the links.
I might play around with those a little in my programming for myself, but unfortunately, since I'm using a template that Zobo sent me that's licensed under the GPL, I can't release my plugin unless it only uses code that's under a GPL-compatible license. Neither of the ones you linked to fit the criteria.
Thanks anyway, though. I appreciate the effort.
About scripting functions. Please look at the AWK (or GAWK) - it has VERY usefull functions and functionality such as gsub(), index(), split(), sprintf(), substr(), $0 ($1, $2, ...) and so on. It would be great if you implement such features in your plugin.
I looked through the GAWK online manual, and there are some good ideas there. Unfortunately, most of the interesting stuff there really only applies to a more advanced control structure with nested functions, etc.
If I'm feeling particularly ambitious a little later I might create a more advanced parser, and then I'll revisit it. That's probably at least several months away, if ever. Right now I want to concentrate on getting this linear scripting system up and running.
If there are any functions in particular that you would like to see, let me know. Just keep in mind that I can't implement anything that returns a value, only things that alter text.
Thanks for your help though.
I'm just about finished with the Simple Script plugin, although I'm still open for suggestions on functions that people would like to see.
I have one more question for everyone. I've created a menu option for "Repeat Last Script" which is convenient for running the same script on multiple files. This menu option is just begging for a hot key. I've decided on ALT-SHIFT-R, the only combination of CTRL, ALT, and SHIFT with either R (for Repeat) or S (for Script) that isn't already being used by default. Of course, I haven't downloaded every plugin, so I don't know if it conflicts with anything that others are using.
Any objections to me using ALT-SHIFT-R for "Repeat Last Script"?
Never mind. I added the ability to map the shortcut key in the .ini file. It will be ALT-SHIFT-R by default, but you can change it if you would prefer a different key combination. You can also map Run Script, though it will have no default shortcut.
I would have liked to use the built-in Notepad++ Shortcuts Mapper in order to keep the shortcuts centralized, but I'll have to hold off on that until I can do a little more testing to figure out if it would even work.
How about clipboard actions like:
CopyToClipBoardIfContain(text): copy the whole line is it contain a text
CopyToClipBoardIfNotContain(text) : copy if don't contain text
CutToClipBoardIfContain(text): Cut the whole line is it contain a text
CutToClipBoardIfNotContain(text) : Cut if don't contain text
Also as you have:
setblanks(minblank,maxblank,threshhold): Changes the number of blank lines between lines.
It might be usfule to add
setSpaces(minSpace,maxSpace,threshhold): Changes the number of Spaces.
so that if you have
X = 7
Y = 6
Z = 9
you can change it to
X = 7
Y = 6
Z = 9
regards
It seems that the editor removes the extra spaces, what i ment (lines represent spaces):
X = _________________________7
Y = ______6
Z = _____________________________________9
you can change it to
X = 7
Y = 6
Z = 9
Your idea about using the clipboard is interesting. I'm wondering what kinds of applications this could have? If you can give me an example of how you might use this, I think I can probably implement it.
On your SetSpaces idea, I just want to confirm that you're thinking the same thing I'm thinking. The SetBlanks function sets the number of blank lines between paragraphs to Minblank, unless it already has at least a number of blank lines indicated by Threshhold, in which case it will set the number of blank lines at that position to Maxblank.
For example, if you have a double-spaced document that you want to convert to a single-spaced document, you would use setblanks(0,1,2). This means that all of those single blank lines between rows of text would be converted to 0 blank lines (Minblank=1). In cases where there are 2 or more blank lines (Threshold=2), it would assume this is a major break, and set it to 1 blank line between rows of text (Maxblank=1).
Is this the sort of thing you had in mind for SetSpaces?
Oops. I meant, Minblank=0 in the second-to-last paragraph above. It should read:
"This means that all of those single blank lines between rows of text would be converted to 0 blank lines (Minblank=0)."
Yes, This would be a good implementation, so this would be what i need in setSpaces, and thinking about it again may be we can generalize the functionality to setChars(char,Min,Max,threshold), so for an example if a java programmer wants to be sure he/she don't have 2 or more semi commas, for example:
if (appData == null){
return false;;
}
you can say setChars(';',0,1,2)
so for simplicity you might have 3 function: setBlanks,setSpaces and setChars you can use setChars to do the functionality of the first 2, but they are there if you don't know how to do that
Regarding your question about where to use copytoClipBoard, say you have an SQL file which contain many amny active and remarked lines, something like:
insert into ROLE(ROLE_ID,NAME) values(0001,'Administrator');
--insert into ROLE(ROLE_ID,NAME) values(0002,'Power User');
--insert into ROLE(ROLE_ID,NAME) values(0003,'Manager');
insert into ROLE(ROLE_ID,NAME) values(0004,'Commercial User');
and you want to copy only the active lines to run them, what i do know is
* copy '--' to clipboard
* hide lines using tidyfx vis
* select all
* copy visible selection (using Tidy also)
* paste in new text documnet
* copy all the text again
* replace text in the old document
all those steps can be simply done by selecting all lines and choosing:
cutToClipBordWhenContain('--')
I see. In your CopyIfContain function, you were talking about checking on a per-line basis. That actually makes quite a bit of sense. I was under the mistaken impression that you meant that it only checked once for the entire selected text.
I may not get it in for the 1.0 version, but it's definitely on the list for the next version. When you first mentioned the clipboard, that started me thinking about what other clipboard functions I could implement, so I've got about a dozen of them planned now.
On the SetChars, your description also makes sense. Basically it would force all sequences of a particular character to be one of exactly two potential lengths. I like it. Again, probably not in the 1.0 version, but I'll keep it in mind.
> I added the ability to map the shortcut key in the .ini file.
Notepad++ supports altering these shortcuts natively, as long as you support the Shortcut object for the menu item (FuncItem). You can even set all members of the Shortcut object to NULL and by default there will be no assignment, but the plugin will be listed in the shortcut mapper (it's hacky but I found it to work without any problems). Have you seens Jenz' PluginTemplate? It should have a proper example.
Thanks. I didn't know that.
I just looked in the shortcut mapper, and with my plugin installed, "Repeat Last Script" is already there, so apparently I set it up right without even realizing it. I just have to tweak "Run Script" a little and it should work too.
It seems like every day I discover some new feature about Notepad++.
Rather than try to put linestart and lineend in so many commands, why not put in a select line(s) command that all subsequent commands will work on. You don't need a deselect if you just make "0", the deselect. The commands would look as follows:
select(line start,line end)
selectc(line start,line count)
Then, all subsequent commands, including sort and uppercase and so on would act only on the selected lines. It would also free up the syntax of the other commands so that you would need fewer commands.
That's an intriguing idea. Right now I have no place to store any settings between lines of the script, so it probably won't go into the 1.0 version because I would have to rewrite a significant portion of the plugin to get it to work. Right now I'm just waiting to hear back from Jens to see if I can get this listed on the Notepad++ Plugins Project, so there's no time to do any major changes. Right now I'm just testing, not implementing any new features.
Once we start down that road, it opens up all kinds of interesting possibilities. A lot of the script functions (and now I've got almost 50 completed with a couple dozen more planned) use similar parameters. It would be nice to store these parameters and not have to set them in each function call. Things like:
Line start
Line end
Case-sensitive matching and sorting (on or off)
Pad character
Delimiter
Line format (Windows, Unix, Mac)
It also sounds like your idea would be better implemented by actually storing a subset of lines to work on which would then be passed back into the working text, which would then be passed back into the open Notepad++ document.
It of course brings up some questions as well. Nothing that can't be resolved, but I'll have to put some thought into them. For example:
How should you set up the parameters?
How persistent should they be? (Reset between scripts, remain until you close Notepad++, or even remember them from previous sessions)
How should the script handle defaults? (i.e. if the parameters haven't been set already)
How do you tell a function whether to use the pre-defined parameters as opposed to setting them in the function call?
How do you tell a function to work only on the selected subset and not the whole text?
Since this would allow me to reduce the number of functions, how important is backward-compatibility? (e.g. Should I leave in the sortcase function?)
Those are just the ones I thought up off the top of my head. I'll have to think about this some more to see if I can work it into a later version.
Thanks for the idea!
How about replace_characters(begin, end) on a line, all through the file, though not necessarily unform in characters but in position. Take a look at Better File Rename as it has many options that would be nice in notepad++
Regarding your replace_characters, are you talking about overwriting portions of every line with certain text? I'm planning a replaceinline(text,position) function that does exactly that. That also suggests the idea of an insertinline function as well.
As far as looking at Better File Rename, I'm not familiar with that particular program, but I'm assuming it's some kind of file renaming program. I've downloaded some freeware programs like that, and I think you're on to something there. There's an obvious similarity between renaming files and renaming a series of lines, so I'll have to look into them and see what kinds of things would be useful.
Thanks, and keep the ideas coming.
Version 0.9 is finished. I just sent the files to Jens to add to the Notepad++ Plugins project, so look for it there soon. I'll put a link in this thread as soon as I see it there.
I'm calling it version 0.9 not because it's not done, but because I haven't finished rigorously testing each function. There are no known bugs at the moment, so once it's uploaded, feel free to start using it.
I haven't added all of the functions I have in mind, but from now until the 1.0 version, I'm not working on any new features, just testing and bug fixing. But I'm still open to ideas for version 1.1.