From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Fredrik Bulow Newsgroups: gmane.emacs.help Subject: Re: replacing endline Date: Thu, 20 Apr 2006 11:22:56 +1000 Message-ID: <87y7y1t4zz.fsf@gmail.com> References: <1145492327.354125.133060@j33g2000cwa.googlegroups.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1145497337 8700 80.91.229.2 (20 Apr 2006 01:42:17 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 20 Apr 2006 01:42:17 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Apr 20 03:42:12 2006 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1FWOBO-0002Lb-5V for geh-help-gnu-emacs@m.gmane.org; Thu, 20 Apr 2006 03:42:10 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FWOBN-0007LU-Nm for geh-help-gnu-emacs@m.gmane.org; Wed, 19 Apr 2006 21:42:09 -0400 Original-Newsgroups: gnu.emacs.help User-Agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux) Cancel-Lock: sha1:FcdvWGdAykUgMSdCHN2Ms4eCaV8= Original-NNTP-Posting-Host: 220.245.217.246 X-Original-NNTP-Posting-Host: 220.245.217.246 Original-X-Trace: dnews.tpgi.com.au!tpg.com.au 1145496176 220.245.217.246 (20 Apr 2006 11:22:56 +1100) Original-Lines: 76 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!newsfeed.gamma.ru!Gamma.RU!news-out2.kabelfoon.nl!newsfeed.kabelfoon.nl!xindi.nntp.kabelfoon.nl!newsfeed.freenet.de!solnet.ch!solnet.ch!nntp.gblx.net!nntp3.phx1!dnews.tpgi.com.au!tpg.com.au!not-for-mail Original-Xref: shelby.stanford.edu gnu.emacs.help:138879 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:34497 Archived-At: 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