From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: floyd@apaflo.com (Floyd L. Davidson) Newsgroups: gmane.emacs.help Subject: Re: How can I move my cursor 80 characters with a key binding? Date: Sun, 25 Dec 2005 11:05:41 -0900 Organization: __________ Message-ID: <87ek41j622.fld@apaflo.com> References: <2089451.post@talk.nabble.com> <20051225062518.GD9520@setzer.hsd1.tx.comcast.net> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1135541363 6392 80.91.229.2 (25 Dec 2005 20:09:23 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 25 Dec 2005 20:09:23 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Dec 25 21:09:20 2005 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 1EqcB8-0007Kz-56 for geh-help-gnu-emacs@m.gmane.org; Sun, 25 Dec 2005 21:09:14 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EqcCI-0005Xj-DU for geh-help-gnu-emacs@m.gmane.org; Sun, 25 Dec 2005 15:10:26 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!newsfeed.berkeley.edu!ucberkeley!sn-xit-02!sn-xt-sjc-08!sn-post-01!supernews.com!corp.supernews.com!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: gnus 5.10.6/XEmacs 21.4.15/Linux 2.6.5 Cancel-Lock: sha1:ZhQrC3IaSUf19nILnmRJlw4e3I4= Original-X-Complaints-To: abuse@supernews.com Original-Lines: 60 Original-Xref: shelby.stanford.edu gnu.emacs.help:136608 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:32227 Archived-At: "Scott Teresi (sent by Nabble.com)" wrote: >Well, that's great! The built-in key combination is almost good enough, but I think I might need >to do the custom key binding so that I can rapidly jump the cursor 80 characters, repeatedly. If I >have a line that takes up 10 lines on the screen (a paragraph of text, for instance), and I need >to get to the center of that paragraph, I'd have to jump forward several times to get there. (I >think the key binding would be easier for me than trying to guess exactly how many characters to >jump forward.) >Does anyone know an easier way to cursor around a very long line? I'm pretty frustrated with how I >can't simply hit the up arrow and move up to the previous line on the screen (which is actually >part of the same very long line), but it's an improvement over PICO which always adds a carriage >return at the edge of the screen. I use the Terminal program in Mac OS X which doesn't seem to >allow mouse input. >Thanks a lot for your help! Merry Christmas! >Scott I'm not positive, but it sounds like this might do what you want. Put this into your init file, ~/.emacs.el or whatever. (This works on either Emacs or XEmacs, but the init file would be named differently.) You can change the name of the function from "fld-jmp80" to anything you happen to like, but it is wise to pick a prefix that will never be used by any other module, just to avoid stepping on something else. Typicall the programer's initials or a prefix specifying the name of the module are used. This function can take an optional argument, but the default argument is 1. With the (default) argument of 1 it will move the cursor forward by 80 characters. With any other argument it will move the cursor backwards by 80 characters.. (defun fld-jmp80 (&optional fld-arg) "Move cursor forward or backward 80 characters. The default argument is 1, which moves characters forward, any other argument will move 80 characters backwards." (interactive "p") (let ((fld-cnt)) (setq fld-cnt -80) (if (eq 1 fld-arg) (setq fld-cnt 80)) (forward-char fld-cnt))) You will also want to bind this to a key sequence, such as a function key. Here are ways to bind this function to various keys. Choose a key sequency you like, and using one of these as an example, put a command into your init file to bind your function to your choise of keys. (global-set-key "\C-a" 'fld-jmp80) ;; Cntl-A (global-set-key "\C-x\C-a" 'fld-jmp80) ;; Cntl-X Cntl-A (define-key ctl-x-map "\C-a" 'fld-jmp80) ;; Cntl-X Cntl-A (define-key esc-map "a" 'fld-jmp80) ;; Esc A (global-set-key [(insert)] 'fld-jmp80) ;; "Insert" fkey (define-key global-map [f5] 'fld-jmp80) ;; F5 fkey -- Floyd L. Davidson Ukpeagvik (Barrow, Alaska) floyd@apaflo.com