LFCS: Linux Foundation Certified System Administrator - Difference between i and a commands of the vi editor

Difference between i and a commands of the vi editor

Question

What is the difference between the i and a commands of the vi editor?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

B

The correct answer is B.

In the vi editor, i and a are two different commands used to insert text into a file being edited.

i is the insert mode command, which puts the editor into insert mode at the current cursor position. Any text entered by the user will be inserted before the cursor position. In insert mode, the user can type normally, and the text they type will be added to the file.

On the other hand, a is the append mode command, which puts the editor into insert mode at the end of the current line. Any text entered by the user will be inserted after the cursor position. In append mode, the user can type normally, and the text they type will be added to the end of the current line.

It's worth noting that vi has several modes, including command mode, insert mode, and visual mode, among others. In command mode, the user can issue commands to manipulate the file being edited, while in insert mode, the user can enter text. The mode the editor is currently in is indicated in the bottom left-hand corner of the screen.

So, in summary, the i command inserts text before the current cursor position, while the a command inserts text after the cursor position.