help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Hard to switch from vi


From: Hadron Quark
Subject: Re: Hard to switch from vi
Date: Tue, 10 Oct 2006 13:53:46 +0200

Pascal Bourguignon <pjb@informatimago.com> writes:

> Wen Weng <WenWeng@charter.net> writes:
>
>> Hi, I am a vi user for years and am now trying emacs.
>> I find it hard to get efficient. Can someone teach me some
>> commands?
>
> Emacs can do it itself.  The first thing emacs does, when you start
> it, is to display a screen that says:
>
> Welcome to GNU Emacs, one component of the GNU/Linux operating system.
>
> Get help           C-h  (Hold down CTRL and press h)
> Emacs manual       C-h r
> Emacs tutorial     C-h t           Undo changes     C-x u
> Buy manuals        C-h C-m         Exit Emacs       C-x C-c
> Browse manuals     C-h i
> Activate menubar   F10  or  ESC `  or   M-`
> (`C-' means use the CTRL key.  `M-' means use the Meta (or Alt) key.
> If you have no Meta key, you may instead type ESC followed by the character.)
>
>
>
> Then, type CTRL-h and t to get the tutorial that will teach you the
> basics. 
>
>
>> 1. In vi, to delete a line, I do, "dd" and to delete 5 lines, I do
>> "5dd". In emacs, how do I delete a complete line? C-k only delete
>> from cursor to the end of line. Adding a C-a is really too much work.
>
> C-k  
> C-k C-k 

This doesn't do what the OP wanted. He want C-a C-k.

>
> M-5 C-k
> C-u 5 C-k
> C-5 C-k   ; on X 
>
>
>> 2. Is there a repeat last command command like the dot command in vi?
>
> No.   But you can repeat any command by prefixing it with
> M-<digit>...  or C-u <digit>...
>
> If you have a group of commands that you might want to repeat, you can
> put them in a "keyboard macro", and invoke the keyboard macro.
>
> Type: M-x apropos RET kbd-macro RET
>
>
>> 3. In vi, to find a pairing brace I use the "%" command, is there a
>> command like thins in emacs?
>
> C-c , and C-c .   (backward-sexp and forward-sexp)

There are undefined in my snapshot emacs : its M-C-n and M-C-p

>
> Also, you can set the variable blink-matching-paren to true to have
> the pairing brace be highlighted automatically when the cursor passes
> over one of them.
>
> M-x set-variable RET blink-matching-paren RET t RET
>
> Or type in the *scratch* buffer:
>
> (setq blink-matching-paren t) C-x C-e
>
> If you want it always on, you can put the form:
>
>     (setq blink-matching-paren t)
>
> in your ~/.emacs file.

Doesn't work in this version I am posting from :( Just tried it on a c
file and a lisp file.

GNU Emacs 22.0.50.1 (i486-pc-linux-gnu, GTK+ Version 2.8.17) of
2006-08-24 on vernadsky, modified by Debian


>
>
> Also, most of the time you don't need to identify manually the
> matching parenthese, because you can manipulate the parenthesized
> blocks as wholes, using commands such as  kill-sexp (C-M-k).
>
> Imagine I want to exchange the then and else branches:
>
>        if(a==b){
>            printf("no");
>            a++;
>        }else{
>            printf("yes");
>            b--;
>        }
>
> I move on the first {, and type C-M-k
>
>        if(a==b)else{
>            printf("yes");
>            b--;
>        }
>
> then I move forward one word with M-f to reach the remaining {, and
> type C-y to yank the first branch there:
>
>        if(a==b)else{
>            printf("no");
>            a++;
>        }{
>            printf("yes");
>            b--;
>        }
>
>
> and I type C-M-K to kill the else branch, and type C-u 2 C-c ,
> to move at the beginning of the else.
>
>        if(a==b)else{
>            printf("no");
>            a++;
>        }
>
> then I type C-y to yank the else branch:
>
>        if(a==b){
>            printf("yes");
>            b--;
>        }else{
>            printf("no");
>            a++;
>        }

Sounds more complicated than mark, cut and replace :)

>
> There are also specialized minor mode to do even more structuring
> editing with some languages, like paredit-mode for lisp and scheme,
> where even more low level editing is done automatically.
>
>
>
>> 4. Should I really need to switch to emacs?
>
> This is highly advised.   

:))))
 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]