VIM Tutorial
How to open vim in the terminal
Just write vim and press enter. It will open a new blank window.
$ vim
How to exit vim from the terminal
Press :q and then press enter.
:q
Before understanding more commands let's see the different modes that available in VIM
Modes of vim
Normal Mode
Default mode when opening a file.
Used for navigating, editing, and manipulating text.
Most commands and shortcuts work in this mode.
Press Esc to enter Normal Mode from other modes.
Insert Mode
Used for inserting new text.
Entered by pressing i, a, o, or s in Normal Mode.
Allows typing new text, but most commands don't work.
Press Esc to exit Insert Mode and return to Normal Mode.
Visual Mode
Used for selecting and manipulating text.
Entered by pressing v, V, or Ctrl+v in Normal Mode.
Allows selecting text using movement commands.
Press Esc to exit Visual Mode and return to Normal Mode.
Command Mode
Used for executing commands and searching.
Entered by pressing : in Normal Mode.
Allows typing commands, such as :wq to save and quit.
Press Enter to execute the command and return to Normal Mode.
Ex Mode
Used for executing complex commands and scripts.
Entered by pressing Q in Normal Mode.
Allows typing commands, such as :echo "Hello, World!".
Press :visual to exit Ex Mode and return to Normal Mode.
Replace Mode
Used for replacing text.
Entered by pressing R in Normal Mode.
Allows typing new text to replace existing text.
Press Esc to exit Replace Mode and return to Normal Mode.
Select Mode
Used for selecting text more intuitively.
Entered by pressing gh in Normal Mode.
Allows selecting text using mouse or keyboard.
Press Esc to exit Select Mode and return to Normal Mode.
You may in whatever mode, first you need to come to normal mode and then you can go to different mode.
How to open an existing file with Vim
If you are in the same directory as the file, just write vim followed by the filename and press enter.
$ vim file1.sh
How to exit Vim without saving the changes
You will need to force the editor to exit without worrying about the changes
:q!
How to save and exit at the same time
You will need to write the save and exit commands together.
:wq
How to undo the changes
Press esc
to go from insert mode to normal mode then press u
If you want to undo multiple changes then press u
key multiple times.
Pressing
0
takes you to the beginning of the line and Pressing$
takes you to the end of the line when you are in Normal Mode.When you type
shift + a
it will take you to the insert mode and cursor will be at the end of the line
Conclusion
Mastering Vim's modes and commands significantly boost productivity.
Vim is a powerful tool for efficient text editing.
Continuous practice and exploration are essential for proficiency.
Understanding the basics of opening, editing, and navigating files is crucial.
Happy Vimming!
Thank you for taking the time to read this article ๐. I hope the article provided you with valuable insights. I would highly appreciate it if you took a moment to like ๐, share your thoughts or feedback comment โ๏ธ, and share ๐ it.
You can also follow me for more content on CSS, Javascript, React, Git, DevOps, Linux, Shell Script and other web Development and Devops topics.
Happy Learning...! โ๏ธโ๏ธโ๏ธ
For Paid collaboration, please mail me at: subramanyeshwarak@gmail.com
If you liked my content, Connect with me on