vimtricks.wiki Concise Vim tricks, one at a time.

How do you record a macro to convert camelCase to snake_case?

Answer

qa/[A-Z]\ni_<Esc>l~q

Explanation

Record a macro that finds the next uppercase letter, inserts an underscore before it, and lowercases it. Converts camelCase identifiers.

Next

How do you yank a single word into a named register?