Vim is a text editor that is widely used in the Linux/Unix environment.
Here are some basic commands that you can use in Vim:
To open a file in Vim
vim <file_name>
To switch between normal mode and insert mode
- Press
i
to enter insert mode, which allows you to type in the text. - Press
Esc
to return to normal mode.
To save changes and exit Vim
- Press
Esc
to return to normal mode - Type
:w
to save changes - Type
:q
to exit Vim - If you have made changes and want to save and exit at the same time, type
:wq
To move the cursor
Use the arrow keys to move the cursor up, down, left, or right
- Or use the following keys to move more quickly:
h
to move leftj
to move downk
to move upl
to move right
To delete text
- Position the cursor over the text you want to delete.
- Press
x
to delete the character under the cursor. - Press
dd
to delete the entire line.
To copy and paste text
Position the cursor over the text you want to copy
- Press
yy
to copy the entire line. - Position the cursor where you want to paste the text.
- Press
p
to paste the copied text after the cursor, orP
to paste before the cursor.
To search for text
Press /
to enter search mode
- Type the text you want to search for, and press
Enter
- Press
n
to move to the next occurrence of the search term, orN
to move to the previous occurrence.
These are just a few basic commands to get you started. Vim has many more commands and features that you can learn as you become more familiar with the editor.
For More Command Check below Cheat Sheet.
Download the Above Cheat Sheet Image by Link