The line number (position) of a line of text or code inside a file, often for debugging.
Questions tagged [line-numbers]
369 questions
42
votes
16 answers
Why did we bother with line numbers at all?
When you write something in BASIC, you are required to use line numbers. Like:
10 PRINT "HOME"
20 PRINT "SWEET"
30 GOTO 10
But I wonder: who came up with the idea to use line numbers at all? It is such a nuisance, and left quite an "echo" in the…

oɔɯǝɹ
- 7,219
- 7
- 58
- 69
42
votes
4 answers
Command for toggling line numbers in vi
I know
:set number
and
:set nonumber
I want to know whether there is any command in vi/vim
:set togglenumber
to display line number if the line numbers is not showing or hiding line numbers if line numbers is showing.

Mohammed H
- 6,880
- 16
- 81
- 127
41
votes
6 answers
How can I use #pragma message() so that the message points to the file(lineno)?
In order to add 'todo' items into my code, I want to put a message in the compiler output.
I would like it to look like this:
c:/temp/main.cpp(104): TODO - add code to implement this
in order to make use of the Visual Studio build output…

xtofl
- 40,723
- 12
- 105
- 192
39
votes
4 answers
How can I print source line number in Perl?
Is it possible to get the current source line number in Perl?
The equivalent in C++ is __LINE__.

David Sykes
- 48,469
- 17
- 71
- 80
31
votes
3 answers
How to insert a counter into a Stream .forEach()?
FileWriter writer = new FileWriter(output_file);
int i = 0;
try (Stream lines = Files.lines(Paths.get(input_file))) {
lines.forEach(line -> {
try {
writer.write(i + " # " + line +…

Vega
- 2,661
- 5
- 24
- 49
28
votes
6 answers
Relative Line Numbers In Emacs
Does anyone know how if something like this Vim Relative Line Numbers exists for emacs? I use vimpulse, and man, that would be super handy to have! I know some lisp, so if it doesn't, I could try to make my own, if I got a point in the right…

Steve
- 1,596
- 1
- 10
- 21
27
votes
5 answers
Read lines by number from a large file
I have a file with 15 million lines (will not fit in memory). I also have a small vector of line numbers - the lines that I want to extract.
How can I read-out the lines in one pass?
I was hoping for a C function that does it on one pass.

Aleksandr Levchuk
- 3,751
- 4
- 35
- 47
26
votes
2 answers
Current line number from a System.Xml.XmlReader (C# & .Net)
Does anyone know how I can get the current line number of an System.Xml.XmlReader? I am trying to record where in a file I find Xml elements.

Danielb
- 1,608
- 5
- 24
- 34
24
votes
4 answers
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…
Flawe
19
votes
7 answers
Show line number in exception handling
How would one display what line number caused the error and is this even possible with the way that .NET compiles its .exes?
If not is there an automated way for Exception.Message to display the sub that crapped out?
try
{
int x =…

Crash893
- 11,428
- 21
- 88
- 123
18
votes
2 answers
Make Distraction Free mode show line numbers in Pycharm/Intellij
Like the title suggests, when I use Distraction Free mode in PyCharm or Intellij I cannot see the line numbers, even though I have ticked the "line numbers" box in the settings. Is there a way to make the line numbers appear on Distraction Free…

Aventinus
- 1,322
- 2
- 15
- 33
18
votes
4 answers
Finding out what line number an element in the dom occurs on in Javascript?
Though I've never heard of this but, is it possible to retrieve a node from the DOM using JS, and then find out on what line of the file that node occurred on?
I'm open to anything, alternative browsers plugins/add-ons etc...it doesn't need to be…

leeand00
- 25,510
- 39
- 140
- 297
17
votes
4 answers
WPF RichTextBox to create editor with line numbers
I'm creating a text editor for a domain specific language. I'm using the WPF RichTextBox as the basic control. I don't know how to gracefully include line numbering. Does anyone know of any examples?

John Alden
- 171
- 1
- 1
- 3
17
votes
3 answers
Does tmux support relative line-numbers?
Background.
I am a frequent vim-user, I just love the way you can navigate the buffers without ever having to reach for the mouse. I'm especially fond of the relative line numbers that let's me jump to specific lines with perfect accurecy, it just…

Master Wo
- 215
- 2
- 7
17
votes
4 answers
search text file using c# and display the line number and the complete line that contains the search keyword
I require help to search a text file (log file) using c# and display the line number and the complete line that contains the search keyword.

Chitresh
- 405
- 1
- 6
- 16