Defining Region focused on current page

20 views
Skip to first unread message

Ni Va

unread,
Feb 26, 2015, 10:14:48 AM2/26/15
to vim...@googlegroups.com
Hi,

I would like to define a region based on current page displayed of opened buffer.

How can I define that ?

Gary Johnson

unread,
Feb 26, 2015, 10:31:40 AM2/26/15
to vim...@googlegroups.com
I don't know what you mean by "define a region", but you can
visually select all the lines on the current displayed page with

HVL

H moves the cursor to the first line of the window; V starts
visual mode linewise; L moves the cursor to the last line of the
window.

Regards,
Gary

Ni Va

unread,
Feb 26, 2015, 10:57:47 AM2/26/15
to vim...@googlegroups.com, gary...@spocom.com
Hi Gary,

I know visual selection but I just want to define a region to set this command line :

syntax sync region ... in order to do syn only on current displayed page

Ni Va

unread,
Feb 26, 2015, 11:28:48 AM2/26/15
to vim...@googlegroups.com, gary...@spocom.com
It's ok I have just modified vim74/syntax/xml.vim in order to synchronize only onto 100 fewer lines

syn sync minlines=100
syn sync maxlines=100

Paul Isambert

unread,
Feb 26, 2015, 11:34:34 AM2/26/15
to vim...@googlegroups.com
See “:help \%l” and “:help line()” (especially with “w0” and “w$”) and
you should be able to do something like:

exec 'syntax region YourRegion start=+\\%' . line('w0') . 'l+ end=+\\%' . line('w$') . 'l+'

Best,
Paul

Gary Johnson

unread,
Feb 26, 2015, 1:20:24 PM2/26/15
to vim...@googlegroups.com
The trouble with that is that the line() functions are evaluated
only at the time the exec command is executed, so the region remains
the lines in the window at the time the syntax file was sourced.

I discovered that the other day when I tried doing something similar
with matchadd(), \%l and line("'a"). After seeing the result, it
was "obvious" why it failed. I wound up evaluating the matchadd()
in a CursorHold autocommand.

Regards,
Gary

Reply all
Reply to author
Forward
0 new messages