[vim/vim] ctrl-r ctrl-w doesn't work as expected in command mode if incsearch is on (Issue #9898)

304 views
Skip to first unread message

bsdmp

unread,
Mar 6, 2022, 3:58:05 AM3/6/22
to vim/vim, Subscribed

Steps to reproduce

mv ~/.vimrc ~/vimrc
mv ~/.vim vim
vim

:set incsearch

insert two lines:
one
two

put cursor on word "one", type /^ to get into search mode, Ctrl-R Ctrl-W, word "two" will be inserted into command line

Expected behaviour

Word under cursor is expected to be inserted ("one"). If I remove :set incsearch step, all works as expected. According to #vim@libera bug is not present in 3455.

I use this method to quickly navigate through code, because '^func_name' will immediately gets me to its implementation.

Version of Vim

vim-8.2.4476-no_x11

Environment

OpenBSD current
xterm
screen-256color
ksh

Logs and stack traces

No response


Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/9898@github.com>

Tony Mechelynck

unread,
Mar 6, 2022, 4:51:56 AM3/6/22
to vim/vim, Subscribed

Isn't this expected? With /^ you search for a begin-of-word. Help for c_CTRL-R_CTRL-W says:

	When 'incsearch' is set the cursor position at the end of the

	currently displayed match is used.  With CTRL-W the part of

	the word that was already typed is not inserted again.

IOW, with 'incsearch' on, you start at the beginning of the next Word from the cursor — or at least that's how I understand it.

What happens if instead of /^ you go into search mode with only / ? Or if instead of /^ (search forward) you use ?^ (search back)?

Best regards,
Tony.


Reply to this email directly, view it on GitHub, or unsubscribe.


Triage notifications on the go with GitHub Mobile for iOS or Android.

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

Tony Mechelynck

unread,
Mar 6, 2022, 4:55:44 AM3/6/22
to vim/vim, Subscribed

Oops, ^ is begin-of-line, not begin-of-word. But otherwise I think my reasoning holds.

Best regards,
Tony.


Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.

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

bsdmp

unread,
Mar 6, 2022, 5:11:01 AM3/6/22
to vim/vim, Subscribed

Isn't this expected? With /^ you search for a begin-of-word. Help for c_CTRL-R_CTRL-W says:

	When 'incsearch' is set the cursor position at the end of the

	currently displayed match is used.  With CTRL-W the part of

	the word that was already typed is not inserted again.

IOW, with 'incsearch' on, you start at the beginning of the next Word from the cursor — or at least that's how I understand it.

Does it mean that ^ in /^ is interpreted as 'part of the word'?

I mean in following scenario it makes sense:

fooa
foob

set cursor on first line, type /foo it will auto-complete to /foob. I see how it makes sense for words, but I expected ^ to be interpreted in other, "special", way. (I illustrated workflow in which it makes sense in OP).

What happens if instead of /^ you go into search mode with only / ? Or if instead of /^ (search forward) you use ?^ (search back)?

If i use / - it works as expected, it pastes word under cursor.
If i use ?^ and i'm on first line, i see E348: No string under cursor, if i'm on second line it pastes one.


Reply to this email directly, view it on GitHub, or unsubscribe.


Triage notifications on the go with GitHub Mobile for iOS or Android.

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

Bram Moolenaar

unread,
Mar 6, 2022, 9:45:19 AM3/6/22
to vim/vim, Subscribed

When you type "^" the cursor moves to the start of the next line. You can't see it, since it doesn't match any character yet. Try typing "." and you see the "t" of "two" is highlighted.
This is normal behavior, "^" searches for the next start of the line, so that is where the cursor is when you type CTRL-R CTRL-W


Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.

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

Bram Moolenaar

unread,
Mar 6, 2022, 9:45:20 AM3/6/22
to vim/vim, Subscribed

Closed #9898.


Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issue/9898/issue_event/6190683627@github.com>

Reply all
Reply to author
Forward
0 new messages