Add Line Number to selected text

DrScript
liyinghui
2004-04-16
2004-04-16
  • liyinghui

    liyinghui - 2004-04-16

    #drscript
    #This drScript can add line number to selected text base on 1
    #limodou(chatme@263.net) 2004/04/16
    #version 1.0
    text=DrDocument.GetSelectedText()
    lines=text.split('\n')
    endtext=''
    if lines[-1]=='':
        del lines[-1]
        endtext='\n'
    text="\n".join([ "%4d  %s" % (i+1, lines[i]) for i in range(len(lines))])
    text += endtext
    DrDocument.SetSelectedText(text)

     
    • liyinghui

      liyinghui - 2004-04-16

      All Indent disappear!

       
    • Daniel Pozmanter

      If you use "Replace Tabs With Spaces" before posting, you should be fine.

      #drscript
      #This drScript can add line number to selected text base on 1
      #limodou(chatme@263.net) 2004/04/16
      #version 1.0
      text=DrDocument.GetSelectedText()
      lines=text.split('\n')
      endtext=''
      if lines[-1]=='':
          del lines[-1]
      endtext='\n'
      text="\n".join([ "%4d %s" % (i+1, lines[i]) for i in range(len(lines))])
      text += endtext
      DrDocument.SetSelectedText(text)

       
    • liyinghui

      liyinghui - 2004-04-16

      Yes!
      #drscript
      #This drScript can add line number to selected text base on 1
      #limodou(chatme@263.net) 2004/04/16
      #version 1.0
      text=DrDocument.GetSelectedText()
      lines=text.split('\n')
      endtext=''
      if lines[-1]=='':
          del lines[-1]
          endtext='\n'
      text="\n".join([ "%4d  %s" % (i+1, lines[i]) for i in range(len(lines))])
      text += endtext
      DrDocument.SetSelectedText(text)

       
    • liyinghui

      liyinghui - 2004-04-16

      Oh, it doesn't work.

       

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks