• Login
Community
  • Login

Highlighting range between brackets in a .php file with html code as well

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
phpbracketshtml
32 Posts 6 Posters 14.9k 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.
  • M
    Marco Czen
    last edited by Marco Czen Dec 18, 2017, 11:14 AM Dec 18, 2017, 11:12 AM

    Hi, I have several php files that have html code in them as well.
    Is there a way to enable highlighting of php brackets from opening tag to closing tag which may span over html blocks as well ?

    Right now, when 1 select an opening php tag { , it becomes bold white and the closing } becomes bold white as well.

    But if there is a lot of code in between them, its easy to miss the closing tag.

    Any plugin that can provide this feature ? Or any edit to a notepad file to enable this ?

    Thanks.

    S A 2 Replies Last reply Dec 18, 2017, 2:55 PM Reply Quote 2
    • S
      Scott Sumner @Marco Czen
      last edited by Dec 18, 2017, 2:55 PM

      @Marco-Czen

      Well, you could do some fancy stuff with regular expression Marking that gets nice and complicated when dealing with nested open/close delimiters…

      Or maybe this is simpler. Try this (default keycombos shown):

      • move caret to opening (or closing) delimiter
      • press Ctrl+Alt+B (menu-equivalent command: Search (menu) -> Select All Between Matching Braces)
      • press Ctrl+F1 (menu-equivalent command: Search (menu) -> Mark All > Using 1st Style
      M 2 Replies Last reply Dec 21, 2017, 9:27 AM Reply Quote 3
      • C
        chcg
        last edited by Dec 19, 2017, 6:20 PM

        Also slightly off topic, maybe this plugin could be of help:
        https://github.com/StanDog/npp-phpautocompletion

        M 1 Reply Last reply Dec 22, 2017, 4:22 AM Reply Quote 0
        • A
          Alan Kilborn @Marco Czen
          last edited by Dec 20, 2017, 1:43 AM

          @Marco-Czen

          I think @Scott Summer’s idea is a really good one, but why not take it one step further and record those 2 actions into a single-keystroke macro?

          M 2 Replies Last reply Dec 21, 2017, 12:37 PM Reply Quote 2
          • G
            guy038
            last edited by guy038 Dec 20, 2017, 8:48 PM Dec 20, 2017, 8:48 PM

            Hello @marco-czen, and All,

            You may, also, be interested in the possibilities of recursive regular expressions, discussed, five months ago, in that post, below :

            https://notepad-plus-plus.org/community/topic/14090/best-way-to-find-unmatched-parentheses/5

            Read, particularly, the practical part, for Rowan, near the end, as well as the P.S. part, that I’ve just added this evening ( in France ! )

            Best Regards,

            guy038

            1 Reply Last reply Reply Quote 1
            • M
              Marco Czen @Scott Sumner
              last edited by Dec 21, 2017, 9:27 AM

              @Scott-Sumner - Noted. Thanks. Will revert.

              1 Reply Last reply Reply Quote 0
              • M
                Marco Czen @Alan Kilborn
                last edited by Marco Czen Dec 21, 2017, 12:38 PM Dec 21, 2017, 12:37 PM

                @Alan-Kilborn - Ohhh … How do we do that ?
                Man … its just so difficult to participate in these discussions … Evwerytime i wanna post , it makes me wait 1200s !!!
                WTH ???

                Is there a site admin who I can talk to ? If i am spamming, blocking me would get rid of me …but blocking posts from somebody who wants to ask notepad related questions is just plain **&^%$%

                S 1 Reply Last reply Dec 21, 2017, 12:55 PM Reply Quote 1
                • S
                  Scott Sumner @Marco Czen
                  last edited by Dec 21, 2017, 12:55 PM

                  @Marco-Czen

                  I gave you two upvotes so you should be able to post without waiting now.

                  To record macros, see the first 4 entries on the Macro menu. It’s pretty self-explanatory, but if you have trouble, just ask here…

                  M 1 Reply Last reply Dec 21, 2017, 12:58 PM Reply Quote 0
                  • M
                    Marco Czen @Scott Sumner
                    last edited by Dec 21, 2017, 12:57 PM

                    @Scott-Sumner said:

                    press Ctrl+Alt+B (menu-equivalent command: Search (menu) -> Select All Between Matching Braces)

                    Ayyway i can make the above become a key combo like Ctrl+B ( like Ctrl+T for matching tags) or just expand Ctrl + T to also match php braces ?

                    Ohhh waitt … Need to wait 1200s again !!! Cant a 60s delay suffice ???

                    S 1 Reply Last reply Dec 21, 2017, 1:02 PM Reply Quote 0
                    • M
                      Marco Czen @Scott Sumner
                      last edited by Dec 21, 2017, 12:58 PM

                      @Scott-Sumner - Oh god … Thanks buddy … What a relief …

                      1 Reply Last reply Reply Quote 1
                      • S
                        Scott Sumner @Marco Czen
                        last edited by Dec 21, 2017, 1:02 PM

                        @Marco-Czen said:

                        can make the above become a key combo like Ctrl+B ( like Ctrl+T for matching tags) or just expand Ctrl + T to also match php braces

                        If I were you I’d find an unused key-combination you like and assign your recorded macro to that. Trying to combine functionalities is difficult; can be done but usually involves scripting and you probably don’t want to go there.

                        M 1 Reply Last reply Dec 22, 2017, 4:24 AM Reply Quote 0
                        • M
                          Marco Czen @chcg
                          last edited by Dec 22, 2017, 4:22 AM

                          @chcg - Hi, how do we get this installed ? Have you noticed any performance issues ?

                          1 Reply Last reply Reply Quote 0
                          • M
                            Marco Czen @Scott Sumner
                            last edited by Dec 22, 2017, 4:24 AM

                            @Scott-Sumner - Roger that. Thanks. Posting few seconds after my other post … What a relief … heheheheheh :)

                            1 Reply Last reply Reply Quote 0
                            • M
                              Marco Czen @Alan Kilborn
                              last edited by Dec 22, 2017, 4:34 AM

                              @Alan-Kilborn - Tried this but my Macro kept going back to the same brace. I must be doing it wrong.

                              Instead i now just click on a brace and do Ctrl + Alt + B ( as pointed out by @Scott Sumner ) to go to the matching brace … its a pity there is no plugin for this yet.

                              Thanks.

                              C 1 Reply Last reply Dec 22, 2017, 11:42 AM Reply Quote 0
                              • C
                                Claudia Frank @Marco Czen
                                last edited by Dec 22, 2017, 11:42 AM

                                @Marco-Czen

                                close npp, open shortcuts.xml with a different editor and put the following into it.

                                    <Macro name="Mark_between_brackets" Ctrl="no" Alt="no" Shift="no" Key="0">
                                        <Action type="2" message="0" wParam="43023" lParam="0" sParam="" />
                                        <Action type="2" message="0" wParam="42020" lParam="0" sParam="" />
                                        <Action type="2" message="0" wParam="43009" lParam="0" sParam="" />
                                        <Action type="2" message="0" wParam="42020" lParam="0" sParam="" />
                                        <Action type="2" message="0" wParam="43022" lParam="0" sParam="" />
                                    </Macro>
                                

                                Save it, close it and start npp. You should now have a menu entry Mark_between_brackets
                                under Macro menu.

                                What it does is
                                43023 - clear any marking using style 1
                                42020 - start Begin/end select operation
                                43009 - go to matching brace end
                                42020 - end Begin/end select operation
                                43022 - mark active selection using style 1

                                Of course your cursor should be next to the brace to make this work.

                                Cheers
                                Claudia

                                M 1 Reply Last reply Dec 22, 2017, 2:19 PM Reply Quote 0
                                • G
                                  guy038
                                  last edited by guy038 Dec 22, 2017, 12:33 PM Dec 22, 2017, 12:33 PM

                                  Hi, @marco-czen, @claudia-frank and All,

                                  Marco,

                                  • Close any instance of N++

                                  • Open your active shortcuts.xml file, with an other text editor than N++ ( IMPORTANT )

                                  • Add, in the Macro section, these lines :

                                          <Macro name="Test" Ctrl="no" Alt="no" Shift="no" Key="0">
                                              <Action type="2" message="0" wParam="43023" lParam="0" sParam="" />
                                              <Action type="2" message="0" wParam="43053" lParam="0" sParam="" />
                                              <Action type="2" message="0" wParam="43022" lParam="0" sParam="" />
                                          </Macro>
                                  
                                  • Save the modifications

                                  • Open N++

                                  Done !

                                  Notes :

                                  • 43023 = Search > Unmark All > Clear 1st Style

                                  • 43053 = Search > Select All Between Matching Braces

                                  • 43022 = Search > Mark All > Using 1st Style

                                  • I named this macro Test. Of course, just change this name as you like !


                                  Claudia, am I missing something ? Your macro or mine give identical results !?

                                  Cheers,

                                  guy038

                                  C M 2 Replies Last reply Dec 22, 2017, 12:53 PM Reply Quote 1
                                  • C
                                    Claudia Frank @guy038
                                    last edited by Dec 22, 2017, 12:53 PM

                                    @guy038 said:

                                    Claudia, am I missing something ?

                                    No, definitively not :-) - I didn’t see it - need more coffee.
                                    Your macro, which is basically what Scott suggested, is the preferred one - good job.

                                    Cheers
                                    Claudia

                                    1 Reply Last reply Reply Quote 0
                                    • S
                                      Scott Sumner
                                      last edited by Dec 22, 2017, 1:11 PM

                                      @Claudia-Frank said:

                                      open shortcuts.xml with a different editor

                                      @guy038 said:

                                      Open your active shortcuts.xml file, with an other text editor than N++ ( IMPORTANT )

                                      I find, with a relatively recent version of N++ (e.g.s: 7.2.2, 7.5.3), that you don’t have to use a “different text editor” (blasphemy anyway!), as long as you haven’t changed via the N++ GUI any other settings that shortcuts.xml holds. Thus, when you quit N++ after editing shortcuts.xml file with it, N++ won’t feel the need to write out that file–and wipe out your manual edits.

                                      So if you change via the user interface any of these things you definitely don’t want to pull shortcuts.xml into an editing tab and start hacking on it:

                                      • shortcuts via the Shortcut Mapper (or by using the last menu item on the Macro or Run menus)
                                      • saved macros by using the macro recorder
                                      • saved Run menu items created via the Run -> Run… dialog box

                                      Of course, if you’re a noob or at all tentative about this, maybe the “different editor” approach IS best… :-)

                                      1 Reply Last reply Reply Quote 2
                                      • G
                                        guy038
                                        last edited by Dec 22, 2017, 2:03 PM

                                        Hi, @scott-sumner,

                                        Thanks for sharing this useful info ! So, seemingly, if you simply do these operations, below, the execution of a added macro should be OK :-))

                                        • Start Notepad++

                                        • Open your active Shortcuts.xml file

                                        • Copy, for instance, the Claudia’s macro, above, named Mark_between_brackets, on the black background ( Ctrl + C )

                                        • Add a new line at the end of the Macro section, before the ending tag </Macros>

                                        • Paste the macro contents ( Ctrl + V )

                                        • Save the new contents of Shortcuts.xml ( Ctrl + S )

                                        • Close then re-start N++… and enjoy !


                                        BTW, Scott, you said :

                                        you don’t have to use a “different text editor” (blasphemy anyway!)

                                        Yes, it’s a true nonsense, as Notepad++ IS THE text editor ;-))

                                        Best Regards,

                                        guy038

                                        M 1 Reply Last reply Dec 22, 2017, 2:28 PM Reply Quote 3
                                        • M
                                          Marco Czen @Claudia Frank
                                          last edited by Dec 22, 2017, 2:19 PM

                                          @Claudia-Frank - Niceeee

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