As a Beginner, the word Vim might sound scary in the tech world, but hey, I am here to rescue. Below is the quick guide for navigating the scary Vim world. Let's get started.
*Creating our first file using Vim *
Go to your Bash
terminal and run the command below to create a newfile
vim newfile.txt
It will open an interface like this
Vim has different modes, with Normal mode and Insert mode being the most important. Normal mode is used for navigation and commands, while Insert mode is used for editing text.
Let's see how we can switch between different modes-
You can press i
key on your keyboard to go into the Insert mode where we can edit the text. To return to Normal mode, we can click the Esc
key.
Editing, saving files, and exiting the Vim environment-
So, previously we have created the file newtext.txt
, now we are going to edit the file.
Press the i
key (yes, on your keyboard) to enter the Insert mode. Enter the text you want that file to contain. You can use the arrow keys (↑ ↓ ← →)
to move around the editor.
If you are not able to edit the text, check if you are in Insert mode
by looking at the bottom of your editor.
After entering the text, we got to save the file. Press the Esc
key to return to the Normal mode
. When you are in Normal mode, type the :w
command in your editor to save the file.
Lastly, we need to exit our Vim environment, type the :q
command to exit.
If you want to save and quit the editor, just type :wq
or :x
, and if you want to quit without saving, you can type :q!
in Normal Mode.
Dealing with Git commit message with the following steps
- Press
i
to ensure you are in Insert mode and enter the commit message. - Then, press the
Esc
key to make sure you are in Normal mode. - Type
:wq
and pressEnter
to save the message and exit. - If you want to abort the merge, type
:ql!
thenEnter
.
Command Table
So this is a quick way to create, edit, navigate, save, and exit the almighty Vim. Hope this guide helps you.
Top comments (0)