Vim: Support smart relative line numbers

Created on 4 Sep 2018  路  13Comments  路  Source: VSCodeVim/Vim

Is your feature request related to a problem? Please describe.
It would be nice if there was a configuration option such that line numbers are relative when jumping might be used (example:10j), and absolute when they could not.

Describe the solution you'd like
My suggestion would be to have a configuration option smartRelativeLineNumbers that, when enabled, overrides user settings on line numbers and turns on relative line numbering in normal and visual modes, and absolute in insert mode.

Describe alternatives you've considered
Chintzy plugins.
aiotecism/amVim, which enables this feature, but is otherwise not as good of a plugin for my needs.

Additional context
n/a

help wanted kinfeature

Most helpful comment

Hi, I was wondering if work on this feature is still in progress?

All 13 comments

https://code.visualstudio.com/updates/v1_6#_improvements-to-linenumber-and-whitespace-settings

This was implemented earlier but looks like we have a bug somewhere https://github.com/VSCodeVim/Vim/issues/423

Sorry, @jpoon, I'm confused, does this implement exactly what I was asking for? That is, does it switch the line numbers from absolute to relative when in normal and visual mode? or does it add a completely separate gutter like the commenter mentioned in the other issue? Or is it relative line numbers across the board? It's unclear.

Ah, I misread the issue. The PR fixes the support for relative numbers (:set relativenumber), but you'll have to toggle it manually when switching modes to get what you asked for.

Is there a VIM-equivalent setting of what you are asking for? The smartRelativeLineNumbers option you suggest seems like it would be very custom to this extension.

I believe @flowchartsman is after something like this plugin: https://github.com/jeffkreeftmeijer/vim-numbertoggle

Basically, enabling relative line numbers when it makes sense (in the active split, when in visual mode) and using regular line numbers when in insert mode, and for inactive splits.

That is correct. Relative line numbers in active split, in visual or normal modes. As it is implemented in one of the alternative vim plugins. https://github.com/aioutecism/amVim-for-VSCode/issues/197 (I just don't like this plugin as much, so I'd love to have it here :D )

@jpoon can you please re-open this issue?

Re-opened. Apologies I misunderstood.

I'd love to see this introduced and I'm happy to code it up myself, but this isn't my primary language, and I don't know the project that well. Would anyone be willing to pair up with me to help solve it?

@flowchartsman I am willing to pair after work hours (some time after maybe 5 or 6pm EDT). Implementation doesn't look bad in that PR you linked. If convenient, you can send me a message on Slack (@shawnaxsom on our Slack channel. You might want to check out our contributing guide as well.

Will do, thanks!

Hi, I was wondering if work on this feature is still in progress?

Test build in case anyone wants to try it out!
vim-1.14.5-pr5010.vsix.zip

@aymanbagabas works great, thank you! Hoping to see #5010 merged, this is a great feature!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

elithrar picture elithrar  路  3Comments

orn688 picture orn688  路  3Comments

gerardmrk picture gerardmrk  路  3Comments

spinningarrow picture spinningarrow  路  3Comments

liamdawson picture liamdawson  路  3Comments