In LaTeX-mode (AUCTeX) buffers, the backslash "\" is treated as an escape character. I'd like it to be treated as word constituent (syntax class "w") instead, but only in LaTeX-mode buffers. The main reason is that it's more convenient for moving and deleting word-wise (M-f etc), including macros with their backslashes.
Some answers to questions like Treat symbols as words in prog modes suggest to use "superword-mode", but that doesn't work for me because it changes the underscore syntax, which is not what I want. Others suggest to use
(modify-syntax-entry ?\\ "w")
or
(modify-syntax-entry ?\\ "w" ***-mode-syntax-table)
at appropriate places in the initialization file, where "***" is the current mode.
Unfortunately the first solution changes the backslash syntax globally The first solution is buffer-local, as @Stefan pointed out, and it works if inserted in the LaTeX-mode hook. But the second doesn't work if I replace "***" with "latex", "tex", "LaTeX", or "TeX".
Any idea why the second command above is not working in latex-mode buffers? Cheers!
\w
,\<
to treat it as a word-constitutent, or because you wantM-f
orM-b
orM-C-b
or some other navigation command to jump to before/after rather than the reverse, ...). Note also that your first sample code does not necessarily change the syntax globally (it changes it in the table active in the current buffer when the code is executed).LaTeX-mode-syntax-table
.