Re: cursorline and long lines

105 views
Skip to first unread message

Christian Brabandt

unread,
Mar 29, 2012, 3:31:46 PM3/29/12
to vim_use, Vim ML
Bram,

On Mi, 28 M�r 2012, Abu Yoav wrote:

[...]
> I am editing a text file (latex). I prefer that each paragraph be a
> long line, and that vim wrap the text. That's the usual behaviour, and
> that works fine. An option that seems very helpful is cursorline, so I
> set it (":set cul"). However, this does not do what I want. Namely,
> instead of highlighting the *visual* line I am on, it highlights the
> whole paragraph. Is there any way to highlight only the current visual
> line I am on? Again, a workaround would be to instruct vim to have
> lines of at most 80 characters (say), but I don't want that.

The help for 'cursorline' says:

,----
| Highlight the screen line of the cursor with CursorLine
`----

While 'cul' has always been highlighting complete lines. Do you think,
this would warrant a new option, that changes 'cul' to only highlight
screen lines or change the option 'cul' to a string option, that can be
set to 'screen' or 'line'?

This might be helpful for long lines (e.g. when editing csv files and
wrap is set).

If not, the documentation should be updated.

regards,
Christian
--
Der Furchtsame erschrickt vor der Gefahr, der Feige in ihr, der Mutige
nach ihr.
-- Jean Paul (eig. Johann Paul Friedrich Richter)

Gary Johnson

unread,
Mar 29, 2012, 6:41:02 PM3/29/12
to vim_use, Vim ML
On 2012-03-29, Christian Brabandt wrote:
> Bram,
>
> On Mi, 28 M�r 2012, Abu Yoav wrote:
>
> [...]
> > I am editing a text file (latex). I prefer that each paragraph be a
> > long line, and that vim wrap the text. That's the usual behaviour, and
> > that works fine. An option that seems very helpful is cursorline, so I
> > set it (":set cul"). However, this does not do what I want. Namely,
> > instead of highlighting the *visual* line I am on, it highlights the
> > whole paragraph. Is there any way to highlight only the current visual
> > line I am on? Again, a workaround would be to instruct vim to have
> > lines of at most 80 characters (say), but I don't want that.
>
> The help for 'cursorline' says:
>
> ,----
> | Highlight the screen line of the cursor with CursorLine
> `----
>
> While 'cul' has always been highlighting complete lines. Do you think,
> this would warrant a new option, that changes 'cul' to only highlight
> screen lines or change the option 'cul' to a string option, that can be
> set to 'screen' or 'line'?
>
> This might be helpful for long lines (e.g. when editing csv files and
> wrap is set).
>
> If not, the documentation should be updated.

Or declare it a bug and fix the behavior to match the documentation.

Regards,
Gary

Christian Brabandt

unread,
Mar 30, 2012, 3:07:52 AM3/30/12
to vim_use, Vim ML

Well, here is a patch, that fixes it. I am not sure, whether this
is a bug and this patch certainly makes 'cul' behave unexpectedly.

Would be good, if some people try it out,
because the screen drawing code looks frightening to me ;)

regards,
Christian

cursorline.diff

Ingo Karkat

unread,
Mar 30, 2012, 4:52:45 AM3/30/12
to vim...@googlegroups.com
On 29-Mar-2012 15:41:02 -0700, Gary Johnson wrote:

> On 2012-03-29, Christian Brabandt wrote:

>> [14 lines deleted]


