How do you use vim modes with an example?

Vim is a versatile text editor commonly used on Unix-based systems, known for its various modes that enhance editing efficiency. The three primary modes in Vim are:

  • Normal Mode: This is the default mode when you open Vim. In Normal mode, you can navigate, delete text, and do other command-like actions.
  • Insert Mode: This mode allows you to enter text into your document. You can switch to Insert mode by pressing the 'i' key while in Normal mode.
  • Visual Mode: This mode is used to select text. You can enter Visual mode by pressing 'v' in Normal mode.

Here's an example of using these modes:

<?php // This is a simple PHP script echo "Hello, World!"; ?>

Vim Text Editor Normal Mode Insert Mode Visual Mode Linux