开发者

Relative line numbers in Visual Studio

I'm pretty sure I know the answer to this one cause I've been searching everywhere, but if anyone knows he's probably on this site.

Is it possible to display line numbers that are relative to the cursor position in Visual Studio? The line where the cursor is would 开发者_如何转开发always be 0, the line above would be 1 as well as the line below, etc.

Perhaps there is an addin that can do that? Given that other addins like Rockscroll can modify the margins in the VS text editor.

Thanks!


Since VSCode 1.6 you can set editor.lineNumbers with the value of relative in the settings.json file or in File>Preferences>Settings.

Relative line numbers in Visual Studio


Seems most extensions for relative line numbers do not support Visual Studio 2022 yet.

Fortunately, if you use VsVim, it supports this directly. But it needs to enabled with :set relativenumber.

To make it persistent, create a .vimrc (%userprofile%\.vimrc) with this content:

set relativenumber


You may want to check out my RelativeLineNumbers Visual Studio 2010 extension. Hope you find it useful.


For Visual Studio 2019 and vsvim users, Relative Number will now do the job.

Note that if you had regular line numbers in Visual Studio, this will show you 2 line numbers columns by default. You can disable VS default line numbers, and :set number and :set nonumber will toggle the extension's column.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