jiamijiang
jiamijiang

Reputation: 95

How to create a file in the terminal of VSC?

I know how to create a folder in the terminal of vsc mkdir NameOfFolder, but how to create a file in the terminal?

Upvotes: 4

Views: 32195

Answers (9)

Doan Chung
Doan Chung

Reputation: 1

  • create file : echo $null > File.txt
  • delete file : Remove-Item -Path "File.txt" -Force
  • Create a single folder : New-Item -Path "Folder_Name" -ItemType Directory

Upvotes: 0

Moses Oteng
Moses Oteng

Reputation: 1

On Windows Powershell, use New-Item -Path . -Name "testfile1.txt". This creates a text file that is named testfile1.txt. You can also check out the Microsoft website for more information.

Upvotes: 0

Bas
Bas

Reputation: 598

$ touch example.py (if using bash)

echo "# This is an example PowerShell script" > example.py (if using PowerShell)

Upvotes: 1

zwilso1
zwilso1

Reputation: 21

ni filename.txt

This worked for me on Windows VSC.

Upvotes: 2

adit70
adit70

Reputation: 11

Once you are in the desired directory in VSCode terminal, use touch file_name.file_extension Eg: touch README.md. It works just like LINUX.

Upvotes: 1

Diana V
Diana V

Reputation: 1

you can also use : ni filename.thx

Upvotes: -2

Valdas Stonkus
Valdas Stonkus

Reputation: 549

Just type square bracket ">" and name in the bash terminal of VScode:

> fileName.txt

Upvotes: -1

Chopins_left_hand
Chopins_left_hand

Reputation: 136

You can also use:

code filename.filetype

This also works with directories

code app/program.py

This wil open the new file in te editor (if the filetype allows it) and then you can just save it.

Upvotes: 10

Aremu Matthew
Aremu Matthew

Reputation: 142

Ctrl + ` to open the terminal in Visual Studio Code.

echo > "File.txt" to create a new .txt file in the current directory.

Upvotes: 11

Related Questions