- Line numbers in text editor
- 7 Answers 7
- texstudio: show line numbers in editor
- 3 Answers 3
- The line number on the SQL Editor in DBeaver
- 4 Answers 4
- Not the answer you’re looking for? Browse other questions tagged dbeaver or ask your own question.
- Related
- Hot Network Questions
- Subscribe to RSS
- Show line number in script editor
- 2 Answers 2
- How can I show line numbers in Eclipse?
- 16 Answers 16
- In Eclipse Mars 4.5.1, line numbers are (annoyingly) turned off by default again. Follow the below instructions to enable it.
- Line numbers are default in Eclipse SDK Luna (4.4) as of today
Line numbers in text editor
Okay this sounds like a question a six year old would ask, (and I hope there is an empirical answer) so here’s my inner child: In programming numbers start from from zero but why do line numbers in text editors (for programming) also start from one?
7 Answers 7
Line numbers need to be countable. It is more intuitive to start counting at 1 instead of 0 , because 0 (say: zero) means none, not one.
Looking at a coffee mug on your table, you would not answer the question of how many mugs there are by saying: «Zero» — because that would imply no mug at all is on your table. Thus with line numbers, and almost every other countable thing there is, you’d start with 1 for logic reasons.
Your real questions should be: Why on earth do array indices and the like start from 0 in programming! 🙂
Kontur is correct. But I would also like the add that Arrays in programming start at 0 for a very specific reason. This is not because the number in an array is supposed to ‘count’ the amount of elements, but instead it is considered an offset value, and thus array[0] merely means that the specific entry is 0 memory positions away from the start of the array in memory and array[1] is 1 position along. They are not used for counting purposes but as an offset meaning it is perfectly logical that programming lists start at 0.
Early languages like FORTRAN had the first element of an array starting with 1, and it was weird when C came along to use 0. That’s only natural to you youngsters. FORTRAN started with 1 because it was natural to number things in a list starting with 1. C started with 0 because it was a language deliberately written to be close to the hardware, whereas FORTRAN was abstracting the mathematical concepts with no idea as to how the computer would implement it. Of course we had to be able to know in some cases how the code was implemented in machine language, but in general C is much closer to the hardware.
It is purely historical / traditional / cultural. In many ways one can argue that line numbers should start at zero. But text editors have always labeled the first line as line one, and any editor that labeled it as zero would be outcast.
Generally, the difference between starting at 1 and starting at zero is whether you are «counting» or «measuring». If you measure a highway, it is clear that the point where the highway starts is «zero». But what do you call that first mile? Is it «mile 0» or is it the «first mile»? Both are acceptable depending upon whether you are measuring the distance, or counting the miles. This is very much like centuries: 1950 is the middle of the «20th century». The distinction is the 1950 is a measure of the time since the beginning (except there was no year zero, another historical anomaly) and the other is a counting of the centuries.
In an array, we are «measuring» to the position, and this is preferred not because it is closer to the hardware, but because the math works out easier. The first element in an array is always 0 units from the beginning of the array. This becomes quite apparent when you have an array of arrays. Imagine an array of decades, each element of which is an array of years. You would want the years to run 0 thru 9 to represent a decade like 1950 thru 1959. While it could be implemented either way (the first year of the decade is 1950, which is zero years from the start of the decade). The math is easier if the you can simply subtract to find the offset = (year — decade_start).
All that being said, the logic is that the first line of a text file really should be called «line 0» because you are measuring the position in the text file. But it is not. I don’t believe there is a logical reason for that, but simply that it has been traditionally labeled with a «1». Perhaps in the same tradition that the first year in the Gregorian calendar is named «1» as well.
texstudio: show line numbers in editor
How do I show line numbers in the editor? According to the picture in the doc (e.g. about bookmarks) there should appear by default.
I’m using Texstudio version 2.7, win8.1.
3 Answers 3
Under preferences, tick the ‘Show Advanced Options’ checkbox in the bottom left of the window, several new menu items are made available, including ‘Adv. Editor’.
Under ‘Adv. Editor’, under Appearance section, there is a drop-down box ‘Show Line Numbers’:
OK, here are the complete instructions for turning on line numbering for the linux version of TexStudio: Options > Configure TexStudio (then tick Show Advanced Options box in lower left corner of window. At that point a new entry will appear Adv. Editor. Select that. On the third line down in the new window will be an option to turn on line numbering.
In newer versions (at least in TeXstudio 2.12.22 on Win10) you find it in «Editor» (not any more «Advanced Editor»)
- Options
- Configure TeXstudio
- Use Editor options («Editor» on the left)
- Activate line numbers (select «All lines and numbers» in drop down menu «Show line numbers»)
alternatively you could use the «(option filter)» to find it faster (Type it in the current GUI-language, not in english)
The line number on the SQL Editor in DBeaver
How to toggle the line number on the SQL Editor in DBeaver?
I can’t find this option in Window / Preferences / General / Editors / SQL Editor.
Is it possible to do this?
4 Answers 4
It is now under Window / Preferences / General / Editors / Text Editors but as @simhumileco pointed out there is a shortcut in the context menu when you right-click the left gutter of the editor.
Right click on left column of SQL Editor and click Show / Hide Line Numbers from context menu.
Window > Preferences > General > Editors > Text Editors Then, select the checkbox «Show Line Numbers»
You can follow the below steps:
Not the answer you’re looking for? Browse other questions tagged dbeaver or ask your own question.
Related
Hot Network Questions
Subscribe to RSS
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev 2021.4.16.39093
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.
Show line number in script editor
Is there any way in a standard R environment how to show cursor position (at least line number) in script editor in R? I’ve tried to look at options but no success.
I am using R for Windows (XP, 7, ..).
2 Answers 2
According to Ben Bolkers’ comments, it is not possible in current version of R (until someone hacks it).
Try R studio. It is perfect IDE for R development, I think that it has feature like this.
I think there comes a point where — if you’re at all serious — you need to consider something more powerful than a text editor. Once you’ve come to that conclusion, the second thing you need to consider is whether you will be using the platform only for R or for other languages as well.
If you are coding only in R I think RStudio makes a lot of sense and you should certainly try it. For me it didn’t quite ‘fit’ my way of working and in addition to R I use Perl and a bit of Python so I wanted something that could handle multiple languages. I eventually decided on and now use Emacs with ESS. This is not as obviously attractive and modern as RStudio but it is powerful, flexible and runs on just about any machine.
Vincent Goulet’s package of Emacs and ESS for Windows is a good way to get started. Originally I liked KomodoIDE but R is not explicitly supported by ActiveState and I couldn’t get it to work with R using third-party utilities so in the end I went with ESS. ESS has been a good choice for me.
How can I show line numbers in Eclipse?
How can I show line numbers by default in Eclipse?
16 Answers 16
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:
Right click the gutter and select «Show Line Numbers»:
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.
Update November 2015:
In Eclipse Mars 4.5.1, line numbers are (annoyingly) turned off by default again. Follow the below instructions to enable it.
Update December 2013:
Line numbers are default in Eclipse SDK Luna (4.4) as of today
(December 10, 2013)
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:
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.
Update August 2014
Line number default length is now 120 (instead of 80) for Eclipse Mars 4.5M1.
See «How to customize Eclipse’s text editor code formating».
Original answer (March 2009)
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:
(with [workspace] being the root directory of your eclipse workspace)
Then eclipse will be opened with «line numbers shown ‘by default’ «
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.
Or you can just type «numb» in Windows Preferences to access to the Text Editor part: