Skip to content
| Marketplace
Sign in
Visual Studio Code>Formatters>map-replace.js — Replace multi-selection text with custom JavaScript functionNew to Visual Studio Code? Get it now.
map-replace.js — Replace multi-selection text with custom JavaScript function

map-replace.js — Replace multi-selection text with custom JavaScript function

Yukai Huang

|
9,964 installs
| (8) | Free
Replace multi-selection text with custom JavaScript function
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

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

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft