Skip to content

Instantly share code, notes, and snippets.

@sun
Last active January 30, 2020 13:53
Show Gist options
  • Save sun/1a0f5c65df3d01fe5e1d to your computer and use it in GitHub Desktop.
Save sun/1a0f5c65df3d01fe5e1d to your computer and use it in GitHub Desktop.
vim
# Replace `define('...', '...');` with `const ... = ...;`
:%s/define( *'\(\w*\)',\( *\)'\([^']*\)' *);/const \1 =\2'\3';/
# Replace `isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] :` with `$_SERVER['SERVER_NAME'] ??`
# Using different delimiters to match an underscore literally.
:%s!isset.*SERVER_NAME.*:!$_SERVER['SERVER_NAME'] ??!
# Convert line endings to Linux/Unix
:set ff=unix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment