Question

When I am using vi (which I think invokes elvis by default on Slackware 13.37) I am able to insert text as expected but when I edit out typos by using ESC x the cursor movement key l as well as $ places the cursor on the last letter rather than beyond it therefore forcing me to insert any new text to the left of the last letter essentially forcing a typo unless I delete back all the way to a space. The actual arrow key will usually allow me to go beyond the last letter, but not always.

To help explain what I am doing:

This is text with a tttypog

I fix it with ESC x

This is text with a typog

but ESC l or ESC $ allows me only to move the cursor to the g thus forcing me to insert any new text only to the left of the g

This is text with a typoraphicalg

Am I doing something wrong?

Was it helpful?

Solution

Edit: Replaced "command mode" with "normal mode" - @Jim Steward: thanks for pointing out that incorrectness

Short answer: If you are in normal mode and want to insert text after a character press a. Press A to directly jump to the end of the line and to insert characters after the last character. In vi, afaik, it is not possible to place the cursor on a column after the last character in the current line (if you are in normal mode). In vim however there is an option named virtualedit, which can enable you to do so (see :help virtualedit).

OTHER TIPS

There are two modes in vi, the edit mode (default) and the insert mode. The command "i" (without quotes) takes you to the insert mode and ESC brings you back to the edit mode. It is not necessary to press ESC before every command, although pressing ESC is a harmless way to ensure that you are in the edit mode if you forget which mode you were last in.

The "A" command (without quotes) is used to append text at the end of line.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top