Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • DSA
  • Practice Problems
  • Python
  • C
  • C++
  • Java
  • Courses
  • Machine Learning
  • DevOps
  • Web Development
  • System Design
  • Aptitude
  • Projects
Open In App
Next Article:
How to Create a File in CMD
Next article icon

How to Create a File in VSCode using Terminal?

Last Updated : 16 Oct, 2022
Comments
Improve
Suggest changes
Like Article
Like
Report

In a few cases touch or new-item or any other base keywords may not be used to create a file in vs code due to the absence of extensions, but using the following approach you can create and code any type of file with ease. In this article, you will learn about how to create a file with any file type extension in vs code using a terminal with commands. 

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. 

opening vs code
 

Step 2: Click on the Terminal and New Terminal, to open a terminal. or press ctrl + ` to open the terminal.

opening new terminal in vs code
 

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. 

using code keyword to create a new file in vs code using terminal
 
creating a .py file using code keyword in vs code, using terminal
 

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.

files are created in vs code using terminal
 

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"".

creating new file using echo keyword in vs code, using terminal
 

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.

files are created in vs code using terminal
 

Next Article
How to Create a File in CMD
author
jaysurya9
Improve
Article Tags :
  • How To

Similar Reads

  • How to Create a File in the Linux Using the Terminal?
    In this article, we will learn to create a file in the Linux/Unix system using the terminal. In the Linux/Unix system, there are the following ways available to creating files. Using the touch commandUsing the cat commandUsing redirection operatorUsing the echo commandUsing the heredocUsing the dd c
    4 min read
  • How to Open VS Code Using Terminal?
    Getting all your projects using a terminal is a new fun! Yes, you heard it right, you can access VS Code projects using the terminal, which is nothing but short and easy-to-remember commands. Starting VS code from the terminal provides a convenient and efficient way, especially for developers who ar
    4 min read
  • How to create an SRT file on Ubuntu?
    Creating an SRT file on Ubuntu is a straightforward process that allows you to add subtitles to your videos. SRT file creation on Ubuntu involves using text editors or specialized software to generate and format subtitle files in the SRT format. This guide will walk you through how to create an SRT
    4 min read
  • How to Create an Unnamed file in Windows?
    There is curiosity hidden inside everyone. So when it comes to computers we all try to know why this is happening, what will happen if I run this software, what will happen if I delete some of Windows files and etc. We also sometimes try to make a file without a name in Windows and fail and then, fi
    2 min read
  • How to Create a File in CMD
    We all know that one can easily create files using GUI options, but what if you can use a faster way to create files through the command-line interface? This is not a necessary but useful skill for anyone working with Windows. Whether you're automating tasks, working on scripts, or preferring using
    5 min read
  • How to Clone a Project From GitHub using VSCode?
    Cloning a project from GitHub is often the first step for developers looking to contribute to open-source projects or work collaboratively with their team. While there are various ways to clone a GitHub repository, using Visual Studio Code (VSCode) adds a layer of convenience and integration. In thi
    2 min read
  • How to Install Golang in VScode?
    GO is a compiled programming language developed by Robert Griesemer, Rob Pike, and Ken Thompson at Google. It was introduced in 2009 and is also known as golang. In this article, we are going to see how you can set up Visual Code Studio for Go language Development. We are going to install the necess
    3 min read
  • How to Install Git in VS Code?
    Git is a free and open-source distributed version control system. It is designed to manage every type of project even a small or a large project with good speed and efficiency. It is more focused on distributed development of software so that more developers can have the access to the source code an
    2 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
    6 min read
  • How to Create a New Branch on Github using Pycharm?
    Git is an open-source version control system. It means that whenever a developer develops some project (like an app or website) or something, he/she can constantly update, Git is a version control system that lets you manage and keep track of your source code history. Let’s say you have a project, a
    2 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences