Mac – vim macro to convert CamelCase to lowercase_with_underscores

macrosvim

Is there a vim macro to convert CamelCase to lowercase_with_underscores and vice versa?

Best Answer

Tim Pope’s abolish.vim can convert among camelCase, MixedCase, snake_case, and UPPER_CASE, as well as convert (one-way) to dash-case.

Position the cursor on any of fooBar, FooBar, foo_bar, or FOO_BAR and use

  • crc to convert to fooBar
  • crm to convert to FooBar
  • cr_ or
    crs to convert to foo_bar
  • cru to convert to FOO_BAR
  • cr- to convert to foo-bar
Related Question