[vim/vim] When cursor is on last character in the command line window, hitting Ctrl-C moves the cursor to after that last character (Issue #11975)

28 views
Skip to first unread message

Enrico Maria De Angelis

unread,
Feb 12, 2023, 3:22:25 AM2/12/23
to vim/vim, Subscribed

Steps to reproduce

  1. vim -u NONE
  2. :set nocompatible
  3. /some textCtrl-Fh (now the cursor is between x and t, as in | is the cursor in some tex|t)
  4. Ctrl-C

Expected behaviour

I would expect the cursor to be where I left it (and it would be there if I had hit h more than once), but instead it is after some text.

Version of Vim

9.0 patches 1-1182

Environment

Operating system: ArchLinux (up-to-date)
Terminal: URxvt
Value of $TERM: rxvt-unicode-256color
Shell: Bash

Logs and stack traces

No response


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/11975@github.com>

Bram Moolenaar

unread,
Feb 16, 2023, 8:56:17 AM2/16/23
to vim/vim, Subscribed

This happens because quite often the cursor will be on the last character not because of being moved there, but because it's moved back from after the line. Actually moving the cursor there is a bit unexpected, and there is no information about how the cursor got there.
I don't think this can be solved properly without quite a bit of work, and it would happen very infrequently. It's a minor problem as well. Thus this problem gets a low priority.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/11975/1433124809@github.com>

Mirko Ceroni

unread,
Feb 19, 2023, 2:24:55 AM2/19/23
to vim/vim, Subscribed

I have found where this behaviour occour in the code
it seems like a deliberate behavior, although I don't understand why
may be a solution to rem those lines ?
https://github.com/vim/vim/blob/441a7a94482f704b66253b8d08130f27b6b13736/src/ex_getln.c#L4629-L4633


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/11975/1435913945@github.com>

Enrico Maria De Angelis

unread,
Feb 19, 2023, 4:00:16 AM2/19/23
to vim/vim, Subscribed

This happens because quite often the cursor will be on the last character not because of being moved there, but because it's moved back from after the line.

But one can go from command line window's inset mode back to command line via Ctrl+C, so even with the change I suggest, one could still do what the current behavior does, ad the cost of hitting a (or equivalently A) before Ctrl+C. On the other hand, given the current behavior, if one wants to have the cursor right before the last character in command line when moving to it from command line window, one has to Ctrl+C and then reach for Left arrow (far away), or Backspace (closer), but resorting on memory in the latter case, as regards to what character was there.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/11975/1435929918@github.com>

Enrico Maria De Angelis

unread,
Feb 19, 2023, 4:12:34 AM2/19/23
to vim/vim, Subscribed

By the way, at c_CTRL-F one reads

Vim will be in Normal mode when the editor is opened, except when 'insertmode' is set.

and that is true, but if one pressed Ctrl+F while the cursor is at the end of the command line (I'd say the most frequent case, and possibly preciselyh the reason why one is moving to command line window: to be able to move across the line with normal mode movements rather than via arrow keys), one finds the cursor being in normal mode and at the past-to-last character position, which is kind of invalid; indeed, you can h to move to the last character, but l will not bring you back on that position which unreachable in normal mode.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/11975/1435932648@github.com>

Reply all
Reply to author
Forward
0 new messages