Regular expression tokens to identify *screen* lines?

17 views
Skip to first unread message

Tim Chase

unread,
Oct 30, 2023, 7:50:35 PM10/30/23
to Vim Users
I was playing around with tokens like

:help /\%l

and was curious if there was a way to identify *screen* lines rather
than *file* lines. So imagining something like "\%5H" or "\%3L"
would match the fifth-from-top line or the third-from-bottom line
of the screen.

The initial idea was some sort of focused-writing where the top/bottom
lines were dark-gray, getting progressively brighter in white-ness
moving toward the center of the screen where the cursor-line (done
with underline) would be kept in the middle with a high 'scrolloff'
value. Maybe using syntax highlighting or :match-style invocations.

It was mostly an boondoggle idea, so please nobody spend vast amounts
of time on this silliness, but if there something obvious I've
missed for "fade out text around the cursor" sort of functionality.

Thanks for any thoughts, pointers, ideas though. :-)

-tim


(all kicked off by thinking about this thread

https://www.reddit.com/r/vim/comments/17jkv50/vim_for_a_non_coder/

where folks were referring to focus-writer-like functionality to
keep the focus around the cursor-line, so it was just a conceptual
plaything)





Christian Brabandt

unread,
Oct 31, 2023, 9:56:46 AM10/31/23
to vim...@googlegroups.com

On Mo, 30 Okt 2023, Tim Chase wrote:

> I was playing around with tokens like
>
> :help /\%l
>
> and was curious if there was a way to identify *screen* lines rather
> than *file* lines. So imagining something like "\%5H" or "\%3L"
> would match the fifth-from-top line or the third-from-bottom line
> of the screen.

I am pretty sure we do not have regex atoms for screen lines.

> The initial idea was some sort of focused-writing where the top/bottom
> lines were dark-gray, getting progressively brighter in white-ness
> moving toward the center of the screen where the cursor-line (done
> with underline) would be kept in the middle with a high 'scrolloff'
> value. Maybe using syntax highlighting or :match-style invocations.
>
> It was mostly an boondoggle idea, so please nobody spend vast amounts
> of time on this silliness, but if there something obvious I've
> missed for "fade out text around the cursor" sort of functionality.
>
> Thanks for any thoughts, pointers, ideas though. :-)

Perhaps with some reasonable nice looking highlighting group, you can
use :set cursorlineopt=screenline. Or perhaps one can script something
by throwing in marks to delimit the region and then match it using the
\%'m atom (or possibly you don't even need the marks you can just try to
get the virtcol for the region and then use the \%v atom instead).

Thanks,
Christian
--
Drop in any mailbox.
Reply all
Reply to author
Forward
0 new messages