-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Conversation
642c256
to
93d069f
Compare
The request suggested a way to set the formatting of 'number' and 'relativenumber'. |
This doesn't check format string is number literal. |
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 ") |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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/
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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'") |
There was a problem hiding this comment.
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'* |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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'.
Agreed, if we want to have a new (window-local) option, it should cover number and relativenumber format. Perhaps something like |
Right. I'll work on that. |
@jeanCarloMachado Any progress on this? |
The request for this feature was made in this issue /issues/1875
and this pr /pull/680.