jEdit Community - Resources for users of the jEdit Text Editor
writing a macro that repeats to end of file
Submitted by Anonymous on Sunday, 22 February, 2004 - 20:12
I'm having trouble writing a macro that repeats to the end of file. I want the curser to move down 2 lines, then delete, then move down 2 lines, then delete, repeatedly until the end of file is reached.

I wrote the macro that moves down 2 lines and deletes and tried repeating using C+Enter, but if you give it a number that goes past the end of file it starts deleting lines that I don't want deleted.

There's got to be a way to do this. Anyone know?
dave
Comment viewing options
Select your preferred way to display the comments and click 'Save settings' to activate your changes.
here's the bsh code that I wa
by Anonymous on Mon, 23/02/2004 - 03:49
here's the bsh code that I want to run repeatedly until the end of file:

textArea.goToNextLine(false);
textArea.goToNextLine(false);
textArea.backspace();

any help appreciated.

dave
 
Solution
by ibecze on Sat, 24/04/2021 - 02:00
I recently started to use jEdit, and I needed the same functionality (i.e. repeat macro until the end of file). Though the original posting is 17 years old, I still could not find a posted solution, so I came up with this solution below. You need to add the code that you want to repeat, and you need to be careful not to create an infinite loop.


while (textArea.getCaretPosition() != textArea.getBufferLength()) {
    // Include the code you want to repeat here:

}




Using Dave's example, the macro for his purpose should look like this:



while (textArea.getCaretPosition() != textArea.getBufferLength()) {
    // Include the code you want to repeat here:
    textArea.goToNextLine(false);
    textArea.goToNextLine(false);
    textArea.backspace();

}




I hope this solution will still be useful for jEdit users.

István
User login
Browse archives
« March 2024  
MoTuWeThFrSaSu
 
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
Poll
Are you interested in language packs for jEdit?
Yes, and I could help maintain translations
26%
Yes, I'd like to have translations
32%
Indifferent
35%
No, that'd be bad (please comment)
7%
Total votes: 1093
Syndication
file   ver   dls
German Localization light   4.4.2.1   82338
Context Free Art (*.cfdg)   0.31   46042
JBuilder scheme   .001   18486
BBEdit scheme   1.0   18107
ColdFusion scheme   1.0   18015
R Edit Mode - extensive version   0.1   17461
Advanced HTML edit mode   1.0   16194
Matlab Edit Mode   1.0   16056
jEdit XP icons   1.0   15220
XP icons for jEdit   1.1   14281