VI Editor: Move to EOL instead of last character

非 Y 不嫁゛ 提交于 2019-12-03 07:29:37

The normal mode command for entering insert mode at the end of the line is A.

More generally, i enters insert mode before the current character so what you get is perfectly in line with what you do: $ puts the cursor on the last character and i enters insert mode before the last character. That's what you ask Vim to do and that's what it does.

If you want to enter insert mode after the current character, the right command is a so what you should have done instead of $i (which can't do what you want, whether you are in vi or vim) is $a for which there is a cool shortcut: A.

I am guessing you want to use o to "open" a new line. However I have provided some ways to insert text via vi

Insert commands

It should be noted that vi/vim's cursor sets on top of a character not between character like most editors.

  • i insert text before the cursor
  • a append text after the cursor
  • I insert text before the first non-blank in the line
  • A append text to the end of a line
  • o begin a new line below the current one and start insert mode
  • O begin a new line above the current one and start insert mode
  • S/cc delete the current line and start insert.
  • c{motion} delete {motion} and start insert mode. Read as change
  • C Delete from current position to end of line and start insert mode
  • s remove character under cursor and start insert mode
  • r replace one character
  • R start replace mode. Think of it as overwrite

For help on any of these command type :h {command} so help on A would be :h A

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!