>> The help for 'cursorline' says:
>>
>> ,----
>> | Highlight the screen line of the cursor with CursorLine
>> `----
>>
>> While 'cul' has always been highlighting complete lines. Do you think,
>> this would warrant a new option, that changes 'cul' to only highlight
>> screen lines or change the option 'cul' to a string option, that can be
>> set to 'screen' or 'line'?
>>
>> This might be helpful for long lines (e.g. when editing csv files and
>> wrap is set).
>>
>> If not, the documentation should be updated.
>
> Or declare it a bug and fix the behavior to match the documentation.

While I see value in the proposed change, I prefer to keep the old behavior,
too. It subtly reminds me that I'm editing a long physical line with 'wrap' on,
and helps me in choosing j/k or gj/gk for navigation. Since this hasn't been
brought up since 'cursorline's introduction in Vim 7.0, I guess that the
majority doesn't object to the current behavior, neither.

-- regards, ingo

sc

unread,
Mar 30, 2012, 10:39:22 AM3/30/12
to vim...@googlegroups.com

i'm +1 liking the current behavior too, ingo

i'd like to at least keep it as an option

sc

Ben Fritz

unread,
Mar 30, 2012, 11:01:24 AM3/30/12
to vim...@googlegroups.com
On Friday, March 30, 2012 3:52:45 AM UTC-5, Ingo Karkat wrote:
>
> While I see value in the proposed change, I prefer to keep the old behavior,
> too. It subtly reminds me that I'm editing a long physical line with 'wrap' on,
> and helps me in choosing j/k or gj/gk for navigation. Since this hasn't been
> brought up since 'cursorline's introduction in Vim 7.0, I guess that the
> majority doesn't object to the current behavior, neither.
>

I only ever use cursorline and cursorcolumn for three reasons:

1) most common: I don't immediately see the cursor and want to quickly find it. I have a mapping to toggle cursorcolumn and cursorline.
2) sometimes with f, F, t, and T, combined with ; and ,, it's hard to see where the cursor is currently. I have mappings for these commands which highlight the character in question in the current line and also set cursorline and cursorcolumn.
3) when editing tables, where I want to see a visual indication of the entire current line in the table

(1) and (2) are worthless on long wrapped lines. For (3) I always have 'nowrap' set anyway. I find cursorline with 'wrap' set to be almost completely useless. I certainly support making cursorline and cursorcolumn work on the *visual* line and column. What are they for, if not for locating the cursor?

I consider this a bug, but as long as there is an option which makes it act "correctly" I'll be happy. I haven't spoken up because I figured it TECHNICALLY does highlight the line I'm on, it's just not useful in that case. Others probably don't even use the option, because of the prominent warning in the help that it will slow down performance (is this really a concern on a modern machine?).

I see Ingo's point about an indication of a long wrapped line, but I've already mapped j/k to gj/gk, and the line numbers/showbreak is enough for me to see that I'm on a long line. As indicated, I rarely keep cursorline and cursorcolumn on for very long, so the extra indication won't work for me anyway.

Bram Moolenaar

unread,
Mar 30, 2012, 3:35:52 PM3/30/12
to Christian Brabandt, vim_use, Vim ML

Christian Brabandt wrote:

I don't think we should change the current meaning of 'cursorline'.
What the original poster asked for is something else.

Since 'cursorline' is a boolean option we can't change it to be more
than an on/off switch.

That leaves adding Yet Another Option...

- Bram

--
A KNIGHT rides into shot and hacks him to the ground. He rides off.
We stay for a moment on the glade. A MIDDLE-AGED LADY in a C. & A.
twin-set emerges from the trees and looks in horror at the body of her
HUSBAND.
MRS HISTORIAN: FRANK!
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

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

Ingo Karkat

unread,
Mar 30, 2012, 3:53:06 PM3/30/12
to vim...@googlegroups.com
On 30-Mar-2012 21:35, Bram Moolenaar wrote:

> [41 lines deleted]


>
> I don't think we should change the current meaning of 'cursorline'.
> What the original poster asked for is something else.
>
> Since 'cursorline' is a boolean option we can't change it to be more
> than an on/off switch.
>
> That leaves adding Yet Another Option...

We have a similar precedent of two linked options: 'number' and
'relativenumber', and that seems to work fine, with one resetting the other when
set. I also like that in that case, one can set one in a window and the other in
another one, depending on what kind of text is being edited. (As we've already
learned that cursorline is used for many different purposes.)

How about naming it 'cursorscreenline', or maybe 'cursordisplayline'?

-- regards, ingo

Yichao Zhou

unread,
Mar 30, 2012, 10:31:17 PM3/30/12
to vim...@googlegroups.com
> --
> You received this message from the "vim_dev" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php


For relativeline, I hope that we can have another setting such as
`cursorscreenline` which is really useful in tex.

Christian Brabandt

unread,
Mar 31, 2012, 7:12:52 AM3/31/12
to vim_use, Vim ML
Bram,

On Fr, 30 M�r 2012, Bram Moolenaar wrote:
> That leaves adding Yet Another Option...

have you ever thought about providing some kind of a generic option
setting, that could be easily extendible for such small settings.

Something similar to the 'fo' and 'cpo' settings

e.g. set generic=cursorline:screenline
or something? And then when another new minor setting is needed, one
could extend it to something like this:

set generic=cursorline:screenline,foo:foobar

Does that sound reasonable?

Mit freundlichen Gr��en
Christian

Christian Brabandt

unread,
Mar 31, 2012, 9:56:37 AM3/31/12
to Vim ML
Hi Bram!

On Fr, 30 M�r 2012, Bram Moolenaar wrote:

Here is a patch, using 'cursorscreenline'. Seems to work so far.
Additionally, it fixes a problem, that has been introduced with 7.3.479
where the cursorline wasn't drawn, when the number or relativenumber
option was set (line 3508 of screen.c) and removes an old leftover from
option.c, which doesn't seem to be necessary.

regards,
Christian

cursorscreenline.diff

Bram Moolenaar

unread,
Mar 31, 2012, 11:46:57 AM3/31/12
to Christian Brabandt, Vim ML

Christian Brabandt wrote:

Thanks. I'll check it out.

--
The greatest lies of all time:
(1) The check is in the mail.
(2) We have a really challenging assignment for you.
(3) I love you.
(4) All bugs have been fixed.
(5) This won't hurt a bit.
(6) Honey, I just need to debug this program and be home in 5 minutes.
(7) I have just sent you an e-mail about that.
(8) Of course I'll respect you in the morning.
(9) I'm from the government, and I'm here to help you.

Bram Moolenaar

unread,
Mar 31, 2012, 11:46:57 AM3/31/12
to Christian Brabandt, vim_use, Vim ML

Christian Brabandt wrote:

How is this better than adding an option?

--
He was not in the least bit scared to be mashed into a pulp
Or to have his eyes gouged out and his elbows broken;
To have his kneecaps split and his body burned away
And his limbs all hacked and mangled, brave Sir Robin.


"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\

Reply all
Reply to author
Forward
0 new messages