[vim/vim] search() vs ignorecase vs smartcase (Issue #14831)

7 views
Skip to first unread message

097115

unread,
May 23, 2024, 12:43:58 AMMay 23
to vim/vim, Subscribed

Help for search() states that

'ignorecase', 'smartcase' and 'magic' are used.

However, if I run the following:

printf "aaa\nAAA\nbbb\nBBB\n" | \
    vim \
        -u NONE \
        +'set nocompatible ignorecase smartcase' \
        +"nnoremap S :echo search('\<aaa\>\\\|\<BBB\>', 'w')<CR>" \
        -

...and then press S, only aaa and BBB entries will be found, while I'd expect also to find AAA.

Am I wrong?

(Sure, I can include \c atom in the search pattern but that will also match bbb.)

Vim version: 9.1.381


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/14831@github.com>

Christian Brabandt

unread,
May 23, 2024, 1:14:41 AMMay 23
to vim/vim, Subscribed

Well, smartcase means, if you have a pattern with at least one upper case character, the search becomes case sensitive. And that's what's happening here.


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/14831/2126249640@github.com>

097115

unread,
May 23, 2024, 1:22:28 AMMay 23
to vim/vim, Subscribed

Oh, the whole pattern, not just that uppercased part... I see, thanks, Christian!

(On a side note, and if I want to match here aaa, AAA and BBB, I simply have list everything in the pattern, there's no some other smart way? )


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/14831/2126256687@github.com>

097115

unread,
May 23, 2024, 1:22:33 AMMay 23
to vim/vim, Subscribed

Closed #14831 as completed.


Reply to this email directly, view it on GitHub.

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

Christian Brabandt

unread,
May 23, 2024, 1:40:58 AMMay 23
to vim/vim, Subscribed

Not sure what you want to match. You could use ^\w\{3\}$


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/14831/2126276189@github.com>

K.Takata

unread,
May 23, 2024, 1:56:59 AMMay 23
to vim/vim, Subscribed

Perl's regex can turn on/off ignore case only a part of the pattern: (?i:aaa)|BBB.
However, Vim doesn't support such pattern.


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/14831/2126292379@github.com>

Reply all
Reply to author
Forward
0 new messages