Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
179 views
in Technique[技术] by (71.8m points)

Running a macro till the end of text file in Emacs

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.

question from:https://stackoverflow.com/questions/7540224/running-a-macro-till-the-end-of-text-file-in-emacs

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...