Enable the display of line numbers in Visual Studi

2019-01-31 02:11发布

Why doesn't Visual Studio have any way of showing line numbers in a source file? Is there any way to enable it, or a plugin for it? I know that the number of lines of code in a program doesn't matter, but sometimes it is nice to know how long a program is or the number of a particular line for reference.

Though I tried, I can't seem to find a way to enable line numbering and I find that surprising.

This is Visual Studio 2010 Ultimate. (If you have read my older questions, I've been using 2008 Express until now.)

15条回答
Evening l夕情丶
2楼-- · 2019-01-31 02:56

For me, line numbers wouldn't appear in the editor until I added the option under both the "all languages" pane, and the language I was working under (C# etc)... screen capture showing editor options

查看更多
走好不送
3楼-- · 2019-01-31 02:57

In Visual Studio 2013 & 2015 :

Tools -> Options -> Text Editor -> All Languages -> check Line Numbers enter image description here

查看更多
再贱就再见
4楼-- · 2019-01-31 02:57

It's not enabled by default but you can enable it by going to:

  1. Click Tools
  2. Options
  3. Text Editor (expand)
  4. All Languages
  5. Line Numbers (Checkbox)
  6. Click Ok

settings

查看更多
做个烂人
5楼-- · 2019-01-31 02:58

You should edit "settings.json". In that add, "editor.lineNumbers":"on", . You can check comments for various options you have.

In Visual Studio Code - 2017, you can also directly go to a given line number. There are following three ways to do that.

  1. Directly use keyboard shortcut - Ctrl + G.
  2. Under menu Go, use Go to Line - Go > Go to Line
  3. Search for Go to Line in Command Pallete (Cmd + Shift + P).
查看更多
Melony?
6楼-- · 2019-01-31 02:59

In Visual Studio 2010 Express, there is an option called "Show all Settings". Located at "Tools > Options", window.

enter image description here

If this option is not checked, the line number option will not be available. Make sure this option is checked like shown below. This will make lot of additional settings visible in the tree view to the left.

enter image description here

Now this will make the option "Tools > Options > Text Editor > C# > General > Line Editor" available. Check the "Line Number" option to make line numbers visible on Visual Studio 2010 Express.

enter image description here

查看更多
别忘想泡老子
7楼-- · 2019-01-31 03:03

In VS 2010:

Tools > Settings > Expert Settings

Then:

Tools > Options > Show all settings > Text editor > C# > General > Check Line Numbers (checkbox)

查看更多
登录 后发表回答