all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Re: some vi equivalents please?
  2008-10-31 15:08 some vi equivalents please? rustom
@ 2008-10-31 15:01 ` Toby Cubitt
  2008-11-01 13:32   ` Kevin Rodgers
  2008-10-31 15:53 ` Teemu Likonen
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 25+ messages in thread
From: Toby Cubitt @ 2008-10-31 15:01 UTC (permalink / raw)
  To: help-gnu-emacs

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




^ permalink raw reply	[flat|nested] 25+ messages in thread

* some vi equivalents please?
@ 2008-10-31 15:08 rustom
  2008-10-31 15:01 ` Toby Cubitt
                   ` (6 more replies)
  0 siblings, 7 replies; 25+ messages in thread
From: rustom @ 2008-10-31 15:08 UTC (permalink / raw)
  To: help-gnu-emacs

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


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: some vi equivalents please?
  2008-10-31 15:08 some vi equivalents please? rustom
  2008-10-31 15:01 ` Toby Cubitt
@ 2008-10-31 15:53 ` Teemu Likonen
  2008-10-31 15:59 ` Drew Adams
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 25+ messages in thread
From: Teemu Likonen @ 2008-10-31 15:53 UTC (permalink / raw)
  To: help-gnu-emacs

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


^ permalink raw reply	[flat|nested] 25+ messages in thread

* RE: some vi equivalents please?
  2008-10-31 15:08 some vi equivalents please? rustom
  2008-10-31 15:01 ` Toby Cubitt
  2008-10-31 15:53 ` Teemu Likonen
@ 2008-10-31 15:59 ` Drew Adams
  2008-10-31 16:01 ` Parker, Matthew
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 25+ messages in thread
From: Drew Adams @ 2008-10-31 15:59 UTC (permalink / raw)
  To: 'rustom', help-gnu-emacs

> 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).





^ permalink raw reply	[flat|nested] 25+ messages in thread

* RE: some vi equivalents please?
  2008-10-31 15:08 some vi equivalents please? rustom
                   ` (2 preceding siblings ...)
  2008-10-31 15:59 ` Drew Adams
@ 2008-10-31 16:01 ` Parker, Matthew
  2008-10-31 16:53 ` Giorgos Keramidas
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 25+ messages in thread
From: Parker, Matthew @ 2008-10-31 16:01 UTC (permalink / raw)
  To: rustom, help-gnu-emacs

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
> -----Original Message-----
> From: help-gnu-emacs-bounces+mparker=seic.com@gnu.org
[mailto:help-gnu-
> emacs-bounces+mparker=seic.com@gnu.org] On Behalf Of rustom
> Sent: Friday, October 31, 2008 11:09 AM
> To: help-gnu-emacs@gnu.org
> Subject: some vi equivalents please?
> 
> 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




^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: some vi equivalents please?
  2008-10-31 15:08 some vi equivalents please? rustom
                   ` (3 preceding siblings ...)
  2008-10-31 16:01 ` Parker, Matthew
@ 2008-10-31 16:53 ` Giorgos Keramidas
  2008-10-31 17:22   ` Joost Kremers
       [not found] ` <mailman.2577.1225468814.25473.help-gnu-emacs@gnu.org>
  2008-11-05 13:41 ` Ken Goldman
  6 siblings, 1 reply; 25+ messages in thread
From: Giorgos Keramidas @ 2008-10-31 16:53 UTC (permalink / raw)
  To: help-gnu-emacs

On Fri, 31 Oct 2008 08:08:42 -0700 (PDT), rustom <rustompmody@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.



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: some vi equivalents please?
  2008-10-31 16:53 ` Giorgos Keramidas
@ 2008-10-31 17:22   ` Joost Kremers
  2008-10-31 17:34     ` Giorgos Keramidas
  0 siblings, 1 reply; 25+ messages in thread
From: Joost Kremers @ 2008-10-31 17:22 UTC (permalink / raw)
  To: help-gnu-emacs

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                                      joostkremers@yahoo.com
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: some vi equivalents please?
  2008-10-31 17:22   ` Joost Kremers
@ 2008-10-31 17:34     ` Giorgos Keramidas
  2008-10-31 22:49       ` Xah
  0 siblings, 1 reply; 25+ messages in thread
From: Giorgos Keramidas @ 2008-10-31 17:34 UTC (permalink / raw)
  To: help-gnu-emacs

On 31 Oct 2008 17:22:15 GMT, Joost Kremers <joostkremers@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 :-)



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: some vi equivalents please?
  2008-10-31 17:34     ` Giorgos Keramidas
@ 2008-10-31 22:49       ` Xah
  0 siblings, 0 replies; 25+ messages in thread
