Skip to content

Instantly share code, notes, and snippets.

@elcoreman
Last active February 3, 2023 17:43
Show Gist options
  • Save elcoreman/73fa5a423e12a4ed1e31a5f054b39bfd to your computer and use it in GitHub Desktop.
Save elcoreman/73fa5a423e12a4ed1e31a5f054b39bfd to your computer and use it in GitHub Desktop.
Convert all px values to rem in sass style files by Regex

type ctrl+h on VsCode

On Find input insert:

\s(-*[1-9]\d*)px

On Replace input insert:

rem($1)

All your px values will convert to rem(px)
considering rem() as Sass function:

@function rem($pxsize) {
  @return math.div($pxsize, 14) * 1rem;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment