[vim/vim] Alignment of Vim relative numbers (#1875)

159 views
Skip to first unread message

Azat S.

unread,
Jul 25, 2017, 5:04:31 AM7/25/17
to vim/vim, Subscribed

Is there any way to align current line number to right? It looks strange by default, current line is aligning to left. Why there is not option to change it?

I tried to find a solution with :help cul

This thing looks ugly

vim


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub

Anton

unread,
Jul 25, 2017, 6:01:14 AM7/25/17
to vim/vim, Subscribed

This behavior is hardcoded. You can only modify it and recompile

Azat S.

unread,
Jul 25, 2017, 7:17:56 AM7/25/17
to vim/vim, Subscribed

@gapeevanton Sounds bad. Maybe there is some instructions for solving this problem? Why is the alignment change not provided?

Christian Brabandt

unread,
Jul 25, 2017, 4:16:11 PM7/25/17
to vim/vim, Subscribed

No there is no other possibility, except if you want to abuse the sign feature for that. Note, we are trying avoid adding options for such small things (this might be debatable here). However, there is already #680 and #1368 in which a 'numberformat' option has been whished. However, a patch which includes a test would be appreciated :)

Azat S.

unread,
Jul 25, 2017, 5:09:42 PM7/25/17
to vim/vim, Subscribed

@chrisbra Thank you for the answer. I hope 'numberformat' option will be released

cecamp

unread,
Jul 27, 2017, 11:51:50 PM7/27/17
to vim/vim, Subscribed
Christian Brabandt wrote:
>
> No there is no other possibility, except if you want to abuse the sign
> feature for that. Note, we are trying avoid adding options for such
> small things (this might be debatable here). However, there is already
> #680 <https://github.com/vim/vim/pull/680> and #1368
> <https://github.com/vim/vim/issues/1368> in which a 'numberformat'
> option has been whished. However, a patch which includes a test would
> be appreciated :)
>
>
Before the relative numbering patch was accepted into vim's source, I
wrote RltvNmbr (a plugin) that "abused" signs to do relative numbering.
I noted that it too had single digit numbers left justified; it was using
string(L)
(where L held the current linenumber).

So, I tried changing it to printf("%2d",L) . I'm afraid that the signs
feature does not approve of leading spaces. So I don't think one can
successfully abuse the sign feature for right-justified relative numbering.

Just thought I'd point that out!

Chip Campbell

Bee

unread,
Jul 28, 2017, 1:26:25 AM7/28/17
to vim_dev, v...@noreply.github.com, subsc...@noreply.github.com, reply+00b1d1988daaaf4b25456eebb8d485e762a54fd...@reply.github.com, vim-dev...@256bit.org
On Tuesday, July 25, 2017 at 2:04:31 AM UTC-7, Azat S. wrote:
> Is there any way to align current line number to right? It looks strange by default, current line is aligning to left. Why there is not option to change it?

There is one option:

:se nonu rnu

It will right align the current line,
BUT
the current line number is then '0'
which, to me, makes more sense with 'relative' numbering

vim-dev ML

unread,
Jul 28, 2017, 1:26:46 AM7/28/17
to vim/vim, vim-dev ML, Your activity
On Tuesday, July 25, 2017 at 2:04:31 AM UTC-7, Azat S. wrote:
> Is there any way to align current line number to right? It looks strange by default, current line is aligning to left. Why there is not option to change it?

There is one option:

:se nonu rnu

It will right align the current line,
BUT
the current line number is then '0'
which, to me, makes more sense with 'relative' numbering

Azat S.

unread,
Jul 28, 2017, 5:24:40 AM7/28/17
to vim/vim, vim-dev ML, Mention

@vim-ml Maybe. But I want to see exactly the number of the current line


You are receiving this because you were mentioned.

Azat S.

unread,
Sep 21, 2017, 4:25:14 PM9/21/17
to vim/vim, vim-dev ML, Mention

Any progress?


You are receiving this because you were mentioned.

Christian Brabandt

unread,
Sep 22, 2017, 2:54:12 AM9/22/17
to vim/vim, vim-dev ML, Mention

nobody has worked on that feature as far as i know. If you really want this feature, you could try the other issues perhaps there is a PR that implements your behaviour. We would need tests for the feature and some feedback how it works would be appreciated as well.


