all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How can I do these in Emacs?
@ 2003-04-19  5:53 wang yin
  2003-04-19  7:46 ` Alan Mackenzie
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: wang yin @ 2003-04-19  5:53 UTC (permalink / raw)


Hi! I'm new to Emacs. I'm used to use VIM.  But I decided to enjoy the
Emacs world.

I don't know how to do something that's simple in VIM.  I hope I can
get help here.

1. How can I do something like a "o" command in vi with Emacs?  I
   always C-e to the end of the line and press RET.  Are there any
   faster ways?

2. How can I go to start or end of the if {...} block when the pointer
   is inside the block?

for example:

	if (w->backref != NOBACKREF) {
		WFhash[w->backref] = NULL;
-----> <pointer here>	
                w->backref = NOBACKREF;
	}

Thanks.

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

* Re: How can I do these in Emacs?
  2003-04-19  5:53 How can I do these in Emacs? wang yin
@ 2003-04-19  7:46 ` Alan Mackenzie
  2003-04-19  7:57 ` Pascal Bourguignon
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 12+ messages in thread
From: Alan Mackenzie @ 2003-04-19  7:46 UTC (permalink / raw)


wang yin <wy@wanglab.com> wrote on 19 Apr 2003 13:53:56 +0800:
> Hi! I'm new to Emacs. I'm used to use VIM.  But I decided to enjoy the
> Emacs world.

Excellent!  There is plenty to enjoy.

> I don't know how to do something that's simple in VIM.  I hope I can
> get help here.

> 1. How can I do something like a "o" command in vi with Emacs?  I
>    always C-e to the end of the line and press RET.  Are there any
>    faster ways?

Not really.  Vim's o command can also be slow, though, since you often
have to press <ESC> first.  Or, it can be even slower if you forget the
<ESC>, the you end up pressing "o <ESC> u o".  ;-(

However, there is nothing to stop you writing a simple command (in Emacs
lisp) or a keyboard macro which would do exactly what you want.  C-o
would be a good key to bind this to.

> 2. How can I go to start or end of the if {...} block when the pointer
>    is inside the block?

> for example:

> 	if (w->backref != NOBACKREF) {
> 		WFhash[w->backref] = NULL;
> -----> <pointer here>	
>                 w->backref = NOBACKREF;
> 	}

C-M-u.  u stands for "up" here.  Play around with C-M-n and C-M-p, too.
They move forward and backwards over bracketed expressions.

The best way of discovering these things is in the emacs info pages,
though you've probably found these already.  In case you haven't, type:

C-h i       to get to info
m emacs     to select the emacs manual
Move the cursor down to line 75 (more or less).  There you'll see a menu
item "* Programs".  Go into this with <CR> and spend a few hours reading
the contents.  The bit about C-M-u is in the "Parentheses" item.

Have fun!

-- 
Alan Mackenzie (Munich, Germany)
Email: aacm@muuc.dee; to decode, wherever there is a repeated letter
(like "aa"), remove half of them (leaving, say, "a").

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

* Re: How can I do these in Emacs?
  2003-04-19  5:53 How can I do these in Emacs? wang yin
  2003-04-19  7:46 ` Alan Mackenzie
@ 2003-04-19  7:57 ` Pascal Bourguignon
  2003-04-19 14:39   ` Jiri Pejchal
  2003-04-19  8:08 ` Eli Zaretskii
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 12+ messages in thread
From: Pascal Bourguignon @ 2003-04-19  7:57 UTC (permalink / raw)


wang yin <wy@wanglab.com> writes:

> Hi! I'm new to Emacs. I'm used to use VIM.  But I decided to enjoy the
> Emacs world.
> 
> I don't know how to do something that's simple in VIM.  I hope I can
> get help here.
> 
> 1. How can I do something like a "o" command in vi with Emacs?  I
>    always C-e to the end of the line and press RET.  Are there any
>    faster ways?

(defun open-line-a-la-vi ()
    (interactive)
    (forward-line)
    (open-line (or prefix-arg 1)))
(global-set-key "\C-o" 'open-line-a-la-vi)


> 2. How can I go to start or end of the if {...} block when the pointer
>    is inside the block?

See functions  up-list, forward-list, backward-list.   The terminology
is lisp, but  they work correcly in other  syntaxes too.  For example,
beginning-of-defun moves to  the beginning of the function  in C mode,
where there is no defun like in lisp.

You can attach them or a combination of the to a key  like above.

> for example:
> 
> 	if (w->backref != NOBACKREF) {
> 		WFhash[w->backref] = NULL;
> -----> <pointer here>	
>                 w->backref = NOBACKREF;
> 	}
> 
> Thanks.
 

-- 
__Pascal_Bourguignon__                   http://www.informatimago.com/
----------------------------------------------------------------------
Do not adjust your mind, there is a fault in reality.

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

* Re: How can I do these in Emacs?
  2003-04-19  5:53 How can I do these in Emacs? wang yin
  2003-04-19  7:46 ` Alan Mackenzie
  2003-04-19  7:57 ` Pascal Bourguignon
@ 2003-04-19  8:08 ` Eli Zaretskii
  2003-04-19 19:08 ` Stefan Monnier
       [not found] ` <mailman.4924.1050736232.21513.help-gnu-emacs@gnu.org>
  4 siblings, 0 replies; 12+ messages in thread
