polymorph

Simultaneously edit multiple text ranges with related meanings, but different forms.

halohalospecial

381

6

2.2.3

MIT

GitHub

Polymorph

Simultaneously edit multiple text ranges with related meanings, but different forms.

Screenshots

Easier to explain with screenshots! 😃

case1

case2

redux

cardinality

verb-form

color

inverse

xml

Commands

Polymorph: Mark Next In Any Case And Form

Marks the next text range which has a related meaning with the active selection, but has a different letter case or form. If nothing is selected, this will select the longest "superword" under the cursor. Invoke this multiple times to mark the next matching text ranges, similar to Find And Replace: Select Next. Editing the source text range will also edit the marked ranges. Press escape when you're done.

Polymorph: Skip Last Marked

Unmarks the last marked text range. Invoking Polymorph: Mark Next In Any Case And Form again will mark the next matching text range, skipping the unmarked one. This command is useful if Polymorph marked an incorrect text range.

skip

Polymorph: Select All Marked

Selects all marked text ranges.

select-marked

Polymorph: Case Preserving Paste

Use this instead of Core: Paste to coerce the case of the pasted text into the case of the target selection. For example, if the copied text is "mark-next-in-any" and the target selection is "casePreservingPaste", the pasted text will become "markNextInAny" because the target is in camel case.

paste

Forced Transformation Commands

These commands work on selections and ranges marked by Polymorph.

Example keybindings

'atom-text-editor':
  'cmd-e': 'polymorph:mark-next-in-any-case-and-form'
  'shift-cmd-e': 'polymorph:skip-last-marked'
  'ctrl-e': 'polymorph:select-all-marked'
  'shift-cmd-v': 'polymorph:case-preserving-paste'

Credits

Uses nlp_compromise and tinycolor2.

Prior Art

After some searching, the closest I could find is abolish.vim by Tim Pope. That vim plugin lets you replace text by specifying some rules (e.g. :%Subvert/facilit{y,ies}/building{,s}/g to replace all instances of "facility" with "building" and "facilities" with "buildings").

Polymorph attempts to figure out the rules instead, making it less precise, but more magical.