Modes

To truly grasp Vim, it's essential to familiarize yourself with its modes. While Vim offers twelve modes in total, you'll primarily use about four or five in your day-to-day activities.

Recognizing these key modes is crucial:

  • Normal Mode: This is the default mode when you start Vim. In Normal mode, you can execute all standard editor commands, making it primarily used for navigation and text manipulation. Experienced Vim users spend the majority of their time here. A good practice is to return to Normal mode whenever you're not actively typing.
  • Insert Mode: As the name implies, this mode is used for adding new text. You can also run certain commands in Insert mode. When active, you’ll see “– INSERT –” displayed at the bottom of the Vim window.
  • Command Mode: To access Command Mode in Vim, simply press : while in Normal mode. In this mode, you can execute Ex commands (like :set number), enter search patterns (e.g., /word), and use filter commands. After executing a command, Vim will revert to Normal mode.
  • Visual Mode: This mode allows for text selection and manipulation. It operates similarly to Normal mode, but the movement commands will extend a highlighted area. Non-movement commands will then apply to that selected area. You’ll see “– VISUAL –” at the bottom when this mode is active.
  • Insert Normal Mode: By pressing Ctrl-o while in Insert mode, you’ll switch to this mode. It resembles Normal mode but will return to Insert mode after executing a single command. This mode is indicated by “– (insert) –” at the bottom of the window.

Use of Insert Normal Mode?

For example, if you’re in Insert mode and want to delete the next word, you can press Ctrl-o, followed by the command dw. After executing the command, Vim will return you to Insert mode, allowing you to continue typing without needing to switch back manually.

This functionality strikes a balance between the flexibility of Insert mode and the efficiency of Normal mode, enabling you to streamline your workflow without interruption.


Commands

Commands are a fundamental aspect of Vim, as most of your actions will involve executing various commands.

Generally, you can categorize command execution in Vim into three types:

  • Ex Commands: These are executed in the format :{command} (e.g., :help). You’ll frequently use these commands. For a comprehensive list (which is extensive, so don’t dive into it just yet), you can run :help ex-cmd-index.
  • Mapped Commands: These are more complex commands that you can assign to specific keys for easier access. Typically, these are added to your .vimrc configuration file. You’ll explore this further in the blog on Mappings.
  • Editing Commands: These commands are commonly used in both Normal and Insert modes. An example would be d4w, which deletes four words following the cursor. You’ll learn about many of these commands as we move forward.