Primary Linux Text Editors
There are two primary command line interface (CLI) text editors: Vi Improved (VIm) and Nano.
VIm
From bib. source
Vim is very powerful and complex. It uses three different modes, where each mode maps keyboard keys to different functions.
The three modes VIm can be used in are as follows (Garn 2022, 14):
- Insert mode, wherein the keyboard acts as usual, inserting text into the file open in VIm–in this mode you can use your keyboard’s arrow keys to navigate the file contents.
- Command mode, wherein pressing a keyboard key issues commands to VIm; for example, pressing the “i” key tells VIm to switch to insert mode while pressing the “:” key tells VIm to switch to execute mode.
- Execute mode, wherein a command prompt is provided that captures keyboard presses or keypresses
There are more modes available for VIm, but these are the main ones that are often used. All of these modes are more fully known as editing modes.
When in execute mode, one can type “w” to write changes to the given file, and “q” to exit or quit the text editor (Ibid). They can even be written in sequence, such that they will be executed in that sequence: “wq” (Ibid). Alternatively, using the escape key on the keyboard (Ibid).
To open a file in VIm, type the following in a shell terminal (Ibid):
vim $FILENAME_PATHNano
When it comes to Nano (Garn 2022, 15):
From bib. source
It’s simpler but less powerful. […]
Nano does not have modes. Pressing keys on the keyboard inserts text into the file, […]. To save and close the file, use keyboard shortcuts using the
Ctrlmeta key.
The meta-key is a key used to allow combinations of other keypresses that do not result in text input for the file, but performs other actions. In this case, it being the Ctrl key, it can do the following with given key combinations (Ibid):
- Save changes, i.e. write changes to file, using
Ctrl+O(that is,Ctrl+Shiftand “o” at once) - Navigating the file contents by using the keyboard’s arrow keys
- Exit Nano, using
Ctrl+X(that is,Ctrl+Shiftand “x” at once)
To open a file in Nano, type the following just like with VIm (Ibid):
nano $FILENAME_PATHtext_editor command_line command-line command_lines command-lines command_line_interface command_line_interfaces text_editors Vi_Improved editing_mode editing_modes bash_script bash_scripting Bourne_Again_Shell_script Bourne_Again_Shell_scripting Bourne_Again_Shell shell_script shell_scripting metakey meta_key meta-keys meta_keys metakeys key_combos key_combinations arrow_keys Ctrl_key Shift_key arrow_key interfaces keypress Linux
bibliography
- Garn, Damon. The Official CompTIA Linux+ Student Guide (Exam XK0-005). 1.0. Downers Grove, IL: CompTIA, 2022.