Skip to content

Instantly share code, notes, and snippets.

@billhance
Last active June 25, 2018 18:13
Show Gist options
  • Save billhance/43ab39b4a361ff89f37acd6b8c258cdc to your computer and use it in GitHub Desktop.
Save billhance/43ab39b4a361ff89f37acd6b8c258cdc to your computer and use it in GitHub Desktop.
Sublime Regexes

Sublime 2 Regexes

Tips

  • When dealing with files that have over 50k lines, avoid multi-select.
  • When doing a search/replace on a large file, do find all then replace all.

Beginning of line

^

End of line

$

Select first word of the line

^[^\s]*

Trailing Whitespace

[ \t]*$

Wildcard in between prefix and suffix

prefix[^*]*?suffix

Find duplicate lines and unique lines

  1. Sort the file so that all duplicates are on top of each other
  2. Run the following command to select all duplicates via a find, find all, replace or replace all.
^(.+)$\n^\1$
  1. If you cut the selection, you'll have all duplicates on your clipboard and all unique values will be left in the document.
  2. Select all the text and permute the result so that it removes all empty lines but one.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment