In TeX Mode, backward-word (M-b) stops when it encounters a backslash character (\).

For example, when the cursor point is after a \begin and I type M-b, the cursor point ends up between the \ (backslash character) and the b character, while I would like to have it before the backslash.

So to obtain this behaviour I tried the following, but it does not seems to be working. Any idea why?

(add-hook 'tex-mode-hook #'(lambda () (modify-syntax-entry ?\ "w")))

1 Answer 1


I finally found the answer, it was just me forgetting that \ is an escape character. The following works fine:

(add-hook 'tex-mode-hook #'(lambda () (modify-syntax-entry ?\\ "w")))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.