Skip to content

Yukaii/map-replace.js

Repository files navigation

map-replace.js for VSCode

Replace selected string with custom JavaScript function.

Visual Studio Marketplace VS Installs VS Rating

Features

gif

Examples

const things = [
  'Thing',
  'Thing',
  'Thing',
  'Thing',
  'Thing',
  'Thing',
  'Thing',
]

Make selections on all Thing strings, call the command and enter custom transform function:

(value, index) => `${value} #${index}`

Then generates:

const things = [
  'Thing #0',
  'Thing #1',
  'Thing #2',
  'Thing #3',
  'Thing #4',
  'Thing #5',
  'Thing #6',
]

Credits

Idea from @zetavg

License

MIT