You are receiving this because you were mentioned.

Konstantin Kharlamov

unread,
Jul 9, 2018, 8:33:43 AM7/9/18
to vim/vim, vim-dev ML, Mention

This behavior is hardcoded. You can only modify it and recompile

Actually, I was about to report a bug, but discovered this request for an option.

Could alignment be hardcoded to right? I really don't see a reason why would it be hardcoded into an such odd position, which feels like it takes an additional space for no reason (although aligns correctly at a thousand of lines). It looks as if hybrid numbers were hacked up on an UI that isn't really suited for that.


You are receiving this because you were mentioned.

Nazri Ramliy

unread,
Jul 9, 2018, 7:20:40 PM7/9/18
to vim_dev, reply+00b1d19872561229a0f2ca85669dbaec8689554...@reply.github.com, vim/vim, vim-dev ML, Mention
On Mon, Jul 9, 2018 at 8:33 PM, Konstantin Kharlamov
<vim-dev...@256bit.org> wrote:
> This behavior is hardcoded. You can only modify it and recompile
>
> Actually, I was about to report a bug, but discovered this request for an
> option.
>
> Could alignment be hardcoded to right? I really don't see a reason why would
> it be hardcoded into an such odd position, which feels like it takes an
> additional space for no reason (although aligns correctly at a thousand of
> lines). It looks as if hybrid numbers were hacked up on an UI that isn't
> really suited for that.

For me having the current line number at the "odd position" makes it
easier to spot the current line. Compare:

3 one
2 two
1 three
4 four
1 five

vs:

3 one
2 two
1 three
4 four
1 five

In the former I have to scan the numbers to see which line is the
current one, while in the latter the current line number is easy to
spot.

nazri

vim-dev ML

unread,
Jul 9, 2018, 7:20:56 PM7/9/18
to vim/vim, vim-dev ML, Your activity

Tony Mechelynck

unread,
Jul 9, 2018, 8:05:49 PM7/9/18
to vim/vim, vim-dev ML, Mention

I agree with Nazri, especially since in the default highlighting the coulours for the current and relative line numbers are not very different: both in bright yellow in a (dark) cterm, or relative numbers in brown and current line in bold brown in the (light) GUI.

The current behaviour seems intentional, see the examples at :help number_relativenumber.

Best regards,
Tony.


You are receiving this because you were mentioned.

Konstantin Kharlamov

unread,
Jul 10, 2018, 2:41:12 AM7/10/18
to vim/vim, vim-dev ML, Mention

Okay, I respect other's workflow. The problem is that it doesn't work well even for your usecase. The behavior would make sense if it was always aligned, but it's not: if the file have between 100 and 999 lines, then anywhere at 100..999 it's aligned to right. Same for 1000..9999. This only doesn't hold for 1..9 and 10..99, dunno why — but then, files typically have more than 100 lines.


You are receiving this because you were mentioned.

Lifepillar

unread,
Jul 10, 2018, 2:51:42 AM7/10/18
to vim/vim, vim-dev ML, Mention

The behavior would make sense if it was always aligned, but it's not

That depends on numberwidth. Set it to a higher value and you'll see a consistent behaviour.


You are receiving this because you were mentioned.

Tony Mechelynck

unread,
Jul 10, 2018, 3:16:07 AM7/10/18
to vim/vim, vim-dev ML, Mention

Also, if I'm at a "late" line in the file, it stands out by the mere fact that its high number is in the middle of one-digit numbers, e.g. 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 6543, 1, 2, 3, … OTOH, in the case of 4, 3, 2, 1, 5, 1, 2, 3, … the 5 would be much less obvious if it were aligned with the others (and, as with the default colorscheme, in the same or almost the same colour).

Best regards,
Tony.


You are receiving this because you were mentioned.

Konstantin Kharlamov

unread,
Jul 10, 2018, 8:14:55 AM7/10/18
to vim/vim, vim-dev ML, Mention

I'm wondering, can we come to a compromise that doesn't look as if the feature was hacked up on a UI that requiring rewriting in the first place. How about using bold, italic, or a color to highlight the current line?


You are receiving this because you were mentioned.

Konstantin Kharlamov

unread,
Jul 10, 2018, 9:01:23 AM7/10/18
to vim/vim, vim-dev ML, Mention

