Reputation: 12249
One thing I hate about emacs is the default word movement. The following is an example of where I want M-f
to stop (M-b
should stop at the same stops):
MyFoo myVar = obj->member.my_func(int some_arg);
^ ^ ^ ^ ^ ^ ^ ^ ^^ ^^ ^^ ^ ^^ ^
I'm using Emacs 24.3.1 with Emacs Prelude. I have half of the solution with subword-mode
, which properly handles camel case, and the other half with binding M-f
to evil-forward-word-begin
, which properly handles all of the non-camel case stops in the example above. Merging the two solutions would be ideal, but subword-mode
has no effect on evil-forward-word-begin
.
I've also tried modifying the syntax table and using forward-to-word
instead of the default forward-word
and combining that with subword mode, but 1) that plain didn't work (symbols that I added were still skipped; maybe I did it wrong?), 2) I'd have to add a ton of symbols that are already working fine with evil-forward-word-begin
, and 3) It would only apply to the syntax table of one language, where I'd like this functionality globally.
Also, I'd like M-d
(kill-word
) and M-DEL
(backword-kill-word
) to also delete to the stops in the example above.
I've been trying to solve this problem for a while, and I've asked everywhere, including the emacs and evil-mode IRC channels, but I haven't been able to find a solution. Getting this type of word movement would be a huge boost to my productivity.
Upvotes: 2
Views: 767
Reputation: 48823
Something similar:
(eval-after-load 'cc-mode
'(loop for ch from ?A to ?Z by 1
do (modify-syntax-entry ch "." java-mode-syntax-table)))
Upvotes: 0
Reputation: 9427
My syntax-subword mode does almost exactly what you want.
MyFoo myVar = obj->member.my_func(int some_arg);
^ ^ ^^ ^ ^^^^ ^ ^ ^^ ^^ ^^ ^^ ^^ ^
Upvotes: 3
Reputation: 73274
I'd suggest defining functions to assign to the subword-forward-function
and subword-backward-function
variables, which check the current situation and then either call the evil function, or the default subword function.
If you're moving forwards, you can use looking-at
to make the decision; backwards, use looking-back
.
Upvotes: 1