# How to make abbrev expand on symbol, not on word?

I have something like

(define-abbrev-table 'c++-mode-abbrev-table '(("string" "std::string" nil 0)))


in my .abbrev_defs. However, when I input to_string, the string still gets expanded into std::string results in to_std::string.

How to make abbrev treat the string in definition as a symbol thus expand it only when I input a symbol "string"?

Abbrev is about words, by default. The default expansion function uses function abbrev--before-point, which looks for word boundaries.
1. But you can define your own abbrev-expand-function. See node Abbrev Expansion.
2. Or if you set the syntax of character _ to word-constituent (w) instead of symbol-constituent (_) then the s in to_string will not be on a word boundary, so the default expansion will do what you want here. See the Elisp manual, node Syntax Class Table.