Code editors command line tools
Not all your coding has to be done through a graphical interface, some can actually be done on the command line. You know..that black window with white text where you type commands and interesting things happen. Yes, you can actually work with code in this window.
This tutorial focuses on:
- Accessing the command line
- Command line simple editing
- HTML Tidy
- Command line options for graphical code editors
Accessing the command line
To access the command line in Windows, go to Start -> Run -> Type cmd -> Press Enter
A few commands to familiarize yourself with the command line. Type the command and press Enter to see each one in action.
- dir - Lists the contents of the directory you are in.
- help - Provides a list of commands you can use along with a description of what each one does.
- cd - Displays the full path of the directory you are in.
This is the environment you will be using command line code editing tools in. Very different from a graphical program, isn't it?
Command line simple editing
Open up a command prompt window -> type edit -> press Enter. The blue screen that appears is the Windows command prompt built-in text editor.
This text editor includes the core functionality to work with files such as open, save, create new files, and other functionality such as search & replace. You can access the menu options using your mouse.
HTML Tidy is a command line program which will automatically fix mistakes in your HTML code as well as indent code and improve its layout to make it easier to work with. You can't edit code or create new pages using HTML Tidy, only work with existing code to fix it.
Once you download HTML Tidy you don't even have to install it, just run the program.
Do the following to be able to run HTML Tidy from the command line:
- open the directory where you downloaded HTML tidy
- copy the file named tidy (right click on the file and choose copy)
- go to C:\Windows
- Paste the file inside C:\Windows (right click anywhere and choose paste)
Open up a command prompt window -> type tidy -h. This should bring up the HTML Tidy help screen which will display a list of Tidy's commands that you can use.
Command line options for graphical code editors
It's actually possible to open a program from the Command prompt; to do this you need to know the name of the program, put it into the command prompt, and press Enter and the program will open. Opening a program like this is nothing special, but some graphical code editors have command line options that you can use when you open them through the command prompt.
These command line options can be used to do extra things that you would not be able to do if you opened up the code editor in the regular way. For example, the notepad++ code editor has a multiple instances command line option which can be used to open multiple notepad++ windows at a time as opposed to being able to open just one if you open it in the regular way.
Check your code editor's documentation and/or website to find out things you can do if you open it from a command prompt.