How to Create a File in VSCode using Terminal?
Last Updated :
26 Jun, 2025
Sometimes, commands like touch
or New-Item
may not work as expected in VS Code due to environment limitations or missing shell extensions. However, using simple terminal commands, you can easily create and edit files of any type right from VS Code. , Let's learn how to create new files using the code
and echo
commands in the terminal.
Creating a File in VSCode using Terminal
There are primarily two methods to create a file in VSCode using the terminal, you can use the "Code" keyword to create a file, or you can use the "echo" keyword to create a new file.
Use the "Code" keyword
Step 1: Open the Visual Studio Code.
Step 2: Click on the Terminal and New Terminal, to open a terminal. or press ctrl + ` to open the terminal.
Step 3: A new terminal is opened. Go to the desired folder. Now use the following command to create a new file with any file extension type and also to write something or code in a file at your desired location path. Now, type "code filename.extension", to create the desired file, where filename is the name of the file you want to make, and .extension is the extension you want to provide to the file. For example, to create a .txt file, write "code samplefile.txt", and to create a .py file, write "code sumTwoNum.py". Now, you can do "ls" to view all the files in the current directory.
Step 4: The file has been created. Write some text in the file as a sample and save your file. Use Ctrl + S to save the file.
Use "echo" keyword
Step 1: Open Visual Studio Code. Go to the desired location, where you want to create a file. Now use the following command to create a new file with any file extension type and also to write something or code in a file at your desired location path. Now, type "echo > "filename.extension"", to create the desired file, where filename is the name of the file you want to make, and .extension is the extension you want to provide to the file. For example, to create a .txt file, write "echo > "gfg.txt"", and to create a .py file, write "echo > "gfg.py"".
Step 2: The file has been created. Write some text in the file as a sample and save your file. Use Ctrl + S to save the file.
Similar Reads
How to Create Any File Using CMD: Learn 5 Methods Creating a file using Windows GUI is quite simple but did you know you can do the same using the Command Prompt (CMD)? This guide will walk you through multiple methods to create files directly from CMD, giving you more control and efficiency in managing your system.How to Create a File in CMDMethod
4 min read
How to Open Visual Studio Code Using Terminal Did you know you can launch Visual Studio Code directly from your terminal? It's quick, efficient, and makes coding workflows much smoother. In this guide, we'll show you how to set it up on both Windows and macOS.How to Open VS Code From Terminal?To open VS Code, you need to make sure VS Code is in
3 min read
How Do I Disable VS Code of Updating Itself? Visual Studio Code is a powerful and popular code editor that frequently receives updates to improve functionality and security. However, these automatic updates might not always be convenient, especially if you prefer to control when your tools are updated. If you're looking to disable VS Code auto
5 min read
How to Edit Text Files in Linux: Proven 3 Methods Need to tweak a file in Linux but not sure where to start? Editing text files in Linux is a handy skill that can help you fix settings, write scripts, or just note down notes all from your keyboard. This blog is here to help you get started, even if youâre new to Linux. Weâll show you simple ways to
4 min read
How To Add Extensions in VS Code? Visual Studio Code is a lightweight but powerful source code editor that runs on your desktop and is available for Windows, macOS, and Linux. It comes with built-in support for JavaScript, TypeScript, and Node.js and has a rich ecosystem of extensions for other languages and runtimes (such as C++, C
3 min read
How to Install Xcode Command Line Tools? Xcode has a bundle of tools, used for development by developers to build apps for Apple platforms. Xcode also, easily lets the user manage the entire development workflow, creating the app, testing the app, optimizing the app, and submitting it to the App Store. Xcode is an IDE(Integrated Developmen
5 min read