linuxvimtext-editorvislackware

Vi Editing and Cursor Position at End of Line?


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?


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).