如何在 Eclipse 中显示行号?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/640884/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I show line numbers in Eclipse?
提问by fbernier
How can I show line numbers by defaultin Eclipse?
如何在 Eclipse 中默认显示行号?
回答by fbernier
Window → Preferences → General → Editors → Text Editors → Show line numbers.
Window → Preferences → General → Editors → Text Editors → Show line numbers。
Edit: I wrote this long ago but as @ArtOfWarfar and @voidstate mentioned you can now simply:
编辑:我很久以前写过这个,但正如@ArtOfWarfar 和@voidstate 提到的,你现在可以简单地:
Right click the gutter and select "Show Line Numbers":
右键单击装订线并选择“显示行号”:
回答by voidstate
If this doesn't work it may be overridden by your current settings. You can right-click in the bar to the left of the code where line numbers would normally appear and turn them on with the context menu.
如果这不起作用,它可能会被您当前的设置覆盖。您可以右键单击代码左侧通常会出现行号的栏中,然后使用上下文菜单将其打开。
回答by VonC
Update November 2015:
2015 年 11 月更新:
In Eclipse Mars 4.5.1, line numbers are (annoyingly) turned off by default again. Follow the below instructions to enable it.
在 Eclipse Mars 4.5.1 中,默认情况下再次(令人讨厌地)关闭行号。按照以下说明启用它。
Update December 2013:
2013 年 12 月更新:
Lars Vogeljust published on his blog:
Line numbers are default in Eclipse SDK Luna (4.4) as of today
截至今天,行号是 Eclipse SDK Luna (4.4) 中的默认值
(December 10, 2013)
(2013 年 12 月 10 日)
We conducted a user survey if users want to have line numbers activated in text editors in the Eclipse IDE by default.
The response was very clear:
如果用户希望在 Eclipse IDE 的文本编辑器中默认激活行号,我们进行了一项用户调查。
回应非常明确:
YES : 80.07% (1852 responses)
NO : 19.93% (461 responses)
Total : 2313
Skipped: 15
With Bug 421313, Review - Line number should be activated by default, we enabled it for the Eclipse SDK build, I assume other Eclipse packages will follow.
对于错误 421313,默认情况下应激活 Review-Line 编号,我们为 Eclipse SDK 构建启用了它,我假设其他 Eclipse 包将跟随。
Update August 2014
2014 年 8 月更新
Line number default lengthis now 120(instead of 80) for Eclipse Mars 4.5M1.
See "How to customize Eclipse's text editor code formating".
Eclipse Mars 4.5M1 的行号默认长度现在为120(而不是 80)。
请参阅“如何自定义 Eclipse 的文本编辑器代码格式”。
Original answer (March 2009)
原始答案(2009 年 3 月)
To really have it by default, you can write a script which ensure, before launching eclipse, that:[workspace]\.metadata\.plugins\org.eclipse.core.runtime\.settings\org.eclipse.ui.editors.prefs
does contain:
要在默认情况下真正拥有它,您可以编写一个脚本来确保在启动 eclipse 之前:[workspace]\.metadata\.plugins\org.eclipse.core.runtime\.settings\org.eclipse.ui.editors.prefs
确实包含:
lineNumberRuler=true
(with [workspace]
being the root directory of your eclipse workspace)
Then eclipse will be opened with "line numbers shown 'by default' "
([workspace]
作为 eclipse 工作区的根目录)
然后 eclipse 将使用“默认显示的行号”打开
Otherwise, you can also type 'CTRL+1' and then "line", which will give you access to the command "Show line numbers"
(that will switch to option "show line numbers" in the text editors part of the option.
否则,您还可以键入“CTRL+1”,然后键入“line”,这将使您可以访问“显示行号”命令
(这将在选项的文本编辑器部分切换到“显示行号”选项。
Or you can just type "numb" in Windows Preferences to access to the Text Editor part:
或者您可以在 Windows 首选项中输入“numb”来访问文本编辑器部分:
Picture from "How to display line numbers in Eclipse" of blog "Mkyong.com"
图片来自博客“ Mkyong.com”的“如何在Eclipse中显示行号”
回答by shaby
As simple as that. Ctrl+F10, then N, to Show or hide line numbers.
就如此容易。 Ctrl+ F10,然后N,显示或隐藏行号。
Reference : http://www.shortcutworld.com/en/win/Eclipse.html
回答by crsierra
Slight variation on Mac OSX:
Eclipse → Preferences → General → Editors → Text Editors → Show line numbers
Mac OSX 上的细微变化:
Eclipse → Preferences → General → Editors → Text Editors → Show line numbers
回答by HANU
Windows → Preferences → General → Text Editors → Show numberlines
Windows → 首选项 → 常规 → 文本编辑器 → 显示数字线
回答by Antonio Leite
in this file
在这个文件中
[workspace].metadata.plugins\org.eclipse.core.runtime.settings\org.eclipse.ui.editors.prefs
[工作区].metadata.plugins\org.eclipse.core.runtime.settings\org.eclipse.ui.editors.prefs
make sure the parameter
确保参数
lineNumberColor=0,0,0
lineNumberColor=0,0,0
is NOT 255,255, 255, which is white
不是 255,255, 255,这是白色
回答by bhejaFry
Go to Windows → Preferences → General → Text Editors → Show numberlines. Click OK, then Apply changes. Then it will show the line count automatically.
转到 Windows → 首选项 → 常规 → 文本编辑器 → 显示数字线。单击确定,然后应用更改。然后它会自动显示行数。
回答by Arul Pandian
one of the easy way is using shortcuts like : Ctrl+F10, then press n "it show line number and hide line numbers.
一种简单的方法是使用诸如 Ctrl+F10 之类的快捷方式,然后按 n "它显示行号并隐藏行号。
回答by Ujjwal Roy
Open Eclipse
打开日食
goto -> Windows -> Preferences -> Editor -> Text Editors -> Show Line No
转到 -> Windows -> 首选项 -> 编辑器 -> 文本编辑器 -> 显示行号
Tick the Show Line Nocheckbox
勾选显示行无复选框