3 Quick Tricks for Programmers on Windows

Kevin Feng
5 min readJul 21, 2022
Certified Windows moment

This article is going to be pretty short (and the title is pretty self-explanatory), so I think we can skip the lengthy introduction and jump right into the tricks.

1. Frequent CMD user?

If you frequently use Command Prompt on Windows, then you might want to stop using that slow, and quite frankly, primitive technique you’ve always been doing. Next time, instead of searching for Command Prompt through the Windows search bar, try performing WIN + R (Windows key plus R) and hitting ENTER before you even see the Windows Run console come up. If the last thing you opened with Run was Command Prompt, it will open up at lightning fast speeds. If it wasn’t, then simply type in “cmd” into Windows Run and hit ENTER. Run will then remember that the last thing you opened using with it was Command Prompt, so the next time you execute this skillful technique, Command Prompt will open faster than you can say “I am a true Windows aficionado.”

2. VS Code Hack

I’m sure you all know that opening VS Code will, by default, open the glorified text editor (it’s not an IDE, fight me) in the directory that you last worked on. But what if you don’t want to work in the same directory anymore?

Well, you could navigate to the top left of the window like some type of ape and use the “open folder” function, or you could use this quick hack to open VS Code anywhere.

Just a simple, six-character command

First, open the folder that you want to open VS Code in. Next, in the file explorer’s address bar, type “cmd” to open an instance of Command Prompt. Now before you go on screeching about how this goes against the trick that was just mentioned previously, this opens an instance of Command Prompt at that specific directory — much faster than opening Command Prompt and then using cd to change directories.

Boom. VS Code opens.

In the Command Prompt window that opens, type this: code . and hit ENTER. And that’s it! VS Code will open at the directory from which code . was executed. This trick is particularly useful if you have tons of folders on your desktop that contain your project files (otherwise, it may be faster to just open VS Code and use the file explorer pop-up to navigate to your projects). This is because folders on your desktop are always just four inputs (or less) away. The order of inputs I usually use are as follows: WIN + D (jumps to desktop instantly; two inputs so far), double-click on the folder that you want to open (four total inputs), and you’re already in the Windows file explorer at the proper directory. From there, just follow the aforementioned trick to open VS Code at that specific folder. Here it is again in a neater version broken down into steps:

  1. Highlight the text in file explorer address bar
  2. Type “cmd” and hit ENTER
  3. Type code . in the Command Prompt window and hit ENTER

3. The Power of PowerShell

This one honestly blew my mind, and I only learned about it a few days ago. If you need to create a file with some text, you don’t actually need to open a text editor (like VS Code, cough cough). Instead, you can use the pipe operator (>>) in PowerShell to send the output of something like an echo statement to a text file. If that’s not clear, here’s an example:

Say you want to create a README file in a blank folder with some content in it. Maybe it has a header and a short sentence describing the project. Here’s what you can do using PowerShell:

This actually creates a file titled README.md in the current directory and pipes the echo output to that file, with no text editor entering the equation at any point! I would be careful with this one though because after using this a few times, I’ve noticed that the character formatting isn’t always perfect (something to do with non UTF-8 encoding). When I actually tried to run code after pasting in some code with this trick, Java didn’t like it and pointed out that there was something wrong with the text encoding.

This is perfectly fine for just pushing some code to GitHub, which is what I’ve been doing a lot of while working on LeetCode problems. You can also combine this trick with part of the previous one — navigate to the folder that you want to create a file in and replace the file explorer’s address bar with “powershell” and hit ENTER.

If you’re wondering what happens when you use this command and pipe the output to a file that already exists, it still adds the output to that file, so do be careful if you don’t want duplicate content or improperly formatted text.

This works with copy + pasting, so feel free to copy 70 lines of code and simply hit CTRL + V after echo ". Then close with another quote, the pipe operator, and whatever file you want to pipe the output to. If you want to have multiple lines of code typed directly into the terminal, simply perform SHIFT + ENTER every time you want a new line.

--

--