Skip to content

Instantly share code, notes, and snippets.

@predorock
Last active September 5, 2022 09:22
Show Gist options
  • Save predorock/bbebcd3a7bb3900cae3c3d7fec1b1e1f to your computer and use it in GitHub Desktop.
Save predorock/bbebcd3a7bb3900cae3c3d7fec1b1e1f to your computer and use it in GitHub Desktop.
RegEx to replace relative imports to absolute imports in vscode
// pseudo code
const alias = 'environment'
(?<=from)((?!\'\.\/).)*?(?=alias)
or
(\.\.\/)+(?=alias)
//NOTE: I'am working with an angular cli project. So do the refactoring module by module in case you have to fix some issues due to import replacement
//instructions
- put the regular expression in the vs code replace input
- select the regular expression matching mode
- include only .ts files (for angular cli project 'src/app/**/*.ts')
- press enter to search all occourences an replace them with your new alias
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment