1.3. Text Editors#
So how do we make, edit, or even begin to visualize files?
We need a CLI text editor. Something similar on your computer might be Notepad, or TextEdit, which really is just a simplified Word program.
You have several text-editor options, like nano, emacs, and vi/vim. Personally, I prefer using vi/vim, since I learned this first, but feel free to explore what works best for you!
1.3.1. vi/vim#
There are several levels to using vi/vim, but don’t get lost! For now, we only need to know:
vi/vim has 2 modes:
Command Mode
When you run
vi filenameto edit,vi/vimstarts out in command mode. This means that all the alphanumeric keys are bound to commands, rather than inserting those characters.
Insert Mode
To enter the insert mode, type
i(for “insert”, this is shown in the bottom right corner). You can type normally until you want to make a correction, save the file, or perform another operation that’s reserved for command mode or last-line mode. To get out of insert mode, hit theespkey.
1.3.2. How to Use vi/vim?#
To make a new file:
vi filename
If filename exists, vi/vim will open it, and you start in Command Mode.
1.3.3. Save & Quit#
To do this, you need to be in Command Mode. There are 4 options:
:wSave the file
:wqSave the file and quit (exit)
:qQuit the file, but don’t exit
If changes were made, then you will not be able to exit, and must do option 4.
:q!“Force quit” the file