Home

Awesome

caser.vim

Easily change word casing with motions, text objects or visual mode.

This plugin is largely inspired by Tim Pope's vim-abolish, and aims to improve its casing functionality to better blend with Vim's editing philosophy.

Table of contents

  1. Installation
  2. Usage

Installation

vim-caser may be installed by any of your favourite plugin managers. Be it Pathogen, Vundle or Plug, use whichever you prefer.

For example, when using with Plug:

Plug 'arthurxavierx/vim-caser'

Usage

vim-caser makes it easy to convert between multiple word casings, from camelCase to snake_case to Title Case, it blends nicely with Vim's editing features such as motions, text objects and visual mode.

All mappings below must be followed by a motion or a text object, or be applied within visual mode.

CaseDefault MappingPlug Mapping (normal/visual)
MixedCase or PascalCasegsm or gsp<Plug>CaserMixedCase/<Plug>CaserVMixedCase
camelCasegsc<Plug>CaserCamelCase/<Plug>CaserVCamelCase
snake_casegs_<Plug>CaserSnakeCase/<Plug>CaserVSnakeCase
UPPER_CASEgsu or gsU<Plug>CaserUpperCase/<Plug>CaserVUpperCase
Title Casegst<Plug>CaserTitleCase/<Plug>CaserVTitleCase
Sentence casegss<Plug>CaserSentenceCase/<Plug>CaserVSentenceCase
space casegs<space><Plug>CaserSpaceCase/<Plug>CaserVSpaceCase
dash-case or kebab-casegs- or gsk<Plug>CaserKebabCase/<Plug>CaserVKebabCase
Title-Dash-Case or Title-Kebab-CasegsK<Plug>CaserTitleKebabCase/<Plug>CaserVTitleKebabCase
dot.casegs.<Plug>CaserDotCase/<Plug>CaserVDotCase

The gs prefix can be changed through the option g:caser_prefix. Alternatively, the default mappings can be disabled by setting g:caser_no_mappings.

Limitations

Currently vim-caser only supports the casing options displayed in the table above. If you would like to have another casing option in vim-caser, please feel free to create an issue in this repository, or to submit a pull request with the feature properly documented.

Global options

NameDefaultDescription
g:caser_prefixgsThe prefix of all mappings created by vim-caser. E.g.: gsc, gs-, gsu, etc.
g:caser_no_mappingsnot setSet to 1 to disable default mappings. Custom mappings can be set using the <Plug> mappings.