> (defun treesit-toggle-named-thing () > (interactive) > (setq-local treesit-sexp-type-regexp > (unless treesit-sexp-type-regexp #'treesit-node-named))) > > For the example above it toggles between moving to the > first character of 'if' and moving to the opening brace. Actually, it's better to toggle between the traditional behavior and navigation by the 'sexp' thing: (defun treesit-toggle-sexp-mode () (interactive) (setq-local treesit-sexp-type-regexp (unless treesit-sexp-type-regexp (if (treesit-thing-defined-p 'sexp nil) 'sexp #'treesit-node-named)) forward-sexp-function (if (eq treesit-sexp-type-regexp 'sexp) #'treesit-forward-sexp #'treesit-forward-sexp-list))) The only ts-mode where the 'sexp' thing is well defined is c-ts-mode with (sexp (not ,(rx (or "{" "}" "[" "]" "(" ")" ",")))) All other ts-modes contain desperate attempts to emulate the traditional behavior to navigate symbols with the 'sexp' thing. But symbol navigation is now implemented as the default behavior. So these ts-modes should be fixed based on the pattern in c-ts-mode. Then after toggling to the sexp mode they will navigate all ts nodes except nodes that define boundaries. Here is an example how such fix will look for ruby-ts-mode: