πŸ’Ύ Archived View for bbs.geminispace.org β€Ί s β€Ί vim β€Ί 21404 captured on 2024-12-17 at 15:21:42. Gemini links have been rewritten to link to archived content

View Raw

More Information

-=-=-=-=-=-=-

Comment by πŸš€ stack

Re: "Always off by 1! Is it me?"

In: s/vim

It's not a bug, as everything is like that. It is mainly a consequence of the fact that in insert the cursor is between characters and in normal mode it's on a character, but for some reason the position always slips to the left and is not restored... That's why I feel like I am missing something that (Molinar or whoever started doing it) had in mind... Although it could be just stupid.

πŸš€ stack [OP/mod]

Oct 31 Β· 7 weeks ago

7 Later Comments ↓

🐦 wasolili [...] · Nov 01 at 01:59:

I got curious as to what the reasoning behind it was since, until now, I've just taken it as "it is what it is" and found this (in :help faq-10-2):

In insert mode, when I press the <Esc> key to go to command mode, the cursor moves one character to the left (except when the cursor is on the first character of the line). Is it possible to change this behavior to keep the cursor at the same column?
No. It is not possible to change this behavior. The cursor is always positioned on a valid character (unless you have virtual-edit mode enabled). So, if you are appending text to the end of a line, when you return to command mode the cursor must drop back onto the last character you typed. For consistency sake, the cursor drops back everywhere, even if you are in the middle of a line. You can use the CTRL-O or CTRL-\ CTRL-O command in insert mode to execute a single ex command and return back to insert mode without moving the cursor column.

so I guess Bill Joy just preferred that editing the very start of the line be inconsistent instead of editing the last character of the line being inconsistent. not that interesting, but at least I learned about insert mode ctrl-o

πŸš€ stack [OP/mod] Β· Nov 01 at 02:03:

Yea, sort of makes sense, maybe. It sure drives me nuts!

I am constantly catching an extra character by yanking lines in V mode. To copy 2 lines I intuitively go down 2, and catch the first character of the next line! Combine that with pasting in the wrong place, and my next few minutes are occupied by furious remedial editing...

🐦 wasolili [...] · Nov 01 at 02:35:

for copying 2 lines, I usually just do `yj` which will yank the entire current line and the line after. numbers can be used for more lines, e.g. `y2j` for the current line and the next 2, and k works as expected (e.g yk for current line and the line above it)

then there's `yy` for just the current line. there's also the move and copy commands which are occasionally useful.

I very rarely use visual mode since usually the default motions behave more usefully outside of it. (as in `yj` from normal mode yanks the two lines, but `vyj` only yanks part of each line unless you do `0vj$y`))

πŸ•Έ arma Β· Nov 01 at 12:31:

I'd say the off-by-one thing is a UX bug. For me the main powerful idea behind Vi/Vim is not where the cursor ends up, but modes (normal/insert/visual). And the reason why modes matter is that typing becomes easy, because the user rarely has to press more than one key at a time on the keyboard. None of that Ctrl-Alt-Shift finger acrobatics.

🐐 satch · Nov 01 at 13:32:

It would be pretty easy to make it the choice of the user whether to have the inconsistency be at the end of the line or the beginning of the line.

That way people who are bothered by the behavior could add something simple to their init script and problem solved.

That being said, it’s pretty easy to get used to - especially if you make frequent use of β€˜A’.

πŸš€ stack [OP/mod] Β· Nov 01 at 16:28:

OK, I will make it a goal to find the bindings that actually do what I want and get used to them.

@arma - yes! Before Vim I spent almost a decade or so with Emacs and Common Lisp, and my hands are a wreck.

🦊 fiore · Nov 09 at 19:00:

happens to me as well!

Original Post

πŸŒ’ s/vim

Always off by 1! Is it me? β€” I love vim, but perhaps I am using it wrong! Whenever I do just about anything, I am pretty much always off by one character. In the simplest case, if I enter the instert mode and exit it, I am no longer on the same character! If I do it repeatedly, the cursor will crawl backwards. Whenever I yank and paste, I invariably wind up one character past where I wanted to paste. I thought I would get used to it eventually, but it's now been years and I am constantly '...

πŸ’¬ stack [mod] Β· 18 comments Β· 2 likes Β· Oct 30 Β· 7 weeks ago