Linux provides various command-line and graphical text editors for file manipulation. Common command-line editors include nano, vi/vim. These tools allow users to create, open, edit, and save files.
In this practice, I will use vi because I personally prefer vi than nano
To use vi
Type vi and filename you want to edit
Press Enter
If I want to start writing or editing the contents I will first of all Press (i)
insert then I will start writing or editing after which I will Press (esc) key
(:) Colon
(w) Write
(q) Quit
(!) Bang
Then Press Enter
That takes you back. Then if you want to see or view the contents of what you have written or edited use (cat)
(cat) — Concatenate — It is used to quickly view the content of one or more files directly in the terminal, it can also be used to merge file and its contents into another file.
(cat) — Concatenate- To merge and create a file and its contents into another file.
echo- This is used to create a file, write a file and over write the contents in an existing file.
vi Editing Commands
Command Description
i Insert at cursor (goes into insert mode)
a Write after cursor (goes into insert mode)
A Write at the end of line (goes into insert mode)
ESC Terminate insert mode
u Undo last change
U Undo all changes to the entire line
o Open a new line (goes into insert mode)
dd Delete line
3dd Delete 3 lines
D Delete contents of line after the cursor
C Delete contents of a line after the cursor and insert new text. Press
ESC key to end insertion.
dw Delete word
4dw Delete 4 words
cw Change word
x Delete character at the cursor
r Replace character
R Overwrite characters from cursor onward
s Substitute one character under cursor continue to insert
S Substitute entire line and begin to insert at the beginning of the line
~ Change case of individual character
Top comments (0)