Making Emacs popular again
Making Emacs popular again
Posted May 8, 2020 16:22 UTC (Fri) by jem (subscriber, #24231)In reply to: Making Emacs popular again by marcH
Parent article: Making Emacs popular again
My biggest problem with vi is not that it is modal, I can get used to that. I think the strangest thing about vi is how it handles the cursor. "Normal" editors use the cursor to specify a point between two characters, or before the first character on the line, or after the last character on the line. If there are N characters on the line, the cursor can have N+1 positions.
Vi, on the other hand, uses the cursor to mark the character it is on. The exception is of course if the line is empty, in which case the cursor has nowhere to go, so it is displayed in the first column. This also means we need both an "insert" and an "append" command to enter insert mode, to add text either to the left or the right side of the cursor. Once in insert mode, vi starts treating the cursor exactly like all other editors do: text is inserted at the left edge of the cursor and the cursor is moved forward past the inserted character. When insert mode is exited, vi goes back to its normal behavior and realizes the cursor can't be left hanging mid-air, so it moves the cursor back one step, which is really confusing.
If somebody has a good explanation why vi is implemented like this, I'd like to hear it.
Posted May 8, 2020 17:21 UTC (Fri)
by mpr22 (subscriber, #60784)
[Link] (1 responses)
Posted May 10, 2020 14:42 UTC (Sun)
by jem (subscriber, #24231)
[Link]
Posted May 8, 2020 17:46 UTC (Fri)
by epa (subscriber, #39769)
[Link] (4 responses)
Posted May 12, 2020 4:04 UTC (Tue)
by filbranden (guest, #87848)
[Link] (3 responses)
It's just one setting away on Vim:
set virtualedit=onemore
You might still find some of the behavior a bit unexpected. For example, $ moves to the last character of the line, rather than one past.
Also, you might just break so many plug-ins this way :-)
But yeah, it's available as a configuration option.
Posted May 13, 2020 11:07 UTC (Wed)
by jem (subscriber, #24231)
[Link] (2 responses)
Ok, thanks. But this is only a partial solution. As you said, $ does not work, and pressing <esc> in insert mode still moves the cursor one position left. You would think i<esc> (entering insert mode and immediately exiting) would be a no-op, but no. My biggest problem with this setting, though, is that it is not supported in VS Code's vim emulator, which is my main use case for vim: to replace VS Code's Notepad-like default editor with a real editor.
Posted May 13, 2020 12:10 UTC (Wed)
by karkhaz (subscriber, #99844)
[Link] (1 responses)
Posted May 13, 2020 17:43 UTC (Wed)
by jem (subscriber, #24231)
[Link]
There's a lot to like about vi, too, for example how you are able to combine editing commands with movement commands. At least you don't have to reach for the arrow keys all the time.
Posted May 9, 2020 0:17 UTC (Sat)
by karkhaz (subscriber, #99844)
[Link]
In normal mode, you sometimes want to operate on characters. Commands like replace ('r'), substitute ('s'), delete ('x') work on the character that the cursor is on, unless of course you prefix the command with a number (in which case the command operates across a span of text, but still starting on the character that the cursor is on). It would not make sense for the cursor to be at the beginning of the line, before any characters, because what character are you operating on?
In insert mode, as you say, the cursor acts like in other editors, because insert mode is the mode that is akin to other editors.
Somebody else made a comment about the cursor changing its shape based on the mode---that seems like a very helpful way to understand this difference, what an excellent feature! In insert mode, you can have the pipe-cursor before the first character on the line, because you can start inserting text before the first character. In normal mode, the cursor is an underline, and the action operates on the character that is underlined. The underline cannot move before the first character or after the last, since there's no character for it to operate on.
Making Emacs popular again
Making Emacs popular again
Making Emacs popular again
Making Emacs popular again
Making Emacs popular again
>set virtualedit=onemore
Making Emacs popular again
Making Emacs popular again
Making Emacs popular again