Changing Emacs Forward-Word Behaviour

Posted by gvkv on Stack Overflow See other posts from Stack Overflow or by gvkv
Published on 2009-11-20T15:14:36Z Indexed on 2010/04/02 9:43 UTC
Read the original article Hit count: 366

Filed under:
|

As the title says, how does one change the behaviour of emacs forward-word function? For example, suppose [] is the cursor. Then:

my $abs_target_path[]= abs_path($target);
<M-f>
my $abs_target_path = abs[_]path($target);

I know I could just use M-f M-b but as far as I'm concerned, that shouldn't be necessary and I'd like to change it. In particular, I want two things:

  1. When I press M-f, I want to go to the first character of the next word regardless of whether the point is within a word, within a group of spaces or somewhere else.
  2. Customize word-characters on a mode-by-mode basis. After all, moving around in CPerl mode is different than, say, TeX mode.

So, in the above example, item 1 would have the cursor would move to the 'a' (and the point to it's left) after hitting M-f. Item 2 would allow me to define underscores and sigils as word characters.

© Stack Overflow or respective owner

Related posts about emacs

Related posts about emacs23