Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between append and insert mode in Vim

Tags:

vim

I noticed this accidentally when playing around in vimtutor. What's the difference between append and insert mode in Vim? When I type a in normal mode (not A) I can insert text. When should I use one and not the other?

like image 725
AWE Avatar asked Nov 03 '12 08:11

AWE


People also ask

What is insert mode in Vim?

vim has two "modes": COMMAND mode and INSERT mode. In COMMAND mode, you execute commands (like undo, redo, find and replace, quit, etc.). In INSERT mode, you type text. There is a third mode, VISUAL mode, that is used to highlight and edit text in bulk.

What are the three modes of Vim?

In Vim, there are three modes of operation: Normal, Insert, and Visual.

What is the difference between command and insert mode in vi?

Insert mode is the mode to be in when inserting text into the file. Command mode is the mode to be in when giving commands which will move the cursor, delete text, copy and paste, save the file etc. When entering a file, vi is in command mode. To enter text, you must enter insert mode.

What is the default mode of Vim editor?

Explanation: The default mode of vi editor is command mode, where every key which is pressed is interpreted as a command to run on the text. To perform operations on text like deleting, copying, the first step you'll have to follow is to be in the command mode so that you can run commands according to your suitability.


2 Answers

The append command will put the cursor after the current position, while the insert command will put the cursor before it.

Using the append command is like moving the cursor one character to the right, and using the insert command.

Using the insert command is like moving the cursor one character to the left, and using the append command.

You choose which depending on where you want to start typing.

like image 198
Nathan Fellman Avatar answered Oct 13 '22 23:10

Nathan Fellman


Note that vimtutor doesn't initially make the case of the command obvious:

SHIFT+A (capital A, as opposed to a) the cursor moves to the end of the current line.

SHIFT+I (capital I, as opposed to i)moves to the start of the current line.

like image 44
m0j0Priest Avatar answered Oct 13 '22 23:10

m0j0Priest