Community
    • Login

    load header file with same name as the current c file

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    14 Posts 4 Posters 2.0k 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.
    • Alan KilbornA
      Alan Kilborn
      last edited by Alan Kilborn

      I whipped up a quick script for this, for “associated” C/C++/H files. It would go nicely as a right-click context menu entry. :)

      import os
      temp_list = notepad.getCurrentFilename().rsplit('.', 1)
      if len(temp_list) == 2:
          ext = temp_list[1].lower()
          if ext in [ 'cpp', 'c', 'h' ]:
              all_except_ext = temp_list[0]
              if 'c' in ext:
                  assoc_file = all_except_ext + '.h'
              else:
                  assoc_file = all_except_ext + '.c'
                  if not os.path.exists(assoc_file): assoc_file = all_except_ext + '.cpp'
              if os.path.exists(assoc_file): notepad.open(assoc_file)
      
      1 Reply Last reply Reply Quote 4
      • Ion MarqvardsenI
        Ion Marqvardsen
        last edited by

        Thanks Alan! You make it sound easy.

        I know how to make changes to the contextMenu.xml file, to add or delete menu entries. But that is it.

        Is it possible to add your code to the contextMenu.xml ? Can you show an example?

        Alan KilbornA 1 Reply Last reply Reply Quote 1
        • Alan KilbornA
          Alan Kilborn @Ion Marqvardsen
          last edited by

          @Ion-Marqvardsen

          I can certainly show an example of how to add a script to the right-click context menu. But the script isn’t embedded there, it’s just “pointed-to” there. Have you installed the Pythonscript plugin and tried to get the script running manually?

          1 Reply Last reply Reply Quote 1
          • Ion MarqvardsenI
            Ion Marqvardsen
            last edited by

            I am sorry, but I don’t know anything about Pytonscript or running scripts “manually”. That sounds weird to me.

            I am not a super user of Notepad++, and my “programming skills” (if I can call it that) is limited to C and Matlab.

            I totally understand, if you consider me a “lost cause”, at this point. Anyway, thanks for trying. Have a nice weekend. :-)

            dinkumoilD Alan KilbornA 2 Replies Last reply Reply Quote 1
            • dinkumoilD
              dinkumoil @Ion Marqvardsen
              last edited by

              @Ion-Marqvardsen

              There are various plugins that have been written to solve your issue. Here is a presumeably uncomplete list (all untested):

              QuickOpenPlugin
              SourceSwitch
              Switcher
              Open Selection

              1 Reply Last reply Reply Quote 2
              • Alan KilbornA
                Alan Kilborn @Ion Marqvardsen
                last edited by

                @Ion-Marqvardsen said:

                if you consider me a “lost cause”

                Well… I’m not 100% sure (yet) but you are starting to sound like someone that wants to be spoon-fed, yes. I’m not so much into that, but if you show some amount of effort, I and others here are definitely “in your corner” and will help you.

                1 Reply Last reply Reply Quote 3
                • Ion MarqvardsenI
                  Ion Marqvardsen
                  last edited by

                  Hi Alan,

                  I would need to be “spoon-fed”. And I don’t like that. When I made the request, I was hoping there would be a solution ready.

                  Once again, thanks for your help.

                  I will give the plugins on the list a try. They might be exactly what I was looking for.

                  Alan KilbornA 1 Reply Last reply Reply Quote 2
                  • Alan KilbornA
                    Alan Kilborn @Ion Marqvardsen
                    last edited by Alan Kilborn

                    @Ion-Marqvardsen

                    hoping there would be a solution ready

                    Hmmmmmm…Pythonscript is just another plugin on the list…

                    Imgur

                    1 Reply Last reply Reply Quote 6
                    • Ion MarqvardsenI
                      Ion Marqvardsen
                      last edited by

                      Hi Alan,

                      For me there is nothing easy about pythonscripts. It is a question of knowing my limitations and balance between how much benefit there is with loading the associated header/source file versus the time to learn about and write the python code. Starting from where I am today, it does not give any meaning. I will have to progress on my own terms.

                      Alan KilbornA 1 Reply Last reply Reply Quote 0
                      • Alan KilbornA
                        Alan Kilborn @Ion Marqvardsen
                        last edited by

                        @Ion-Marqvardsen

                        LOL

                        1 Reply Last reply Reply Quote 2
                        • Ion MarqvardsenI
                          Ion Marqvardsen
                          last edited by

                          Yes, I know. I understand you reaction.

                          1 Reply Last reply Reply Quote 1
                          • Jim DaileyJ
                            Jim Dailey
                            last edited by

                            @Ion-Marqvardsen
                            You might want to install the Solution Tools plug-in. I use it and the <Ctrl>~ hotkey to cycle among files having the same name and various different file extensions.

                            See here: http://npp.incrediblejunior.com/

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