Opening and Closing Vim

Opening Vim

To start using Vim, you first need to open it:

  1. Open a Terminal: Access your terminal through your operating system’s usual method (e.g., using Spotlight search on macOS, the Start menu on Windows, or a keyboard shortcut like Ctrl + Alt + T on many Linux distributions).
  2. Launch Vim: Type vim and press Enter. This command opens Vim in normal mode, where you can navigate and manipulate text but not insert text immediately.

Understanding Vim Modes (We will go in detail in another guide)

Vim operates in several modes, but the most pertinent for beginners are:

  • Normal Mode: The default mode when you open, where you can navigate and manipulate text.
  • Insert Mode: Accessed by pressing i in normal mode, allowing you to insert text.

Closing Vim

Exiting Vim involves using command-line mode, which you enter using the colon (:). Here’s how to do it:

  1. Switch to Command Mode: If you are in insert mode (typing text), press Esc to return to normal mode. Once in normal mode, press :. Notice the cursor moves to the bottom of the screen, in the command line area.
  2. Type the Quit Command: After the colon, type q (for quit). The complete command will look like this: :q.
  3. Execute the Command: Press Enter to execute the command and close Vim. If you have made changes that have not been saved, Vim will warn you. To quit without saving changes, type :q! and press Enter.

What Happens with the Cursor?

When you press :, the cursor jumps to the bottom line of the Vim window, also known as the command line or status line. This is where you enter various Vim commands. The command line is a powerful tool in Vim, allowing you to perform operations like saving files, searching text, and configuring the editor.