Member-only story

Visual Studio Code Regex Search Cheat Sheet

A cheat sheet for searching in VS Code using regular expressions.

Lincoln W Daniel
ModernNerd Code
5 min readOct 31, 2024

--

Searching through your project’s source code in Visual Studio Code is easy. However, it can feel very limited if you’re not familiar with how to use its powerful regular expression (regex) search capabilities.

For that reason, in this article, I’m going to share with you some of the regex search queries I use for finding complex lines of code in my projects, especially when I’m working on a large refactor, as is the case right now. These are just the regex searches that have worked for me in my projects that run ManyStories.com and OurTransfers.com, so if you have your own, please share in the comments.

Just remember to toggle on the regex setting in the search input:

Find a variable that’s dot-accessed

You may have an variable that holds an object. From that object, you’ve accessed some number of fields, scattered across your app. Because that variable is globally defined, as is ill advised, you can’t rely on your editor to find it nor automatically refactor it to a new name. This is where this regex search query comes in handy.

Say you your variable is named myVariable and you access it via dot-notation like…

--

--

ModernNerd Code
ModernNerd Code

Published in ModernNerd Code

Learn to Code Life. Subscribe to Video Tutorials on Youtube

Lincoln W Daniel
Lincoln W Daniel

Written by Lincoln W Daniel

Chief Bull @ BullAcademy.org ® Elevating writers @ ManyStories.com. Author @JavaForHumans Ex: Editor in Chief MarkGrowth (acq.), Engineer @Medium @GoPuff

No responses yet