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:
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.
Try:
(require 'misc)
Then use M-x forward-to-word
and see if it does what you want. You can then rebind M-f
, etc.
To make the _
not a word separator (i.e. make it a word constituent) for C & C++ mode, you would do this:
(modify-syntax-entry ?_ "w" c-mode-syntax-table)
(modify-syntax-entry ?_ "w" c++-mode-syntax-table)
For more information on syntax tables, read this wiki page. Syntax tables are generally named like tex-mode-syntax-table
and cperl-mode-syntax-table
.