From: Xah @ 2008-10-31 22:49 UTC (permalink / raw)
  To: help-gnu-emacs

On Oct 31, 10:34 am, Giorgos Keramidas <keram...@ceid.upatras.gr>
wrote:
> On 31 Oct 2008 17:22:15 GMT, Joost Kremers <joostkrem...@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 :-)

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/^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: some vi equivalents please?
  2008-10-31 15:01 ` Toby Cubitt
@ 2008-11-01 13:32   ` Kevin Rodgers
  2008-11-01 18:47     ` Reiner Steib
  0 siblings, 1 reply; 25+ messages in thread
From: Kevin Rodgers @ 2008-11-01 13:32 UTC (permalink / raw)
  To: help-gnu-emacs

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





^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: some vi equivalents please?
       [not found] ` <mailman.2577.1225468814.25473.help-gnu-emacs@gnu.org>
@ 2008-11-01 14:45   ` rustom
  2008-11-01 14:52     ` rustom
                       ` (2 more replies)
  0 siblings, 3 replies; 25+ messages in thread
From: rustom @ 2008-11-01 14:45 UTC (permalink / raw)
  To: help-gnu-emacs

On Oct 31, 8:59 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 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
| ??                        |


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: some vi equivalents please?
  2008-11-01 14:45   ` rustom
@ 2008-11-01 14:52     ` rustom
  2008-11-01 16:40       ` Giorgos Keramidas
  2008-11-01 17:07     ` Drew Adams
       [not found]     ` <mailman.2646.1225559243.25473.help-gnu-emacs@gnu.org>
  2 siblings, 1 reply; 25+ messages in thread
From: rustom @ 2008-11-01 14:52 UTC (permalink / raw)
  To: help-gnu-emacs

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
* 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
| ??                        |


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: some vi equivalents please?
  2008-11-01 14:52     ` rustom
@ 2008-11-01 16:40       ` Giorgos Keramidas
  0 siblings, 0 replies; 25+ messages in thread
From: Giorgos Keramidas @ 2008-11-01 16:40 UTC (permalink / raw)
  To: help-gnu-emacs

On Sat, 1 Nov 2008 07:52:23 -0700 (PDT), rustom <rustompmody@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 :)



^ permalink raw reply	[flat|nested] 25+ messages in thread

* RE: some vi equivalents please?
  2008-11-01 14:45   ` rustom
  2008-11-01 14:52     ` rustom
@ 2008-11-01 17:07     ` Drew Adams
       [not found]     ` <mailman.2646.1225559243.25473.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 25+ messages in thread
From: Drew Adams @ 2008-11-01 17:07 UTC (permalink / raw)
  To: 'rustom', help-gnu-emacs

> > > 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.)





^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: some vi equivalents please?
  2008-11-01 13:32   ` Kevin Rodgers
@ 2008-11-01 18:47     ` Reiner Steib
  0 siblings, 0 replies; 25+ messages in thread
From: Reiner Steib @ 2008-11-01 18:47 UTC (permalink / raw)
  To: help-gnu-emacs

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/


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: some vi equivalents please?
       [not found]     ` <mailman.2646.1225559243.25473.help-gnu-emacs@gnu.org>
@ 2008-11-02 15:30       ` rustom
  2008-11-02 16:12         ` Drew Adams
       [not found]         ` <mailman.2710.1225642363.25473.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 25+ messages in thread
From: rustom @ 2008-11-02 15:30 UTC (permalink / raw)
  To: help-gnu-emacs

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


^ permalink raw reply	[flat|nested] 25+ messages in thread

* RE: some vi equivalents please?
  2008-11-02 15:30       ` rustom
@ 2008-11-02 16:12         ` Drew Adams
       [not found]         ` <mailman.2710.1225642363.25473.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 25+ messages in thread
From: Drew Adams @ 2008-11-02 16:12 UTC (permalink / raw)
  To: 'rustom', help-gnu-emacs

> > 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. ;-)





^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: some vi equivalents please?
       [not found]         ` <mailman.2710.1225642363.25473.help-gnu-emacs@gnu.org>
@ 2008-11-03  7:19           ` rustom
  2008-11-03  9:10             ` Drew Adams
  2008-11-03 16:24             ` Giorgos Keramidas
  0 siblings, 2 replies; 25+ messages in thread
From: rustom @ 2008-11-03  7:19 UTC (permalink / raw)
  To: help-gnu-emacs

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)


^ permalink raw reply	[flat|nested] 25+ messages in thread

* RE: some vi equivalents please?
  2008-11-03  7:19           ` rustom
@ 2008-11-03  9:10             ` Drew Adams
  2008-11-03 16:24             ` Giorgos Keramidas
  1 sibling, 0 replies; 25+ messages in thread
