some vi equivalents please?

4 views
Skip to first unread message

rustom

unread,
Oct 31, 2008, 11:08:42 AM10/31/08
to
1. In vi I can delete a line that contains a <pat> with
:g/<pat>/d

How is this done in emacs?

2. match-variables:
If I want to remove everything after the second : (in a file that has
3 fields separated with two :'s)
I do
:s/\(.*\):\(.*\):.*/\1 \2
How do I do that in emacs?

Thanks

Teemu Likonen

unread,
Oct 31, 2008, 11:53:20 AM10/31/08
to
rustom (2008-10-31 08:08 -0700) wrote:

> 1. In vi I can delete a line that contains a <pat> with
> :g/<pat>/d
>
> How is this done in emacs?

M-x flush-lines <RET> REGEXP <RET>

See
(info "(emacs) Other Repeating Search")
or
C-h f flush-lines RET

> 2. match-variables:
> If I want to remove everything after the second : (in a file that has
> 3 fields separated with two :'s)
> I do
> :s/\(.*\):\(.*\):.*/\1 \2
> How do I do that in emacs?

M-x replace-regexp <RET> \(.*\):\(.*\):.* <RET> \1 \2

Drew Adams

unread,
Oct 31, 2008, 11:59:42 AM10/31/08
to rustom, help-gn...@gnu.org
> some vi equivalents please?

After you obtain the info you need, consider sharing it by posting it to Emacs
Wiki:
http://www.emacswiki.org/emacs/SiteMap.

That might help other vi users who try Emacs. Type `vi' into the wiki search
field to find an appropriate page to edit, or start a new page if none is
appropriate (and link appropriate existing pages to it). It's very easy to edit
the wiki.

See also the Emacs manual (`C-h r'), node Emulation (`g Emulation'). My
impression is that many former `vi' users of Emacs use Viper - see the Viper
manual (`C-h i', then choose VIPER).

Toby Cubitt

unread,
Oct 31, 2008, 11:01:01 AM10/31/08
to help-gn...@gnu.org
rustom wrote:
> 1. In vi I can delete a line that contains a <pat> with
> :g/<pat>/d
>
> How is this done in emacs?

M-x query-replace-regexp

then enter "^.*<pat>.*$" as the regexp (no quotes), and leave the
replacement blank.


> 2. match-variables:
> If I want to remove everything after the second : (in a file that has
> 3 fields separated with two :'s)
> I do
> :s/\(.*\):\(.*\):.*/\1 \2
> How do I do that in emacs?

M-x query-replace-regexp

then "^[^:]*\(.*\):\(.*\):.*$" for the regexp, and "\1 \2" for the
replacement (again, no quotes).

The "^" and "$" both here and above are only there to prevent the regexp
matching across lines (unlike sed, regexp searches in an Emacs buffer
aren't line-oriented). Depending on your file, you might get away with
something simpler. E.g. for 2, if you know there will always be two
colons on every line, you could use "\(.*?\):\(.*?\):.*" instead ("?"
makes a wildcard non-greedy).

query-replace-regexp is interactive, like query-replace. I find this
useful just to check I've got the regexps right, and then hit "!" once
I'm happy with it to replace all the rest non-interactively. The
non-interactive version is replace-regexp.

There are no doubt many other ways to accomplish this in Emacs...

HTH,

Toby


Parker, Matthew

unread,
Oct 31, 2008, 12:01:02 PM10/31/08
to rustom, help-gn...@gnu.org
M-x delete-matching-lines -> delete lines that contain regexp
M-x flush-lines -> synonym
M-x delete-non-matching-lines -> the reverse
M-x keep-lines -> synonym

Matthew Parker

SEI | 1 Freedom Valley Drive | Oaks, PA 19456 | p: 610-676-1279 | f:
484-676-1279 | www.seic.com

Giorgos Keramidas

unread,
Oct 31, 2008, 12:53:11 PM10/31/08
to
On Fri, 31 Oct 2008 08:08:42 -0700 (PDT), rustom <rusto...@gmail.com> wrote:
> 1. In vi I can delete a line that contains a <pat> with
> :g/<pat>/d
>
> How is this done in emacs?

I commonly use a keyboard macro for this sort of thing.

Type `C-x (' to start defining a macro, the run ``one iteration'' of a
complex set of commands, like `C-s pat C-a C-k C-k', and finally finish
the macro by typing `C-x )'. If the macro seems to work fine, it is
then easy to repeat it a specific number of times (C-u 100 C-x e) or
keep repeating the same macro by `C-x e e e e e e e ...'.

Macros are really powerful in Emacs. I have used them to convert text
files from one `ChangeLog' format to another, or to reformat a bit parts
of a text file that contain dates, and so on. The manual describes a
lot of even more interesting things you can do with keyboard macros.
Have a look at it by typing `C-h r m "Keyboard Macros" RET'.

> 2. match-variables:
> If I want to remove everything after the second : (in a file that has
> 3 fields separated with two :'s)
> I do
> :s/\(.*\):\(.*\):.*/\1 \2
> How do I do that in emacs?

Select a region (or the entire buffer with `C-x -h') and then type:

M-x replace-regexp RET \(.*\):\(.*\):.* RET \1 \2 RET

You can even get an interactive replace mode by typing:

M-x query-replace-regexp RET \(.*\):\(.*\):.* RET \1 \2 RET

Emacs is a bit more verbose when replacing regular expressions, but the
extra verbosity is a bit nice to see in the default case. Binding one
of these to a `shortcut' like `C-c R' is very easy

(global-set-key (kbd "C-c R") 'query-replace-regexp)
(global-set-key (kbd "<f4>") 'query-replace-regexp)

and you *still* get to see the verbose, helpful name of the command,
with the full feature set of command-completion when you need it.

Joost Kremers

unread,
Oct 31, 2008, 1:22:15 PM10/31/08
to
Giorgos Keramidas wrote:
> (global-set-key (kbd "C-c R") 'query-replace-regexp)
> (global-set-key (kbd "<f4>") 'query-replace-regexp)

note that query-replace-regexp is already bound to C-M-%. though if you use
it a lot (i don't) it may be more convenient to choose a less demanding key
combo. C-M-% requires holding down Control, Alt, Shift and '5' simultaneously...


--
Joost Kremers joostk...@yahoo.com
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)

Giorgos Keramidas

unread,
Oct 31, 2008, 1:34:26 PM10/31/08
to
On 31 Oct 2008 17:22:15 GMT, Joost Kremers <joostk...@yahoo.com> wrote:
> Giorgos Keramidas wrote:
>> (global-set-key (kbd "C-c R") 'query-replace-regexp)
>> (global-set-key (kbd "<f4>") 'query-replace-regexp)
>
> note that query-replace-regexp is already bound to C-M-%. though if
> you use it a lot (i don't) it may be more convenient to choose a less
> demanding key combo. C-M-% requires holding down Control, Alt, Shift
> and '5' simultaneously...

Ah, I didn't notice `C-M-%'. Thank you.

On the other hand, in my desktop holding down Alt & Shift at the same
time switches between English and Greek input, so you are right that a
more convenient key is probably going to be nice :-)

Xah

unread,
Oct 31, 2008, 6:49:08 PM10/31/08
to
On Oct 31, 10:34 am, Giorgos Keramidas <keram...@ceid.upatras.gr>
wrote:

alternative solution is just to give it a alias.

So, i have

(defalias 'qr 'query-replace)
(defalias 'qrr 'query-replace-regex)

Alias makes many frequently used command easy, esp when you already
have too many shortcuts to remember or don't have key space.

Recently query-replace and query-replace-regex are incorporated into
my ergo keyboard with just “Alt+5” and “Alt+Shift+5” (e.g. “Alt+%”).
(see http://xahlee.org/emacs/ergonomic_emacs_keybinding.html )

also, the orignial poster might be interested in:

(defalias 'lml 'list-matching-lines)
(defalias 'dml 'delete-matching-lines)

delete-matching-lines is just a alias to the “flush-lines” too. The
“flush-lines” is a 1980's terminology, it's probably best to not
spread it.

Xah
http://xahlee.org/


Kevin Rodgers

unread,
Nov 1, 2008, 9:32:58 AM11/1/08
to help-gn...@gnu.org
Toby Cubitt wrote:

> rustom wrote:
>> 1. In vi I can delete a line that contains a <pat> with
>> :g/<pat>/d
>>
>> How is this done in emacs?
>
> M-x query-replace-regexp
>
> then enter "^.*<pat>.*$" as the regexp (no quotes), and leave the
> replacement blank.
>
>
>> 2. match-variables:
>> If I want to remove everything after the second : (in a file that has
>> 3 fields separated with two :'s)
>> I do
>> :s/\(.*\):\(.*\):.*/\1 \2
>> How do I do that in emacs?
>
> M-x query-replace-regexp
>
> then "^[^:]*\(.*\):\(.*\):.*$" for the regexp, and "\1 \2" for the
> replacement (again, no quotes).
>
> The "^" and "$" both here and above are only there to prevent the regexp
> matching across lines (unlike sed, regexp searches in an Emacs buffer
> aren't line-oriented). Depending on your file, you might get away with
> something simpler. E.g. for 2, if you know there will always be two
> colons on every line, you could use "\(.*?\):\(.*?\):.*" instead ("?"
> makes a wildcard non-greedy).
>
> query-replace-regexp is interactive, like query-replace. I find this
> useful just to check I've got the regexps right, and then hit "!" once
> I'm happy with it to replace all the rest non-interactively. The
> non-interactive version is replace-regexp.

Good advice!

> There are no doubt many other ways to accomplish this in Emacs...

Since rustom is used to vi's noninteractive way of using sed-like
commands:

C-M-h ; mark-whole-buffer
C-u M-| ; shell-command-on-region
sed '/<pat>/d'

C-M-h ; mark-whole-buffer
C-u M-| ; shell-command-on-region
sed 's/^\([^:]*\):\([^:]*\):.*$/\1 \2/' ; note the trailing /

--
Kevin Rodgers
Denver, Colorado, USA

rustom

unread,
Nov 1, 2008, 10:45:42 AM11/1/08
to

Well I tried putting up a table on emacswiki...
The link I made is http://www.emacswiki.org/emacs/ViEmacsTable
What I pasted is my org mode file
But I cant figure out how to put a table into emacswiki. So its messed
up.

Heres the table (in org-mode) anyway

* Vi - Emacs
This table does not cover basic commands like character motion

| Command | Vi |
Emacs |
|-------------------------+-----------------
+---------------------------|
| transpose-char | xp | C-
t |
| transpose-word | dwwp | M-
t |
| indent | >> | C-x
TAB |
| search | /pat | C-
s |
| substitute | :%s/pat/subs | M-% or M-C-
% |
| substitute variables | :s/pat/\1 \2 | replace-regexp then \1
\2 |
| search word/identifier | /<word>
| ?? |
| delete lines | :g/pat/d | flush-
lines |
| set line numbers | :se nu
| ?? |
| show tabs&newlines | :se list
| ?? |
| change file formats | :se ff=unix/dos
| ?? |
| shell cmd | :!cmd | M-!
cmd |
| matching ({[ | % | M-C-f/b
(??) |
| filename on bottom line | % | see code
below |
| sort next n lines | n!!sort
| ?? |

rustom

unread,
Nov 1, 2008, 10:52:23 AM11/1/08
to
Well the post here was as messed up as on the emacswiki -- Sorry
Shortening the lines and trying again.
The following should be pasted into org-mode to read

Drew Adams

unread,
Nov 1, 2008, 1:07:24 PM11/1/08
to rustom, help-gn...@gnu.org
> > > some vi equivalents please?
> >
> > After you obtain the info you need, consider sharing it by
> > posting it to Emacs Wiki:http://www.emacswiki.org/emacs/SiteMap.
> >
> > That might help other vi users who try Emacs. Type `vi'
> > into the wiki search field to find an appropriate page to edit,
> > or start a new page if none is appropriate (and link appropriate
> > existing pages to it). It's very easy to edit the wiki.
> >
> > See also the Emacs manual (`C-h r'), node Emulation (`g
> > Emulation'). My impression is that many former `vi' users of
> > Emacs use Viper - see the Viper manual (`C-h i', then choose VIPER).
>
> Well I tried putting up a table on emacswiki...
> The link I made is http://www.emacswiki.org/emacs/ViEmacsTable
> What I pasted is my org mode file. But I cant figure out how to

> put a table into emacswiki. So its messed up.

I fixed it on the wiki for you. Take a look (edit the page), and you'll see how
easy it is to create a table: ||a||b||c||. (You can alternatively use the markup
<pre>...</pre>.)

FYI, how to edit the wiki is here:
`HowTo' (a link at the top of each page) > `Edit'

In particular, see the link there called `TextFormattingRules'.

However, I notice now that the table construct, `||', is not mentioned
explicitly at `TextFormattingRules'. You'll find it by following the link
`Oddmuse:Usemod Markup Extension'. (Feel free to add a brief mention of it at
`TextFormattingRules', if you like.)

Giorgos Keramidas

unread,
Nov 1, 2008, 12:40:13 PM11/1/08
to
On Sat, 1 Nov 2008 07:52:23 -0700 (PDT), rustom <rusto...@gmail.com> wrote:
> Well the post here was as messed up as on the emacswiki -- Sorry
> Shortening the lines and trying again.

That's web-based readers for you. You can never tell what they are
_really_ going to post, until *after* you have posted it and see how the
text arrived back in your incoming news feed.

The table seems useful. I'll try to reformat it in the Wiki itself.

Thanks for writing it :)

Reiner Steib

unread,
Nov 1, 2008, 2:47:42 PM11/1/08
to
On Sat, Nov 01 2008, Kevin Rodgers wrote:

> Since rustom is used to vi's noninteractive way of using sed-like
> commands:
>
> C-M-h ; mark-whole-buffer
> C-u M-| ; shell-command-on-region
> sed '/<pat>/d'

Using `!' (replace all remaining matches with no more questions) in
`query-replace-regexp' seem more useful to me.

Bye, Reiner.
--
,,,
(o o)
---ooO-(_)-Ooo--- | PGP key available | http://rsteib.home.pages.de/

rustom

unread,
Nov 2, 2008, 10:30:57 AM11/2/08
to
On Nov 1, 10:07 pm, "Drew Adams" <drew.ad...@oracle.com> wrote:
> > > > some vi equivalents please?
>
> > > After you obtain the info you need, consider sharing it by
> > > posting it to Emacs Wiki:http://www.emacswiki.org/emacs/SiteMap.
>
> > > That might help other vi users who try Emacs. Type `vi'
> > > into the wiki search field to find an appropriate page to edit,
> > > or start a new page if none is appropriate (and link appropriate
> > > existing pages to it). It's very easy to edit the wiki.
>
> > > See also the Emacs manual (`C-h r'), node Emulation (`g
> > > Emulation'). My impression is that many former `vi' users of
> > > Emacs use Viper - see the Viper manual (`C-h i', then choose VIPER).
>
> > Well I tried putting up a table on emacswiki...
> > The link I made ishttp://www.emacswiki.org/emacs/ViEmacsTable

> > What I pasted is my org mode file. But I cant figure out how to
> > put a table into emacswiki. So its messed up.
>
> I fixed it on the wiki for you. Take a look (edit the page), and you'll see how
> easy it is to create a table: ||a||b||c||. (You can alternatively use the markup
> <pre>...</pre>.)
>
> FYI, how to edit the wiki is here:
>  `HowTo' (a link at the top of each page) > `Edit'
>
> In particular, see the link there called `TextFormattingRules'.
>
> However, I notice now that the table construct, `||', is not mentioned
> explicitly at `TextFormattingRules'. You'll find it by following the link
> `Oddmuse:Usemod Markup Extension'. (Feel free to add a brief mention of it at
> `TextFormattingRules', if you like.)

For some reason the forward-slash ( '/') in substitute is appearing
but in the next line -- substitute variables -- it is disappearing and
italicizing the pat

Drew Adams

unread,
Nov 2, 2008, 11:12:50 AM11/2/08
to rustom, help-gn...@gnu.org
> > FYI, how to edit the wiki is here:
> >  `HowTo' (a link at the top of each page) > `Edit'
> > In particular, see the link there called `TextFormattingRules'.
>
> For some reason the forward-slash ( '/') in substitute is appearing
> but in the next line -- substitute variables -- it is disappearing and
> italicizing the pat

I fixed that too.
/foo/ italicizes foo. ##foo## puts foo in a fixed-width font.

Again, please read up a bit on formatting. It's not a big deal.

And questions/problems about the wiki itself are best brought up there, not
here. You can pose questions and comments directly on the pertinent pages (e.g.
ViEmacsTable), and there is a Problems link at the top and bottom of each page,
for general wiki problems.

It takes a little time to get to know the wiki, but it doesn't get any easier
than this. ;-)

rustom

unread,
Nov 3, 2008, 2:19:00 AM11/3/08
to
On Nov 2, 9:12 pm, "Drew Adams" <drew.ad...@oracle.com> wrote:

> Again, please read up a bit on formatting. It's not a big deal.
>
> And questions/problems about the wiki itself are best brought up there, not
> here. You can pose questions and comments directly on the pertinent pages (e.g.
> ViEmacsTable), and there is a Problems link at the top and bottom of each page,
> for general wiki problems.
>
> It takes a little time to get to know the wiki, but it doesn't get any easier
> than this. ;-)

Well Ok. Ive added somethings there and corrected some omissions.

But there is one thing which is more appropriate here (I think)
When I put n!!sort to sort the next n lines I was putting that merely
as an example of a 2-way pipe.
ie a command that takes its input from a bunch of vi lines and whose
output goes in as a replacement.

Of course its good to know about sort-lines but that is hardly
general.
One could want sort|uniq
or sort|uniq|pr
with all kinds of unixy command-line args peppered in -- a unix-shell
programmer never ceases to find new pipelines that he never had
imagined before.

Also Xah mentioned that flush-lines is obsolete compared to delete-
matching-lines. Since Im hearing of both for the first time I'll leave
it to others to decide which is the recommended name.
Frankly flush makes me think of fflush in C (or something less
mentionable)

Drew Adams

unread,
Nov 3, 2008, 4:10:28 AM11/3/08
to rustom, help-gn...@gnu.org
> Well Ok. Ive added somethings there and corrected some omissions.

Great. You can see from the activity on the page that it sparked some interest
and has no doubt helped others already.

> But there is one thing which is more appropriate here (I think)
> When I put n!!sort to sort the next n lines I was putting that merely
> as an example of a 2-way pipe.
> ie a command that takes its input from a bunch of vi lines and whose
> output goes in as a replacement.
>
> Of course its good to know about sort-lines but that is hardly
> general. One could want sort|uniq or sort|uniq|pr
> with all kinds of unixy command-line args peppered in -- a unix-shell
> programmer never ceases to find new pipelines that he never had
> imagined before.

Not sure what you're asking here (and why here?). I didn't add `sort-lines' to
your table. Someone else did, presumably trying to help fill in the table. I
don't use vi, so I can't say whether it is appropriate or adequate.

But you are free to correct any info that someone enters - on pretty much any
wiki page. Go for it. You might want to mention piping with UNIX `sort'. You
might want to link to the Emacs manual, node Sorting (which see, BTW - there is
lots more than `sort-lines'). The choice is yours. The wiki is yours.

> Also Xah mentioned that flush-lines is obsolete compared to delete-
> matching-lines.

Nonsense. `flush-lines' is in fact the defun name. It is `delete-matching-lines'
that is an alias for `flush-lines'. But neither is obsolete.

You don't need to refer to Xah or Drew or anyone else for this. Just do `C-h f'
for each of `flush-lines' and `delete-matching-lines', and see what is said
about them. Or check the Emacs manual (it is only `flush-lines' that is
documented there, BTW, but both are listed in the Index).

But the doc strings and manual are not infallible. The source code (linked from
the `C-h f' display) and doc together are the best authority about what is.

But even what is is not necessarily what should be. Emacs is open - to you.
Often things are ultimately a matter of opinion and persuasion (and
customization). And Emacs evolves (and that evolution is not always linear or
progressive). But starting with the doc is always a good idea.

> Since Im hearing of both for the first time I'll leave
> it to others to decide which is the recommended name.

They are two names for the same command. Neither is the recommended name, AFAIK.
Use whichever you like. And even if one or the other were recommended, use
whichever you like. ;-)

> Frankly flush makes me think of fflush in C (or something less
> mentionable)

FWIW, if you enter the command name interactively, via `M-x', it is quicker to
use `flush-lines' than `delete-matching-lines'. `M-x flu TAB', five keystrokes,
suffices. Eight keystrokes are needed for `M-x dele TAB m TAB'.

Personally, I suspect that's one reason many people use `flush-lines'. Another
reason might be that "flush" has long been used in connection with purging
things like buffers. (Another reason might be that some people like to mention
unmentionables such as "flush" and "purge".)

On the other hand, `delete-(non-)matching-lines' has the advantage of being easy
to remember and perhaps more accessible to `apropos' because it uses `match'.

Take your pick. There is no right or wrong answer here. That's the only right
answer. ;-)

Giorgos Keramidas

unread,
Nov 3, 2008, 11:24:16 AM11/3/08
to
On Sun, 2 Nov 2008 23:19:00 -0800 (PST), rustom <rusto...@gmail.com> wrote:
> On Nov 2, 9:12 pm, "Drew Adams" <drew.ad...@oracle.com> wrote:
> But there is one thing which is more appropriate here (I think) When I
> put n!!sort to sort the next n lines I was putting that merely as an
> example of a 2-way pipe. ie a command that takes its input from a
> bunch of vi lines and whose output goes in as a replacement.
>
> Of course its good to know about sort-lines but that is hardly
> general. One could want sort|uniq or sort|uniq|pr with all kinds of
> unixy command-line args peppered in -- a unix-shell programmer never
> ceases to find new pipelines that he never had imagined before.

A more general way would be to `mark a region' and then filter the
region through a shell command with `M-! command' or `C-u M-! command'.

I have modified `ViEmacsTable' on the wiki, to include info about these
two, and a pointer to `ExecuteExternalCommand'.

> Also Xah mentioned that flush-lines is obsolete compared to

> delete-matching-lines. Since I'm hearing of both for the first time


> I'll leave it to others to decide which is the recommended name.
> Frankly flush makes me think of fflush in C (or something less
> mentionable)

IMO, Xah is right that `delete-matching-lines' is a more mnemonic name.

The equivalence table seems to be:

delete-matching-lines => flush-lines
delete-non-matching-lines => keep-lines

We don't have a `keep-matching-lines' too, but it would probably make
sense to add it as an alias of `keep-lines' :)

Ken Goldman

unread,
Nov 5, 2008, 8:41:29 AM11/5/08
to
rustom wrote:
> 1. In vi I can delete a line that contains a <pat> with :g/<pat>/d

Others have posted the best way do do this. However, rather than
searching for infrequently used commands, I typically just define a
keyboard macro and replay it.

In this case, the macro would be:

- search for the pattern
- go to the beginning of the line
- kill the line

rustom

unread,
Nov 6, 2008, 2:08:47 AM11/6/08
to

Well... I have some technical and some non-technical responses to
this.

Technical 1.
Your macro is not equivalent to the vi :g/<pat>/d unless it is
embedded into a loop. The loop could be programmatic or interactive
(keep doing Cx e)

Technical 2.
Overall it turns out faster (without the infrequently used flush-
lines) to
Save-buffer in emacs
Finish off the 1 liner in vi
revert-buffer in emacs

Non-technical 1
I work in an environment where I am the old-timer using the strange
old clunky emacs. I have a hell of a time convincing my half-my-age
coworkers to use emacs. Confirming the clunkyness (because I dont
know a command) does not help my cause :-)

Non-technical 2
Funnily enough, this requirement came up in a large scale edit that
required adding a single line to 200 classes in 37 files. I did this
(for these coworkers) by writing 3 elisp functions that implemented an
iterator that sequentially went through the 200 classes. Producing
the file:lineNo list of those 200 cases was where the original request
(for deleting lines) came up.

So, no, Im not averse to writing emacs macros or elisp code; just like
to use the right tool for the job.

Drew Adams

unread,
Nov 6, 2008, 11:50:35 AM11/6/08
to rustom, help-gn...@gnu.org
> Your macro is not equivalent to the vi :g/<pat>/d unless it is
> embedded into a loop. The loop could be programmatic or interactive
> (keep doing Cx e)

To loop with a keyboard macro:
`C-x e e e e e e e e'... or `C-u 1000 C-x e'

> (without the infrequently used flush-lines)

Why "infrequently"?

> I work in an environment where I am the old-timer using the strange
> old clunky emacs. I have a hell of a time convincing my half-my-age
> coworkers to use emacs. Confirming the clunkyness (because I dont
> know a command) does not help my cause :-)

Don't bother. ;-)

Or convince by example. A friend asked his team to estimate how long it would
take to transform tons of C++ code in a certain context. The estimates were all
about 2-3 man-weeks. He looked through the existing Emacs Lisp source code,
hacked something together, and did all of the code transformation in less than a
day.

YMMV, of course. But Emacs is not so clunky. ;-)

> Funnily enough, this requirement came up in a large scale edit that
> required adding a single line to 200 classes in 37 files. I did this
> (for these coworkers) by writing 3 elisp functions that implemented an
> iterator that sequentially went through the 200 classes. Producing
> the file:lineNo list of those 200 cases was where the original request
> (for deleting lines) came up.

There you go. I should think that such demonstrations might eventually pique the
interest of a few of your half-your-agers.

Johan Bockgård

unread,
Nov 7, 2008, 12:12:41 PM11/7/08
to help-gn...@gnu.org
"Drew Adams" <drew....@oracle.com> writes:

> To loop with a keyboard macro:
> `C-x e e e e e e e e'... or `C-u 1000 C-x e'

C-u 0

Drew Adams

unread,
Nov 7, 2008, 12:38:03 PM11/7/08
to Johan "Bockgård", help-gn...@gnu.org
> > To loop with a keyboard macro:
> > `C-x e e e e e e e e'... or `C-u 1000 C-x e'
>
> C-u 0

Yes, good reminder.

It all depends on what you want. If you want to check the result each time
before repeating, then `C-x e e e'.... If you want to repeat only N times, then
`C-u N C-x e'. if you want to repeat forever or until error, then `C-u 0 C-x e'.

And of course `C-h k C-x e' explains this - much quicker than help-gnu-emacs.
;-)

Reply all
Reply to author
Forward
0 new messages