Thursday, June 26, 2014

TextPad: How to Remove All Lines Except the Ones Containing a Pattern

Similar to NotePad,[1] you can remove all lines except the ones containing a pattern in TextPad.[2,3] There is an easy way to achieve this. Basically, you need to perform 3 steps:
  1. Bookmark all lines containing a pattern
  2. Inverse bookmark
  3. Delete all bookmarked lines

 

Bookmark All Lines Containing a Pattern


For this demonstration, we want to remove all lines except the ones containing the following pattern:
  • "concurrent-mark-end"
To bookmark all lines containing a pattern:
  1. Go to Menu "Search" and select "Find..."  
  2. Specify the pattern in "Find what:" and select "Regular expression"
  3. Hit Button "Mark All"

Inverse Bookmark


To inverse bookmark, do:
  • Go to Menu "Search" and select "Inverse Bookmarks"
 You should see some lines are marked and some not.


Delete All Bookmarked Lines


To delete all bookmarked lines, do:
  1.  Go to Menu "Edit" and select "Delete > Bookmarked Lines"
and you should see the final results below:



References

  1. How to delete all line except lines containing a word I need?
  2. TextPad Quick Reference Card - John Bokma
  3. TextPad Downloads

No comments: