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?
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.
In Vim, there are three modes of operation: Normal, Insert, and Visual.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With