2 min read

Command-line On VS Code Windows

Command-line On VS Code Windows

We're using the "git bash" command-line interface (CLI) that comes together when you download git version control.

You don't have to learn all the command when you start learning to code. Instead, you can perform all the actions in Windows Graphic User Interface (GUI).

CLI is for those who prefer keeping their hand on the keyboard. Hence, they do not overstress their hand by moving to the mouse and keyboard so often.

There are some differences compare to Unix or Linux (CLI). For example, not all the commands are available in the "git bash" Windows version.

Below are some of the command we often use:-

List the directory content

ls (LS) to list the files and directories on your current directory

Example:-

pwd to check your current directory.

I seldom use this command on Windows.

I often check my current directory on the integrated terminal on VS Code.

Change directory

cd change to the directory you specify.

Example:-

cd pages - change to pages directory

cd .. - change directory up a level

cd ../component - change directory up a level and to the "component" directory

Create a file

touch filename.extension

Example:-

touch index.html
touch home.css
touch main.js

Keyboard shortcut in VS Code

ctrl + n

Create a directory

mkdir yourDirectoryName

Example:-

mkdir src
mkdir pages
mkdir components

Keyboard shortcut in VS Code

You can create your own key binding

Create a directory with a file

📌 Run this command only after you created the directory.

touch directory/file.extension

Example:-

touch contact/index.html
touch styles/global.css
touch components/Header.jsx

Keyboard shortcut in VS Code

Only can do it with GUI.

Right-click the new file in the explorer then type "directoryName/fileName"

📌 If the directory is not created, VS Code will create the directory with the file inside.

Example:-

  • about/index.html
  • styles/global.css
  • components/Header.jsx

Rename a file

mv currentFileName newFileName

Example:-

mv pages/about-me.html pages/about.html

Or you can cd to the directory and:-

mv about-me.html about.html

Keyboard shortcut in VS Code

ctrl + shift + e to focus on the explorer then navigate to the file you want to rename and press F2

Remove a file

rm fileName

Examples:-

rm pages/about.html
cd pages
rm about.html

Remove a directory

rmdir directoryName

Keyboard shortcut in VS Code

ctrl + shift + e to focus on the explorer then navigate to the directory you want to delete and press delete

Remove a directory with a file inside

rm -r directoryName

Keyboard shortcut in VS Code

ctrl + shift + e to focus on the explorer then navigate to the file you want to delete and press delete