Another point for using a different way to highlight the current number: have anybody tried hybrid line-numbers in Arabic mode? If you open e.g. vim -A /etc/profile you'll find that the current line-number melds with the current line, i.e. there's no space between them.

I bet you can add right-to-left-language users to the list of unhappy ones.


You are receiving this because you were mentioned.

Nick Jensen

unread,
Jul 11, 2018, 8:06:36 PM7/11/18
to vim/vim, vim-dev ML, Mention

@Hi-Angel The CursorLineNr highlight group can be used to highlight the number however you want:

:highlight CursorLineNr cterm=bold,italic gui=bold,italic


You are receiving this because you were mentioned.

Konstantin Kharlamov

unread,
Jul 12, 2018, 2:10:22 AM7/12/18
to vim/vim, vim-dev ML, Mention

@Hi-Angel The CursorLineNr highlight group can be used to highlight the number however you want:

:highlight CursorLineNr cterm=bold,italic gui=bold,italic

Great! Given that part is solved, are we changing the current line to align to the left, or is there anything else is blocking?


You are receiving this because you were mentioned.

Christian Brabandt

unread,
Jul 13, 2018, 6:14:18 PM7/13/18
to vim/vim, vim-dev ML, Mention

duplicate of #2204


You are receiving this because you were mentioned.

Christian Brabandt

unread,
Jul 13, 2018, 6:14:20 PM7/13/18
to vim/vim, vim-dev ML, Mention

Closed #1875.


You are receiving this because you were mentioned.

Konstantin Kharlamov

unread,
Jul 14, 2018, 4:27:42 AM7/14/18
to vim/vim, vim-dev ML, Mention

@chrisbra you linked a PR. An issue can not be a duplicate of PR (especially of one referring back to the same issue). An issue can be solved by PR, but for that PR needs to be accepted, and the one you linked haven't been.


You are receiving this because you were mentioned.

Christian Brabandt

unread,
Jul 14, 2018, 5:24:20 AM7/14/18
to vim/vim, vim-dev ML, Mention

Yes I did and I personally don't like to have PRs and issues for the same thing laying around, because it happens often enough that the corresponding PR get's closed once Bram merges it and the issue keeps laying around open and no one notices it. I personally like to have the issues in a manageable state, which would not be the case and as you can see from the issue number, we have already several hundred open issues here, which is barely manageable by the maintainers here. It does not help anybody to have this issue list here becoming a bare garbage dump site. So my decision stands. Thanks for understanding.


You are receiving this because you were mentioned.

Jonathan Wren

unread,
Jul 21, 2020, 8:20:18 PM7/21/20
to vim/vim, vim-dev ML, Mention

Is there any chance of reviving this issue since the associated PR was abandoned?


You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub, or unsubscribe.

Jonathan Wren

unread,
Jul 21, 2020, 8:22:10 PM7/21/20
to vim/vim, vim-dev ML, Mention

Also, I know this is years later and probably irrelevant by now, but did you know that putting the text "Fixes #1875" in the description of PR will automatically close that issue when the PR is merged? Makes keeping issues and PRs in sync much more manageable.

K.Takata

unread,
Jul 21, 2020, 8:38:05 PM7/21/20
to vim/vim, vim-dev ML, Mention

Reopening, then. If someone wants this, please take over #2204.

but did you know that putting the text "Fixes #1875" in the description of PR will automatically close that issue when the PR is merged?

Bram doesn't use the merge button, so it doesn't work.

K.Takata

unread,
Jul 21, 2020, 8:38:07 PM7/21/20
to vim/vim, vim-dev ML, Mention

Reopened #1875.

Jonathan Wren

unread,
Jul 21, 2020, 9:10:21 PM7/21/20
to vim/vim, vim-dev ML, Mention

Bram doesn't use the merge button, so it doesn't work.

It also works in commit messages, but fair enough. I don't want to mess with someone's work flow.

Thanks for reopening!

askfiy

unread,
Jun 19, 2022, 2:36:32 AM6/19/22
to vim/vim, vim-dev ML, Mention

Well, I think this function should be necessary


Reply to this email directly, view it on GitHub.
You are receiving this because you were mentioned.Message ID: <vim/vim/issues/1875/1159628734@github.com>

Reply all
Reply to author
Forward
0 new messages