• Login
Community
  • Login

Code folding help

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
5 Posts 2 Posters 559 Views
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.
  • V
    Vindicit
    last edited by May 5, 2022, 6:28 PM

    So Im trying to use code folding. I’m not sure what language I am working with so I am trying to create my own language setting. My open line in the code looks like “Macro XXXXXXX” my end code is just “End”. So my open fold is just “Macro”.

    |Macro XXXXXX
    |mid
    |mid
    |End

    The issue I’m having is within the code there is “Attribute End” and “End Object” which is hanging up the end fold. How do I specify my closing fold as just “End” by itself with a new line afterwards?

    P 1 Reply Last reply May 5, 2022, 8:22 PM Reply Quote 0
    • P
      PeterJones @Vindicit
      last edited by May 5, 2022, 8:22 PM

      @vindicit ,

      Unfortunately, as far as I know, you cannot do that by itself.

      The logic for determining the folding is pretty simple, and cannot handle restricted cases such as that. (It was more designed with simple pairs like if / endif in mind, where there is no ambiguity.)

      However, if you can nest something like "attribute begin" / "attribute end" inside, then you could set
      OPEN = "attribute begin" macro
      CLOSE = "attribute end" end
      then this text

      blah
      
      macro
      
      attribute begin
      
      attribute end
      
      end
      
      blah
      

      will fold as:
      b12035ea-9e9d-4a98-99e6-f172110c1dab-image.png
      … so the attribute begin / attribute end is a nested fold inside of the other

      But that requires that anything with “end” in it be able to be added in the list (and the one that’s just-plain-“end” has to be the last version in the list).

      1 Reply Last reply Reply Quote 0
      • V
        Vindicit
        last edited by May 6, 2022, 10:04 AM

        Thanks Ill take a look at that.

        1 Reply Last reply Reply Quote 0
        • V
          Vindicit
          last edited by Vindicit May 6, 2022, 10:46 AM May 6, 2022, 10:44 AM

          So I took a look at the code and it has as an example

          Macro XXXXX
          
          Begin Object XXX
          
          Attributes Beg
          Attributes End
          
          End Object XXX
          End
          

          So In the folding in code 2 style I have
          Macro “Begin Object” “Attributes Beg”

          In close I have
          “End Object” “Attributes End” End

          Does this look right? It seems to work.

          P 1 Reply Last reply May 6, 2022, 1:09 PM Reply Quote 0
          • P
            PeterJones @Vindicit
            last edited by May 6, 2022, 1:09 PM

            @vindicit ,

            If it works for you, that’s the important thing. I always keep the pairs in the same order, so I would have said OPEN = "begin object" "attributes beg" macro and CLOSE = "end object" "attributes end" end so that the object-pair were the first tokens in each, the attributes-pair were the second tokens in each, and the macro-pair were the third tokens in each. But that doesn’t seem to be required.

            1 Reply Last reply Reply Quote 1
            5 out of 5
            • First post
              5/5
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors