line-numbers

Current line number from a System.Xml.XmlReader (C# & .Net)

感情迁移 提交于 2019-11-28 01:47:29
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. Take advantage of the IXmlLineInfo interface supported by an XmlReader : IXmlLineInfo xmlInfo = (IXmlLineInfo)reader; int lineNumber = xmlInfo.LineNumber; Expanding on the IXmlLineInfo interface, the documentation for this is pretty bad; from doing a bit of digging, I can tell you the following: 1) System.Xml.XmlReader is abstract, so you're never going to be dealing with an instance of this, as such, the fact that it doesn't implement IXmlLineInfo isn't

displaying line number in rich text box c#

不打扰是莪最后的温柔 提交于 2019-11-27 18:10:36
问题 I have a Multiline richtextbox control into which i want to integrate the feature of adding a line number. i have considered many approaches Add a label and updating the line numbers as the line count changes Add a picturebox along with to draw string on it. Add another textbox along with and show line numbers on it Add listbox along and display line numbers in it. I got two doubts. The richtextbox which i'm using is a custom made control and derieves from RichTextBox class. How can i add

Finding out what line number an element in the dom occurs on in Javascript?

女生的网名这么多〃 提交于 2019-11-27 15:50:37
问题 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 cross-browser per say. I would assume that this would be possible somehow considering that some JS debuggers are capable of finding the line number within a script tag, but I'm not entirely sure. 回答1: Ok, forgive me for how large this is. I thought

Why did we bother with line numbers at all? [closed]

会有一股神秘感。 提交于 2019-11-27 15:28:41
问题 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 developing (pun intended) world! 回答1: The idea back then was that you could easily add code everywhere in your program by using the appropriate line number. That's why everybody uses line numbers 10, 20, 30.. so there is room left: 10 PRINT "HOME" 20

Relative Line Numbers In Emacs

大兔子大兔子 提交于 2019-11-27 12:29:23
问题 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 direction. Update : Thanks to the correct response, I came up with this, that will show 1 for the current line, and -1 for the previous line, for combining with vimpulse yanks and deletes. Thanks a ton to all who helped! I know it is not exactly what Vim

Read lines by number from a large file

此生再无相见时 提交于 2019-11-27 10:20:58
问题 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. 回答1: The trick is to use connection AND open it before read.table : con<-file('filename') open(con) read.table(con,skip=5,nrow=1) #6-th line read.table(con,skip=20,nrow=1) #27-th line ... close(con) You may also try scan , it is faster and gives more control

Show line number in exception handling

百般思念 提交于 2019-11-27 07:51:29
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 = textbox1.Text; } catch(Exception ex) { MessageBox.Show(ex.Message); } Steven A. Lowe Use ex.ToString() to get the full stack trace. You must compile with debugging symbols (.pdb files), even in release mode, to get the line numbers (this is an option in the project build properties). To see the stacktrace for a given Exception, use e.StackTrace If you need more

Current line number from a System.Xml.XmlReader (C# & .Net)

梦想的初衷 提交于 2019-11-27 04:49:17
问题 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. 回答1: Take advantage of the IXmlLineInfo interface supported by an XmlReader : IXmlLineInfo xmlInfo = (IXmlLineInfo)reader; int lineNumber = xmlInfo.LineNumber; 回答2: Expanding on the IXmlLineInfo interface, the documentation for this is pretty bad; from doing a bit of digging, I can tell you the following: 1) System.Xml.XmlReader is abstract, so you're

Add line numbers to source code in vim

亡梦爱人 提交于 2019-11-27 02:31:40
How can I add line numbers to a range of rows in vim? Not as in ":set nu" - this just displays numbers, but doesn't add them to the file. Luc Hermitte With :%s/^/\=line('.')/ EDIT: to sum up the comments. This command can be tweaked as much as you want. Let's say you want to add numbers in front of lines from a visual selection ( V + move), and you want the numbering to start at 42. :'<,'>s/^/\=(line('.')-line("'<")+42)/ If you want to add a string between the number and the old text from the line, just concatenate (with . in VimL) it to the number-expression: :'<,'>s/^/\=(line('.')-line("'<")

search text file using c# and display the line number and the complete line that contains the search keyword

不羁的心 提交于 2019-11-27 02:04:30
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. This is a slight modification from: http://msdn.microsoft.com/en-us/library/aa287535%28VS.71%29.aspx int counter = 0; string line; // Read the file and display it line by line. System.IO.StreamReader file = new System.IO.StreamReader("c:\\test.txt"); while((line = file.ReadLine()) != null) { if ( line.Contains("word") ) { Console.WriteLine (counter.ToString() + ": " + line); } counter++; } file.Close(); Bit late to the game on this one, but happened