6.2. Using The Vim Editor: 6.2.1. Two Modes
6.2. Using The Vim Editor: 6.2.1. Two Modes
6.2. Using The Vim Editor: 6.2.1. Two Modes
Introduction to Linux:
Prev Chapter 6. Text editors Next
What makes vi confusing to the beginner is that it can operate in two modes: command mode and insert
mode. The editor always starts in command mode. Commands move you through the text, search, replace,
mark blocks and perform other editing tasks, and some of them switch the editor to insert mode.
This means that each key has not one, but likely two meanings: it can either represent a command for the
editor when in command mode, or a character that you want in a text when in insert mode.
NotePronunciation
It's pronounced "vee-eye".
k to move up
j to move down
:q! forces the exit when you want to quit a file containing unsaved changes.
:wq! overrides read-only permission (if you have the permission to override permissions, for instance
when you are using the root account.
/astring will search the string in the file and position the cursor on the first match below its position.
/ will perform the same search again, moving the cursor to the next match.
:1, $s/word/anotherword/g will replace word with anotherword throughout the file.
i will insert
o will insert a blank line under the current cursor position and move the cursor to that line.
Pressing the Esc key switches back to command mode. If you're not sure what mode you're in because you
use a really old version of vi that doesn't display an "INSERT" message, type Esc and you'll be sure to return
to command mode. It is possible that the system gives a little alert when you are already in command mode
when hitting Esc, by beeping or giving a visual bell (a flash on the screen). This is normal behavior.
In UNIX and MS Windows, if Vim has been properly installed, you can start this program from the shell or
command line, entering the vimtutor command. This will make a copy of the tutor file, so that you can edit
it without the risk of damaging the original. There are a few translated versions of the tutor. To find out if
yours is available, use the two-letter language code. For French this would be vimtutor fr (if installed on the
system).
https://linux.startcom.org/docs/en/Introduction%20to%20Linux/sect_06_02.html 2/2