From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Hadron Quark Newsgroups: gmane.emacs.help Subject: Re: Hard to switch from vi Date: Tue, 10 Oct 2006 13:53:46 +0200 Message-ID: <87odskidyt.fsf@gmail.com> References: <874puejlc4.fsf@thalassa.informatimago.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1160484138 13112 80.91.229.2 (10 Oct 2006 12:42:18 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 10 Oct 2006 12:42:18 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Oct 10 14:42:15 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 1GXGvN-0003bq-3J for geh-help-gnu-emacs@m.gmane.org; Tue, 10 Oct 2006 14:41:33 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GXGvM-0007iC-MX for geh-help-gnu-emacs@m.gmane.org; Tue, 10 Oct 2006 08:41:32 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 153 Original-X-Trace: individual.net phcaH/3YG39AtXixdnaTJAyrjXmdLe+GZrvt7RS1DQ+9AiFqgV X-Orig-Path: news.ibm.net!news X-Face: 2h#||Cd#d%F*NCm59[_6/{1a@jy%; |j>{D~4^gKg(^i%7j0IK?+,/GmW&:CD5fEKb_! Cancel-Lock: sha1:/q+5tu9YYzJWFiL+WLhJbzXDXgs= Original-Xref: shelby.stanford.edu gnu.emacs.help:142342 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:37963 Archived-At: Pascal Bourguignon writes: > Wen Weng 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-... or C-u ... > > 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. :))))