Running a macro till the end of text file in Emacs

whatf picture whatf · Sep 24, 2011 · Viewed 10.9k times · Source

I have a text file with some sample content as shown here:

Sno = 1p
Sno = 2p
Sno = 3p

What i want is to remove the p from each of the columns. With this intention i write a macro:

M-x //go to buffer
C-x (//start the macro
C-s = // search for equalto sign
RET C-f C-f // reach to te alphabet 'p'
DEL // Delete
C-n  C-x )//go to new line and Close the macro definition 
C-x e

Pressing e twice will remove p, but in case i want to do the same stuff till the end of file, how can i do it i can't keep pressing e if i have 20000 such lines. What should be done??

Please donot suggest regex, as this is a sample example, not the actual case. Please donot suggest any elisp, i am comfortable with remembering shortcutf for emacs.

Answer

Nietzche-jou picture Nietzche-jou · Sep 24, 2011

M-0 C-x e to repeat last macro until an error happens (after the final line, either C-s = or C-n will be an error).

You may hear an annoying beep.