Navigation in Vi Editor
Vi editor provides a lot to commands/keys to navigates seamlessly within the editor but you must have to be in the command mode to navigate, to enter in command mode if you are in insert mode press Esc.
Basic 4 navigation keys
There are four basic navigation keys in vi editor to navigate in cardinal directions (up/down/left/right) which are as follow:
Key |
Description |
---|---|
k |
Moves the cursor up one line |
j |
Moves the cursor down one line |
h |
Moves the cursor to the left one-character position. |
l |
Moves the cursor to the right one-character position. |
Examples:
We have discussed about the basic four navigation keys to move the cursor in four cardinal directions we have attached screenshots for each navigation key to demonstrate its moves:
1. To move cursor one line up (k)
2. To move cursor one line down (j)
3. To move cursor one character left (h)
4. To move cursor one character right (l)
Additional Navigation Keys
Apart from the basic navigation keys vi editor provides a lot commands/keys to navigate which are as follows:
Key |
Description |
---|---|
0 |
Positions cursor at beginning of line |
$ |
Positions cursor at end of line |
W |
Positions cursor to the next word |
B |
Positions cursor to previous work |
( |
Positions cursor to beginning of current sentence |
) |
Positions cursor to beginning of next sentence |
H |
Move to top of screen |
nH |
Moves to nth line from the top of the screen |
M |
Move to middle of screen |
L |
Move to bottom of screen |
nL |
Moves to nth line from the bottom of the screen |
Colon followed by a number position |
The cursor on the line number is represented by the number after the colon. For example, “:10” positions the cursor on line 10 |
Basic Vi Editor Guide
1. Create/Edit a file using Vi editor
vi filename
2. Insert Mode
To make any changes in the file first you need to enter in the insert mode to modify the file. To get into insert mode press button ‘i’ to enter in insert mode.
3. Command Mode
To run any command in the vi editor you have to first enter in the command mode if you are currently in the insert mode then press Esc and then ‘:’ colon followed by your command to run your command in the editor.
Which are the four navigation keys in vi
In this article, we will cover how to efficiently navigate in the vi editor along with the basic four navigation keys we will look into some additional navigation keys to navigate seamlessly within the vi editor. First, we look at what Linux and VI editors and why we use them, what are its features and how can we use them.
Linux
Linux was developed by Linus Torvalds in 1991 as a hobby project. It is an open-source (source code that can be used by anyone freely) kernel that is most popular and widely used in the industry as well as in personal systems. There are various operating systems based on Linux kernel, some of the popular Linux distributions are Ubuntu, Cent OS, Red Hat, Debian, and Kali Linux.
VI Editor
Vi Editor is a widely used text editor in Unix/Linux systems and is known for its efficiency and flexibility. Vi editor was developed in 1976 by Bill Joy and later in 1991, an improved version of Vi editor was released which is known as VI IMproved (VIM). There are two modes in Vi Editor:
- Insert Mode
- Command Mode
Contact Us