From: Drew Adams @ 2008-11-03  9:10 UTC (permalink / raw)
  To: 'rustom', help-gnu-emacs

> 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. ;-)







^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: some vi equivalents please?
  2008-11-03  7:19           ` rustom
  2008-11-03  9:10             ` Drew Adams
@ 2008-11-03 16:24             ` Giorgos Keramidas
  1 sibling, 0 replies; 25+ messages in thread
From: Giorgos Keramidas @ 2008-11-03 16:24 UTC (permalink / raw)
  To: help-gnu-emacs

On Sun, 2 Nov 2008 23:19:00 -0800 (PST), rustom <rustompmody@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' :)



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: some vi equivalents please?
  2008-10-31 15:08 some vi equivalents please? rustom
                   ` (5 preceding siblings ...)
       [not found] ` <mailman.2577.1225468814.25473.help-gnu-emacs@gnu.org>
@ 2008-11-05 13:41 ` Ken Goldman
  2008-11-06  7:08   ` rustom
  6 siblings, 1 reply; 25+ messages in thread
From: Ken Goldman @ 2008-11-05 13:41 UTC (permalink / raw)
  To: help-gnu-emacs

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


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: some vi equivalents please?
  2008-11-05 13:41 ` Ken Goldman
@ 2008-11-06  7:08   ` rustom
  2008-11-06 16:50     ` Drew Adams
  0 siblings, 1 reply; 25+ messages in thread
From: rustom @ 2008-11-06  7:08 UTC (permalink / raw)
  To: help-gnu-emacs

On Nov 5, 6:41 pm, Ken Goldman <kg...@watson.ibm.com> wrote:
> 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

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.


^ permalink raw reply	[flat|nested] 25+ messages in thread

* RE: some vi equivalents please?
  2008-11-06  7:08   ` rustom
@ 2008-11-06 16:50     ` Drew Adams
  2008-11-07 17:12       ` Johan Bockgård
  0 siblings, 1 reply; 25+ messages in thread
From: Drew Adams @ 2008-11-06 16:50 UTC (permalink / raw)
  To: 'rustom', help-gnu-emacs

> 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.





^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: some vi equivalents please?
  2008-11-06 16:50     ` Drew Adams
@ 2008-11-07 17:12       ` Johan Bockgård
  2008-11-07 17:38         ` Drew Adams
  0 siblings, 1 reply; 25+ messages in thread
From: Johan Bockgård @ 2008-11-07 17:12 UTC (permalink / raw)
  To: help-gnu-emacs

"Drew Adams" <drew.adams@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





^ permalink raw reply	[flat|nested] 25+ messages in thread

* RE: some vi equivalents please?
  2008-11-07 17:12       ` Johan Bockgård
@ 2008-11-07 17:38         ` Drew Adams
  0 siblings, 0 replies; 25+ messages in thread
From: Drew Adams @ 2008-11-07 17:38 UTC (permalink / raw)
  To: 'Johan "Bockgård"', help-gnu-emacs

> > 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.
;-)





^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2008-11-07 17:38 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-31 15:08 some vi equivalents please? rustom
2008-10-31 15:01 ` Toby Cubitt
2008-11-01 13:32   ` Kevin Rodgers
2008-11-01 18:47     ` Reiner Steib
2008-10-31 15:53 ` Teemu Likonen
2008-10-31 15:59 ` Drew Adams
2008-10-31 16:01 ` Parker, Matthew
2008-10-31 16:53 ` Giorgos Keramidas
2008-10-31 17:22   ` Joost Kremers
2008-10-31 17:34     ` Giorgos Keramidas
2008-10-31 22:49       ` Xah
     [not found] ` <mailman.2577.1225468814.25473.help-gnu-emacs@gnu.org>
2008-11-01 14:45   ` rustom
2008-11-01 14:52     ` rustom
2008-11-01 16:40       ` Giorgos Keramidas
2008-11-01 17:07     ` Drew Adams
     [not found]     ` <mailman.2646.1225559243.25473.help-gnu-emacs@gnu.org>
2008-11-02 15:30       ` rustom
2008-11-02 16:12         ` Drew Adams
     [not found]         ` <mailman.2710.1225642363.25473.help-gnu-emacs@gnu.org>
2008-11-03  7:19           ` rustom
2008-11-03  9:10             ` Drew Adams
2008-11-03 16:24             ` Giorgos Keramidas
2008-11-05 13:41 ` Ken Goldman
2008-11-06  7:08   ` rustom
2008-11-06 16:50     ` Drew Adams
2008-11-07 17:12       ` Johan Bockgård
2008-11-07 17:38         ` Drew Adams

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.