Why chaining commands is so powerful.
That’s rxedit’s superpower, otherwise it would be a less capable grep or sed.
The idea is to make lines selectively visible by either adding to, or hiding, lines that were
made visible by previous commands.
Except for more and all only visible lines are affected by any commands. This applies
specifically to delete and change. invert can be used to “flip” the visibility.
For example, to extract only lines of interest to a report (using the `-o
rxedit myjava.java all::public invert delete -o myreport.out
- show
alllines you care about - optionally, apply an appropriate
lessto remove commented out lines or invertthe visibilitydeleteeverything-o myreport.txtwould then save only lines with lines of interest.- (No, you certainly wouldn’t want want to use the
-Omodify in place option here).
- (No, you certainly wouldn’t want want to use the
You could also search for lines that indicate debugging code, hide some of the ones you want to keep
and then run a macro with predefined language-specific change commands to comment out those debugging lines.
Workflow Help
- Start with broad match commands to reveal relevant lines, possibly using existing macro files.
- Narrow progressively using additional commands.
- Add -n for line numbers and -s for visual spacing.
- Make sure your visible lines match your expections.
If modifying the file
- If modifying the file with
prepend/append,changeordelete, make doubly sure the results are as expected. - When satisfied, use -O to modify the file in place (best to do it on a version-controlled directory)
SEE ALSO
rxedit --help change shows a fairly complex chaining example to comment “print” statements.