3

I'm trying to add another line at the end of the last line in the VI editor and I need to go to the very last of the last line (command $) to insert a new line by hitting the enter key. But the cursor stays on the last character: if I have to hit enter on this last character, it makes the last character of the last line go to the next line. That is not what I need. I just need to insert a line by hitting the enter key.

Operating system: Solaris X11

Thomas Dickey
  • 76,765
Zeus
  • 242

2 Answers2

6

e is used to go to end of word. You should use $ to go to end of line.

You can insert another line from the current position by using o (for open).

You can also use A to append something to the end of line from anywhere on the line.

unxnut
  • 6,008
  • How do I go to the end of the word, ie., if I do $ it will go to the end but cursor stays on the last char, I cannot go to the next spot after the char – Zeus Jul 17 '15 at 19:50
  • 1
    There is nothing after the last character. So, you can use a to append after the current character, or A to append at the end of line. – unxnut Jul 17 '15 at 19:51
  • Excellent! thank you. I'll mark it answered – Zeus Jul 17 '15 at 19:51
4
  1. The normal way to add a new line (or new lines) below the current line is to type o (open).  It will immediately create a new, blank line, so you don't need to type Enter (until/unless you want to add two or more lines).
  2. Are you using i (insert)?  To add text after the current position, use a (append).  Or, to add text at the end of the current line, use A, which is effectively short for $a.
  • My bad, i changed the question, I was using $ instead of e. – Zeus Jul 17 '15 at 19:53
  • 1
    I think it's a custom .vimrc; we had a shared "base" one at work for new hires that did the same thing, where [enter] in normal mode was mapped to [i][enter][esc] – Izkata Jul 18 '15 at 01:58