Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Printing Tab positions

    General Discussion
    4
    10
    2027
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Tim Eckersley
      Tim Eckersley last edited by

      Hi. Probably a very dumb question - but - I need to print a copy of some .vb code - on the screen display the tab positions are indicted by vertical lines of red dots. This actually makes the code easy to follow - I indent sections of the code. Is there any way to get these tab postions to print? Thank you, Tim

      1 Reply Last reply Reply Quote 0
      • PeterJones
        PeterJones last edited by PeterJones

        @Tim-Eckersley ,

        I assume you are talking about the View > Show Symbol > Show Indent Guide bars – the dotted vertical lines aren’t red for me, but we probably have different Settings > Style Configurator > Global Styles > Style=Indent Guideline Style settings.

        I tried making sure I was in Settings > Preferences > Print and setting Colour Options = WYSIWYG, but it didn’t print the indent-guide lines. As far as I can tell, that’s something that Notepad++ decided isn’t worth printing – though it’s quite possible someone else knows how to turn on that feature, even though I don’t know it.

        For a small document (that is completely visible in the current window), you could use Alt+PrintScreen, and paste it into mspaint, and print from there… So, if you’ve got a small document, and it won’t be frequent, this could be a workaround. But that’s not very useful under generic situations (and it’s a pain), so I don’t expect this to be a true solution.

        Sorry I couldn’t be more help. I started posting when I was just going to suggest trying to turn on/off WYSIWYG settings in the print settings, but decided I should try it myself, rather than making you do all the work. Unfortunately, when it didn’t work, I had no more ideas. I almost deleted my response before posting, rather than having my best advice be Alt+PrintScreen… but I (1) wanted you to know you weren’t being ignored, and that someone had put in at least a little effort to help you; (2) make use of the sunk-cost of my experiments, in some way (if nothing else, prevent others from duplicating my effort); (3) maybe by using the terminology of “indent guide”, which is how settings refer to it, it will click something in someone else’s mind.

        (edit: fix mismatched parentheses)

        Scott Sumner Tim Eckersley 2 Replies Last reply Reply Quote 2
        • Scott Sumner
          Scott Sumner @PeterJones last edited by

          @PeterJones

          Don’t second-guess yourself. Your post was valuable to me because it reminded me of the indent guide which had somehow gotten turned off (and I didn’t notice!). Thanks to your excellent help I quickly turned it on and made it a slightly different color. +1 is not enough. :-)

          1 Reply Last reply Reply Quote 0
          • Tim Eckersley
            Tim Eckersley @PeterJones last edited by

            @PeterJones Thank you Peter! That was kind of you! There are about 1500 lines of code. Maybe 21 pages or so in landscape. I may be forced to use the “print screen” option - as laborious as it is.

            The code will be viewed by folks who are not familiar with the language. Many years ago I got into the habit of indenting “nested” code. It seems to make it easier to follow. The vertical red dots were icing on the cake!

            Thank you again for your reply.

            Tim

            1 Reply Last reply Reply Quote 0
            • PeterJones
              PeterJones last edited by PeterJones

              Hmm… now you’ve got me thinking: could we automate the multiple-Alt+Printscreens using PythonScript? I’m thinking about how, doing some searches.

              In the mean time, you’re not the first to ask for this: back in 2010, Abyssoft asked for it on the old sourceforge forums. And a couple months ago, goosar19 asked for it on the github issues site.

              And while thinking about that, I had a flash: as a simpler method, assuming 4 spaces (not tabs) are used for indent. It could be customized, if you have different indent settings:

              1. Replace an indent-space with something visibly-similar to the dotted guide-line

                Search > Replace…
                Find What = (?=\x20|^)\x20\x20\x20\x20
                Replace With = \x{250A}\xA0\xA0\xA0
                Search Mode = Regular Expression
                REPLACE ALL

                The \x{250A} is this ┊ unicode character. Here are alternatives, depending on font support: Replace the above \x{250A} with one of the following:

                • BOX DRAWINGS LIGHT QUADRUPLE DASH VERTICAL U+250A ┊ = \x{250A}
                • BOX DRAWINGS LIGHT TRIPLE DASH VERTICAL U+2506 ┆ = \x{2506}
                • BOX DRAWINGS LIGHT VERTICAL U+2502 │ = \x{2502}
                • VERTICAL FOUR DOTS U+205E ⁞ = \x{250e} – if your font has it
                • VERTICAL ELLIPSES U+22EE ⋮ = \x{22ee}
                • a colon :=\x3A
                • a veritcal bar |=\x7C
              2. Print: might have to save first, though I didn’t in my experiments

              3. Undo should go back to the original. If not, this should take you back:

                Find What = \x{250A}\xA0\xA0\xA0
                Replace With = \x20\x20\x20\x20
                Search Mode = Regular Expression
                REPLACE ALL

              1 Reply Last reply Reply Quote 5
              • Eko palypse
                Eko palypse last edited by

                Not sure if this is helpful but I got something working doing this

                from Npp import notepad, editor, MENUCOMMAND
                
                def printIndent(numSpaces):
                    searchString = r'(?=\x20|^)' + '\x20'*numSpaces
                    editor.beginUndoAction()
                    editor.rereplace(searchString, r'\x7C\x20\x20\x20')
                    editor.endUndoAction()
                    notepad.menuCommand(MENUCOMMAND.FILE_PRINTNOW)
                
                printIndent(4)
                editor.undo()
                

                Note, I wasn’t able printing the vertical indentation line if replaced by the unicode thinggy chars.

                Eko

                Scott Sumner 1 Reply Last reply Reply Quote 3
                • Scott Sumner
                  Scott Sumner @Eko palypse last edited by

                  @Eko-palypse

                  I thought this script was rather interesting so I played with it a bit. I noticed a couple of things I didn’t like. First, it puts the indent marker in column 1 as well as other tabstop columns. Second, it will put the indent marker in for ANY occurrences of 4 (or whatever) spaces in a row, even if these contiguous spaces are not at start-of-line.

                  I managed to “improve” it a bit; here’s what I did (note I disabled the printing and put in some dummy lines to better show the effect):

                  from Npp import notepad, editor, MENUCOMMAND
                  
                  def printIndent(numSpaces):
                      # I'm    a            comment        with             embedded spaces   to show that I don't get replaced
                      numSpacesFormat = '{' + str(numSpaces) + '}'
                      searchString = r'((?<=[\r\n])\x20{nsf})|(\G\x20{nsf})'.format(nsf=numSpacesFormat)
                      replaceStringFormat = r'\x20' * (numSpaces - 1)
                      replaceString = r'(?1\x20{rsf})(?2|{rsf})'.format(rsf=replaceStringFormat)
                      editor.beginUndoAction()
                      editor.rereplace(searchString, replaceString)
                      editor.endUndoAction()
                      #notepad.menuCommand(MENUCOMMAND.FILE_PRINTNOW)
                      if 1:
                          pass
                      else:
                          pass
                          if 1:
                              pass
                          else:
                              pass
                              if 1:
                                  pass
                              else:
                                  pass
                                  if 1:
                                      pass
                                  else:
                                      pass
                  
                  printIndent(4)
                  #editor.undo()
                  

                  This version of the script will turn its own source code from “A” into “B”:

                  Here’s “A”:

                  Imgur

                  And here’s “B”:

                  Imgur

                  Eko palypse 1 Reply Last reply Reply Quote 3
                  • Eko palypse
                    Eko palypse @Scott Sumner last edited by

                    @Scott-Sumner

                    agreed, the version isn’t 100% bulletproofed and thx, it looks like your regex handles corner cases better
                    but if we take the initial question into account I would say the first indent guide should be visible as well.
                    But, of course, this depends on the usage and how some like to have it displayed at all :-)

                    Eko

                    Scott Sumner 1 Reply Last reply Reply Quote 2
                    • Scott Sumner
                      Scott Sumner @Eko palypse last edited by

                      @Eko-palypse

                      I would say the first indent guide should be visible as well

                      Hmmm…yes, I think I agree with you, for the printout. Viewing it only on the screen it is annoying; maybe that is what drove my original opinion. And…not having that column 1 marker made the regex part slightly more interesting. :-)

                      1 Reply Last reply Reply Quote 2
                      • Tim Eckersley
                        Tim Eckersley last edited by

                        Gentlemen, Thank you very much! I will try the methods that you have suggested. The suggestion to “find and replace” is great! Those vertical lines really do help…
                        Tim

                        1 Reply Last reply Reply Quote 3
                        • First post
                          Last post
                        Copyright © 2014 NodeBB Forums | Contributors