From: Eli Zaretskii @ 2003-04-19  8:08 UTC (permalink / raw)


> From: wang yin <wy@wanglab.com>
> Newsgroups: gnu.emacs.help
> Date: 19 Apr 2003 13:53:56 +0800
> 
> 1. How can I do something like a "o" command in vi with Emacs?  I
>    always C-e to the end of the line and press RET.  Are there any
>    faster ways?

Is "C-o" what you want (I don't really know what does "o" do in vi)?

> 2. How can I go to start or end of the if {...} block when the pointer
>    is inside the block?

"M-C-u" goes to the start of the block; to go to the end, follow
"M-C-u" by "M-C-f".

This works for _any_ block, not just an `if'.

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

* Re: How can I do these in Emacs?
  2003-04-19  7:57 ` Pascal Bourguignon
@ 2003-04-19 14:39   ` Jiri Pejchal
  0 siblings, 0 replies; 12+ messages in thread
From: Jiri Pejchal @ 2003-04-19 14:39 UTC (permalink / raw)


Pascal Bourguignon <spam@thalassa.informatimago.com> writes:

> > 1. How can I do something like a "o" command in vi with Emacs?  I
> >    always C-e to the end of the line and press RET.  Are there any
> >    faster ways?
> 
> (defun open-line-a-la-vi ()
>     (interactive)
>     (forward-line)
>     (open-line (or prefix-arg 1)))
> (global-set-key "\C-o" 'open-line-a-la-vi)

Thanks! That's cool.

What about this:
(defun open-line-a-la-vi ()             
     (interactive)              
     (forward-line)
     (open-line (or prefix-arg 1))
     (indent-according-to-mode))   ;;and indent too
(global-set-key "\C-o" 'open-line-a-la-vi)

Jiri Pejchal

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

* Re: How can I do these in Emacs?
  2003-04-19  5:53 How can I do these in Emacs? wang yin
                   ` (2 preceding siblings ...)
  2003-04-19  8:08 ` Eli Zaretskii
@ 2003-04-19 19:08 ` Stefan Monnier
  2003-04-19 19:32   ` David Kastrup
       [not found] ` <mailman.4924.1050736232.21513.help-gnu-emacs@gnu.org>
  4 siblings, 1 reply; 12+ messages in thread
From: Stefan Monnier @ 2003-04-19 19:08 UTC (permalink / raw)


> Hi! I'm new to Emacs. I'm used to use VIM.  But I decided to enjoy the
> Emacs world.

You might also want to try M-x viper-mode RET.
It's supposed to be pretty good.


        Stefan

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

* Re: How can I do these in Emacs?
  2003-04-19 19:08 ` Stefan Monnier
@ 2003-04-19 19:32   ` David Kastrup
  2003-04-19 21:40     ` Stefan Monnier
  0 siblings, 1 reply; 12+ messages in thread
From: David Kastrup @ 2003-04-19 19:32 UTC (permalink / raw)


"Stefan Monnier" <monnier+gnu.emacs.help/news/@flint.cs.yale.edu> writes:

> > Hi! I'm new to Emacs. I'm used to use VIM.  But I decided to enjoy
> > the Emacs world.
> 
> You might also want to try M-x viper-mode RET.  It's supposed to be
> pretty good.

That's like enjoying the Far East cuisine by booking a ticket to Hong
Kong and arranging for visiting all available MacDonalds restaurants
during the stay.

I'd recommend to _first_ emerge yourself fully into the Emacs world
(using tutorials and the reference sheets), and when, after
considerable consideration, you still find yourself throwing up
regularly, _then_ you might try the local MadDonalds aka viper-mode
and be reasonably sure that you don't miss out on much that you could
digest.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: How can I do these in Emacs?
  2003-04-19 19:32   ` David Kastrup
@ 2003-04-19 21:40     ` Stefan Monnier
  2003-04-22  0:20       ` Jason Earl
  0 siblings, 1 reply; 12+ messages in thread
From: Stefan Monnier @ 2003-04-19 21:40 UTC (permalink / raw)


>> You might also want to try M-x viper-mode RET.  It's supposed to be
>> pretty good.
> That's like enjoying the Far East cuisine by booking a ticket to Hong
> Kong and arranging for visiting all available MacDonalds restaurants
> during the stay.

[ I had started writing the paragraph below and then figured it wasn't
  worth the trouble.  Oh well! ]

AFAIK viper-mode is not just "A pill to make Emacs acceptable to those who
like VI".  I know several hardcore Emacs users who swear by viper-mode.
Some of them had never even used vi before.


        Stefan "who doesn't use viper-mode"

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

* Re: How can I do these in Emacs?
       [not found] ` <mailman.4924.1050736232.21513.help-gnu-emacs@gnu.org>
@ 2003-04-21 17:36   ` David Masterson
  2003-04-21 20:49     ` Kevin Rodgers
  0 siblings, 1 reply; 12+ messages in thread
From: David Masterson @ 2003-04-21 17:36 UTC (permalink / raw)


>>>>> Eli Zaretskii writes:

>> From: wang yin <wy@wanglab.com>

>> 1. How can I do something like a "o" command in vi with Emacs?  I
>> always C-e to the end of the line and press RET.  Are there any
>> faster ways?

> Is "C-o" what you want (I don't really know what does "o" do in vi)?

It opens a new line after the current line ("O" opens before the
current line) regardless of where you are in the line whereas "C-o"
(in emacs) splits the line at the current point.

-- 
David Masterson                David DOT Masterson AT synopsys DOT com
Sr. R&D Engineer               Synopsys, Inc.
Software Engineering           Sunnyvale, CA

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

* Re: How can I do these in Emacs?
  2003-04-21 17:36   ` David Masterson
@ 2003-04-21 20:49     ` Kevin Rodgers
  0 siblings, 0 replies; 12+ messages in thread
From: Kevin Rodgers @ 2003-04-21 20:49 UTC (permalink / raw)


David Masterson wrote:

>>>>>>Eli Zaretskii writes:
>>>>>>
> 
>>>From: wang yin <wy@wanglab.com>
>>>
> 
>>>1. How can I do something like a "o" command in vi with Emacs?  I
>>>always C-e to the end of the line and press RET.  Are there any
>>>faster ways?
>>>
> 
>>Is "C-o" what you want (I don't really know what does "o" do in vi)?
>>
> 
> It opens a new line after the current line ("O" opens before the
> current line) regardless of where you are in the line whereas "C-o"
> (in emacs) splits the line at the current point.


(defadvice open-line (before a-la-vi activate)
   "When called interactively, open the new line after the current line (like vi)."
   (if (interactive-p)
       (end-of-line)))

-- 
<a href="mailto:&lt;kevin.rodgers&#64;ihs.com&gt;">Kevin Rodgers</a>

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

* Re: How can I do these in Emacs?
  2003-04-19 21:40     ` Stefan Monnier
@ 2003-04-22  0:20       ` Jason Earl
  2003-04-22 14:16         ` Stefan Monnier
  0 siblings, 1 reply; 12+ messages in thread
From: Jason Earl @ 2003-04-22  0:20 UTC (permalink / raw)


"Stefan Monnier" <monnier+gnu.emacs.help/news/@flint.cs.yale.edu> writes:

>>> You might also want to try M-x viper-mode RET.  It's supposed to be
>>> pretty good.
>> That's like enjoying the Far East cuisine by booking a ticket to Hong
>> Kong and arranging for visiting all available MacDonalds restaurants
>> during the stay.
>
> [ I had started writing the paragraph below and then figured it wasn't
>   worth the trouble.  Oh well! ]
>
> AFAIK viper-mode is not just "A pill to make Emacs acceptable to those who
> like VI".  I know several hardcore Emacs users who swear by viper-mode.
> Some of them had never even used vi before.
>
>
>         Stefan "who doesn't use viper-mode"

viper-mode combines the typist-friendly keystrokes of vi with the
goodness and power of Emacs.  Don't get me wrong, I don't mind hitting
Control-Alt-Cokebottle-Esc to use some of Emacs' more esoteric
features, but for sheer text editting it is really hard to beat vi.

I *started* as a straight Emacs user, but I learned a little vi
because it was useful for sysadmin tasks.  Now I have the best of both
worlds, viper-mode rocks.

Jason

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

* Re: How can I do these in Emacs?
  2003-04-22  0:20       ` Jason Earl
@ 2003-04-22 14:16         ` Stefan Monnier
  0 siblings, 0 replies; 12+ messages in thread
From: Stefan Monnier @ 2003-04-22 14:16 UTC (permalink / raw)


> viper-mode combines the typist-friendly keystrokes of vi with the
> goodness and power of Emacs.

You forgot to mention that it was made without harming any animal,
guaranteed 100% GMO-free and organic.


        Stefan

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

end of thread, other threads:[~2003-04-22 14:16 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-04-19  5:53 How can I do these in Emacs? wang yin
2003-04-19  7:46 ` Alan Mackenzie
2003-04-19  7:57 ` Pascal Bourguignon
2003-04-19 14:39   ` Jiri Pejchal
2003-04-19  8:08 ` Eli Zaretskii
2003-04-19 19:08 ` Stefan Monnier
2003-04-19 19:32   ` David Kastrup
2003-04-19 21:40     ` Stefan Monnier
2003-04-22  0:20       ` Jason Earl
2003-04-22 14:16         ` Stefan Monnier
     [not found] ` <mailman.4924.1050736232.21513.help-gnu-emacs@gnu.org>
2003-04-21 17:36   ` David Masterson
2003-04-21 20:49     ` Kevin Rodgers

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.