From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Pascal Bourguignon Newsgroups: gmane.emacs.help Subject: Re: Hard to switch from vi Date: Mon, 09 Oct 2006 04:04:43 +0200 Organization: Informatimago Message-ID: <874puejlc4.fsf@thalassa.informatimago.com> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1160361723 27805 80.91.229.2 (9 Oct 2006 02:42:03 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 9 Oct 2006 02:42:03 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Oct 09 04:41:58 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 1GWl5U-00026l-4S for geh-help-gnu-emacs@m.gmane.org; Mon, 09 Oct 2006 04:41:52 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GWl5T-0006u5-Jr for geh-help-gnu-emacs@m.gmane.org; Sun, 08 Oct 2006 22:41:51 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!newsfeed.gamma.ru!Gamma.RU!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 142 Original-X-Trace: individual.net XAsOe8YcVAYiT4eF177PawZSX3WASQLgX+5GjB0AnMGvJ4iUDh Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en X-Disabled: X-No-Archive: no User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) Cancel-Lock: sha1:U3wWTWkMSuUMJzgAG2IKTcjkvOU= Original-Xref: shelby.stanford.edu gnu.emacs.help:142288 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:37907 Archived-At: 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 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) 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. 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++; } 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. -- __Pascal Bourguignon__ http://www.informatimago.com/ ADVISORY: There is an extremely small but nonzero chance that, through a process known as "tunneling," this product may spontaneously disappear from its present location and reappear at any random place in the universe, including your neighbor's domicile. The manufacturer will not be responsible for any damages or inconveniences that may result.