Vim Pure Basics

Kamalveer Singh
2 min readOct 3, 2024

--

You might have opened a file in vim text editor by choice or mistake and there you might have had problems in writing to file and even exiting from the vim file.

This blog will help you with —

  1. Opening a file in Vim
  2. Writing to a file
  3. Changing modes
  4. Saving the changes
  5. Exiting from Vim
  1. Opening a file — To open a file in Vim text editor you just need to open your command prompt and use the following command.
vim filename.filetype

vi filename.filetype
it’ll look like this when you use this command

2. Writing to file — to write inside a file you need to first press i or a button to enter the insert mode as at first it is in normal mode and then start typing.

Writing to a file with Vim

3. Changing modes — in vim we have 3 modes which are →

  • Normal Mode: This is the default mode, you can navigate and manipulate text but cannot directly insert text. To enter Normal Mode from any other mode, press the ESC key
  • Insert Mode: This mode allows you to insert text. You can enter Insert Mode from Normal Mode by pressing i (insert before the cursor) or a (append after the cursor).
  • Command Mode: This mode is used for executing commands. You can enter Command Mode from Normal Mode by typing : followed by your command.

4. Saving Changes — To save the changes you have made you need to enter the command mode and type :w.

5. Exiting From Vim — To exit out of vim you need to use the following commands.

:wq    // to save and exit from vim

:q! // to exit without saving

These are the pure basics to know to at least be familiar with vim and not get stuck.

Hope it helped : )

Please give your valuable feedback in comments.

--

--

Kamalveer Singh
Kamalveer Singh

Written by Kamalveer Singh

0 Followers

I love Computer Science <3

No responses yet