[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: replacing endline
From: |
Fredrik Bulow |
Subject: |
Re: replacing endline |
Date: |
Thu, 20 Apr 2006 11:22:56 +1000 |
User-agent: |
Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux) |
sarah.dzion@gmail.com writes:
> Hi I want to convert :
> 72
> 17
> 18
> 19
> 20
> 21
> 22
> 23
> 24
> 25
>
>
> to
>
> 72#17#18#19#20#21#22#23#24#25
>
> how do I do this using replace-string (or something else in emacs)?
> basically I do not know how to specify endline in emacs.
>
> Appreciate the help!
> Thanks!
> -A
The simplest way to do what you want is to use a macro. You use
C-x ( to start recording a macro,
C-x ) to stop recording it and
C-e to execute the recorded macro
Since I am such a newbie friendly person I'll walk you through the
whole process. Don't be scared because what you see below is a nine
step list. It looks complicated because I explain *everything*. The
process is in fact very simple.
1. Place your marker at the beginning of the second line (i.e. in
front of or on top of the 1 in 17).
2. Press C-x and then press ( to start recording a macro. Don't hold
down C-x when you press ), instead, hold down C (which is the key
marked Ctrl and press x, let both keys up end then press ")" )
3. Press backspace. This will take 17 to the line with 72 on it and
the marker will still be on top of the 1 in 17. The text on this
line should now be 7217.
4. Press # to type a #. The text on the line is now 72#17
5. Press arrow down (or C-n) to go to the next line.
6. Press C-a to go to the first beginning of that line which is "where
you started".
7. Pres C-x and then press ) to stop recording the macro.
8. Now press C-x and then e to see the computer automatically do the
things you've recorded into the macro and bring the 18 up to the
line with #'s on it.
9. Now you can either press C-x e seven times to finish the rest of
the lines OR press C-u 7 C-x e which means run macro eight
times. Now you're done!
Note: when I need to run a macro a few hundred times over, then I
rarely count the lines instead I run the macro 9 times or so a several
times until I can easily see how many more iterations that are needed.
Now you know how to make macros and you can apply this to most
repetitive tasks you need to do during the rest of your life! This
will save you *lots* of time. By the way, you can use all (well
almost) normal emacs commandos in your macros.
Hope this was helpful and good luck!
/Fredrik
- replacing endline, sarah . dzion, 2006/04/19
- Re: replacing endline, Ye Wenbin, 2006/04/19
- Re: replacing endline, Katsumi Yamaoka, 2006/04/19
- Re: replacing endline,
Fredrik Bulow <=
- Re: replacing endline, Fredrik Bulow, 2006/04/19
- Re: replacing endline, Fredrik Bulow, 2006/04/19
- Re: replacing endline, Thien-Thi Nguyen, 2006/04/20
- Re: replacing endline, Fredrik Bulow, 2006/04/20
- Re: replacing endline, Lennart Borgman, 2006/04/20
- Re: replacing endline, Eli Zaretskii, 2006/04/20
- Message not available
- Re: replacing endline, Harald Hanche-Olsen, 2006/04/20
- Re: replacing endline, Lennart Borgman, 2006/04/20
- Re: replacing endline, Eli Zaretskii, 2006/04/21
- Message not available
- Re: replacing endline, Harald Hanche-Olsen, 2006/04/21