Hello_World is a word in Python, it differs in a different mode. How do I change it?

In python mode, when I forward-word . The cursor moves from H to d (Hello_World). But in another mode ( shell-mode or c-mode ), the cursor moves from H to _ .

I want to get the result that I get in Python mode, even in another mode. What should I do?

PS: I saw a similar question before, I searched, but I could not find it.

+6
source share
2 answers

I think you are looking for this:

 (modify-syntax-entry ?_ "w") 

Underscore will be considered part of the word. This command will change the syntax table in the mode you are currently in. AFAIK there is no way to change syntax globally. However, you can try changing the standard syntax table. Most major modes inherit a standard syntax table.

 (modify-syntax-entry ?_ "w" standard-syntax-table) 

If this does not work, I think you need to add hook modes for all the modes you use and change their syntax tables separately.

+6
source

Everything has become a little easier since Emacs 24.4. Now there is Mx superword-mode , which has the desired effect.

+2
source

Source: https://habr.com/ru/post/948784/