• Login
Community
  • Login

How to fold code block that use the same keyword

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
2 Posts 2 Posters 240 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.
  • B
    byzod
    last edited by Jan 13, 2024, 8:24 AM

    In my case it’s autohotkey. ahk v2 changes the situational hotkey syntax, now it always use #Hotif

    Example:

    #HotIf WinActive("ahk_exe Nienix.exe")
    	a::
    	{
    		Send "{b}"
    	}
    	c::{
    		Send "{d}"
    	}
    #HotIf
    
    #HotIf WinActive("ahk_exe starfield.exe")
    	e::
    	{
    		Send "{f}"
    	}
    	g::
    	{
    		Send "{h}"
    	}
    #HotIf
    

    I was trying to use redundant { and } to fold #hotif block but was told try not to since it may define function by accident then cause error due to the new syntax

    But the UDL seems not recognize exact same keyword as beginning and ending of code folding (link://npp-user-manual.org/docs/user-defined-language-system/#udl-configuration-tabs) (I was flagged as spam come on this is npp site lol, so plz change link in the link to https )

    I think of a makeshift way by define #hotif\r\n as ending part, but the UDL seems not accept #hotif\r\n, nor #hotif`r`n, nor #hotif^r^n, nor #hotif$

    Is it possible to fold #hotif block using UDL tool?


    Some old language has this problem too, for example vba but I found a different behavior of it
    For this code, the default highlighting system can’t fold sub or with

    Sub HighlightLowerThanValues()
    With Selection.FormatConditions(1)
    .Font.Color = RGB(0, 0, 0)
    .Interior.Color = RGB(217, 83, 79)
    End With
    End Sub
    

    But with this code, it can fold sub and with

    Sub HighlightLowerThanValues()
    	With Selection.FormatConditions(1)
    		.Font.Color = RGB(0, 0, 0)
    		.Interior.Color = RGB(217, 83, 79)
    	End With
    End Sub
    

    I checked the langs.xml but it has no special settings, only keyword

    <Language name="vb" ext="vb vbs" commentLine="&apos;" commentStart="" commentEnd="">
        <Keywords name="instre1">addhandler addressof alias ... until where yield</Keywords>
    

    Is this behavior hard coded in npp? Can it be done with UDL?

    S 1 Reply Last reply Jan 13, 2024, 9:35 AM Reply Quote 0
    • S
      supasillyass @byzod
      last edited by Jan 13, 2024, 9:35 AM

      @byzod You can add EndHotIf to the Close section of Folding in comment style, then comment the closing tag:

      #HotIf WinActive("ahk_exe Nienix.exe")
      	a::
      	{
      		Send "{b}"
      	}
      	c::{
      		Send "{d}"
      	}
      #HotIf ; EndHotIf
      
      1 Reply Last reply Reply Quote 0
      1 out of 2
      • First post
        1/2
        Last post
      The Community of users of the Notepad++ text editor.
      Powered by NodeBB | Contributors