Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add relativenumberformat option #2204

Closed
wants to merge 1 commit into from

Conversation

jeanCarloMachado
Copy link

@jeanCarloMachado jeanCarloMachado commented Oct 12, 2017

The request for this feature was made in this issue /issues/1875
and this pr /pull/680.

@louwers
Copy link

louwers commented Oct 12, 2017

The request suggested a way to set the formatting of 'number' and 'relativenumber'.

@mattn
Copy link
Member

mattn commented Oct 12, 2017

This doesn't check format string is number literal.

@mattn
Copy link
Member

mattn commented Oct 12, 2017

It may be crashed when using %s.

@@ -5571,6 +5571,15 @@ A jump table for the options with a short description can be found at |Q_op|.
NOTE: This option is set to the Vi default value when 'compatible' is
set and to the Vim default value when 'compatible' is reset.

*'relativenumberformat'* *'rnfm'*
'relativenumberformat' 'rnfm' string (default "%-*ld ")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the default is "%*ld ".

global
{not in Vi}
Format the ":relativenumber" command output.
This is a scanf-like string. For example, if you want to
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/scanf-like/printf-like/

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this pull request at all (for one thing, because it only incorporates custom formatting for relativenumber, not for number), but with regard to your comment here I have to be fair: Bram calls it scanf-like for the grepformat option.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

grepformat is used for scanning the output of grepprg, however this is used for printing the line number. So printf-like is suitable here.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right! Perhaps it's a good idea to put a tag to printf(), because otherwise the documentation is not self contained (not everyone using vim will be familar with printf).

@@ -1138,6 +1138,8 @@ if has("quickfix")
call append("$", "grepprg\tprogram used for the \":grep\" command")
call append("$", "\t(global or local to buffer)")
call <SID>OptionG("gp", &gp)
call append("$", "relativenumberormat\tlist of formats for output of 'relativenumber'")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/relativenumberormat/relativenumberformat/

@@ -5571,6 +5571,15 @@ A jump table for the options with a short description can be found at |Q_op|.
NOTE: This option is set to the Vi default value when 'compatible' is
set and to the Vim default value when 'compatible' is reset.

*'relativenumberformat'* *'rnfm'*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block should be moved after *'relativenumber'*. (Should be in alphabetical order.)

@@ -5571,6 +5571,15 @@ A jump table for the options with a short description can be found at |Q_op|.
NOTE: This option is set to the Vi default value when 'compatible' is
set and to the Vim default value when 'compatible' is reset.

*'relativenumberformat'* *'rnfm'*
'relativenumberformat' 'rnfm' string (default "%-*ld ")
global
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'relativenumber' option is "local to window". Should't be the same?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense.

@@ -61,6 +61,7 @@
#define PV_BT OPT_BUF(BV_BT)
#ifdef FEAT_QUICKFIX
# define PV_EFM OPT_BOTH(OPT_BUF(BV_EFM))
# define PV_RNFM OPT_BOTH(OPT_BUF(BV_RNFM))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You put this line inside #ifdef FEAT_QUICKFIX, however this is not a part of the quickfix feature.
It should be moved to outside of the #ifdef.

Additionally, you implemented this as "global or local to buffer" (:help global-local), but I think it should be "local to window" (as I wrote above).
Please check the implementation of 'rnu'.

@chrisbra
Copy link
Member

Agreed, if we want to have a new (window-local) option, it should cover number and relativenumber format. Perhaps something like :set numberformat=nu:%-*ld,rnu:%*ld or something like that? Also a test would be needed.

@jeanCarloMachado
Copy link
Author

Right. I'll work on that.

@azat-io
Copy link

azat-io commented Apr 3, 2018

@jeanCarloMachado Any progress on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants