[Top][All Lists]

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

Re: Changing M-f behavior

From: Ehud Karni
Subject: Re: Changing M-f behavior
Date: Sun, 29 Oct 2000 17:38:36 +0200

On Sat, 28 Oct 2000 16:35:31 -0700, Todd Wells <> wrote:
> I'd like to change M-f so that when it goes forward a word, the cursor lands
> on the first letter of the word instead of on the blank space before the
> word, in the same way as M-b lands on the first letter of the word.  How can
> I do this?
First, M-f (forward-word) lands on the 1st character that is not word
syntax AFTER the word (not BEFORE).

You can redefine it (which I strongly against) or you can define your
own functions and assign whatever key (even M-f to it).

Here are 2 examples of function that work the way you want (please note
that they work on any non space, not just word syntax [\w] characters).

(defun backward-to-non-blank () "go to 1st non blank (after blank) to left"
       (if (re-search-backward "[ \t\n][^ \t\n]" (point-min) t)
           (forward-char 1)
           (if (string-match "[^ \t\n]" (buffer-substring 1 2))
               (goto-char (point-min)))))

(defun forward-to-non-blank () "go to 1st non blank (after blank) to right"
       (if (re-search-forward "[ \t\n][^ \t\n]" (point-max) t)
           (backward-char 1)))next


 @@@@@@ @@@ @@@@@@ @    @   Ehud Karni  Simon & Wiesel  Insurance agency
     @    @      @  @@  @   Tel: +972-3-6212-757    Fax: +972-3-6292-544
     @    @ @    @ @  @@    (USA)  Fax  and  voice  mail:  1-815-5509341
     @    @ @    @ @    @        Better     Safe     Than     Sorry

reply via email to

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