scrolling during search

15 views
Skip to first unread message

Tavis Ormandy

unread,
May 22, 2022, 3:00:13 PM5/22/22
to vim...@googlegroups.com
Hello! I quite like the combination of incsearch and hlsearch, but hate
the way it scrolls the screen to matches -- I only want the hilights
without the scrolling.

I thought maybe I could fix this with autocommands, but I can't get it
to work, e.g.. I thought this might work:

autocmd CmdlineEnter / mark S
autocmd CmdlineChanged * normal g`S

But that doesn't do anything, any ideas?

Thanks!

--
_o) $ lynx lock.cmpxchg8b.com
/\\ _o) _o) $ finger tav...@sdf.org
_\_V _( ) _( ) @taviso

Bram Moolenaar

unread,
May 22, 2022, 3:37:30 PM5/22/22
to vim...@googlegroups.com, Tavis Ormandy

Tavis Ormandy wrote:

> Hello! I quite like the combination of incsearch and hlsearch, but hate
> the way it scrolls the screen to matches -- I only want the hilights
> without the scrolling.
>
> I thought maybe I could fix this with autocommands, but I can't get it
> to work, e.g.. I thought this might work:
>
> autocmd CmdlineEnter / mark S
> autocmd CmdlineChanged * normal g`S
>
> But that doesn't do anything, any ideas?

Not sure if there is a way to do this currently. There actually is code
to restrict the matches to a line range, it is used for a command like
":1,30s/pat". So you could somehow fill in the line numbers at the top
and bottom of the window, type the pattern, then remove the text before
the pattern when starting to search. But that's an ugly hack.

I'm not against adding an option for this, but we currently have no
option to change how 'incsearch' works. Adding Yet Another Option?

--
hundred-and-one symptoms of being an internet addict:
268. You get up in the morning and go online before getting your coffee.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Tavis Ormandy

unread,
May 22, 2022, 5:18:47 PM5/22/22
to vim...@googlegroups.com
On 2022-05-22, Bram Moolenaar wrote:
>> I thought maybe I could fix this with autocommands, but I can't get it
>> to work, e.g.. I thought this might work:
>>
>> autocmd CmdlineEnter / mark S
>> autocmd CmdlineChanged * normal g`S
>>
>> But that doesn't do anything, any ideas?
>
> Not sure if there is a way to do this currently. There actually is code
> to restrict the matches to a line range, it is used for a command like
> ":1,30s/pat". So you could somehow fill in the line numbers at the top
> and bottom of the window, type the pattern, then remove the text before
> the pattern when starting to search. But that's an ugly hack.

Hah! I guess you mean something like this:

nno / :call feedkeys(":" . line('w0') . "," . line('w$') . "s /")<CR>
cnoremap <expr> <CR> (getcmdline() =~ '^\d\+,\d\+s /' ? "<Home><S-Right><C-U><Del><CR>" : "<CR>")

It's a bit scary, but it does sorta work! Do you think that will break
anything?

>
> I'm not against adding an option for this, but we currently have no
> option to change how 'incsearch' works. Adding Yet Another Option?
>

Naturally, I vote yes :)

Tavis.
Reply all
Reply to author
Forward
0 new messages