Text editor is useful when need to edit configuration file or script on Linux.
There are two main text editors in Linux: Nano & Vim.
NANO
Simple text editor
Useful for quick edit
VIM
Allow user "record" editing step
Useful for repetitive editing
Duplicate text DISABLED_ five rows in text file.
Nano
Open Terminal
Direct to text file directory.
cd [Text file directory]
Example: cd /home/student/Desktop
Open text file
nano [Text file directory]
Example: nano test.txt
Type DISABLED_ five rows.
Save and exit
Ctrl + X --> Y --> Enter
Vim
Open Terminal
Direct to text file directory.
cd [Text file directory]
Example: cd /home/student/Desktop
Open text file
vim [Text file directory]
Example: vim test.txt
Press Esc to make sure in Normal Mode.
Insert lines
[Number of lines]i --> Enter --> Esc
Example: 4i --> Enter --> Esc
Get back to top
gg
Start recording, you may record 26 sets of macros (a to z)
q[Slot name, a to z]
Example: qa
Insert mode
I
Type DISABLED_
Quit Insert mode
Esc
Move to next line
j
End recording
q
Run recording in fixed number of iterations
[Number of iterations]@[Slot name, a to z]
Example: 4@a
Press Esc to make sure in Normal Mode.
Save and exit
:wq --> Enter
Esc Normal Mode -- Type command
i or a Insert Mode -- Edit text
v Visual Mode - Highlight text
:set number (or :se nu) Display number of lines
d Cut
y Copy
p Paste
u Undo
Ctrl+r Redo
/[Text] Search forward
?[Text] Search backward
:%s/[Old Text]/[New Text]/gc Search and replace with confirmation
:q! Quit without save
:wq Quit with save