[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How can I move my cursor 80 characters with a key binding?
From: |
Floyd L. Davidson |
Subject: |
Re: How can I move my cursor 80 characters with a key binding? |
Date: |
Sun, 25 Dec 2005 11:05:41 -0900 |
User-agent: |
gnus 5.10.6/XEmacs 21.4.15/Linux 2.6.5 |
"Scott Teresi (sent by Nabble.com)" <lists@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 <http://www.apaflo.com/floyd_davidson>
Ukpeagvik (Barrow, Alaska) floyd@apaflo.com