In python mode, when I forward-word
. The cursor jumps from H
to d
(Hello_World). But in another mode(shell-mode
or c-mode
), the cursor jumps from H
to _
.
I want the result which i get in Python mode, even in the other mode. What should I do?
PS: I saw a similar question before, I have searched, but I could't find it.
I think you're looking for this:
(modify-syntax-entry ?_ "w")
Underscores will be treated as part of a word. This command will change the syntax table of the mode you're currently in. AFAIK there's no way to change syntax globally. However, you could try modifying the standard syntax table. Most major modes inherit the standard-syntax-table.
(modify-syntax-entry ?_ "w" standard-syntax-table)
If that doesn't work, I guess you have to add mode-hooks for all modes you're using and modify their syntax tables individually.
Things got a little simpler since Emacs 24.4. There's now a M-x superword-mode
that has the desired effect.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With