Community
    • Login

    Auto-detect Language when creating new file

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    languageauto-detection
    9 Posts 4 Posters 9.5k 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.
    • Josh RichardJ
      Josh Richard
      last edited by

      When creating a new file, is there a way to auto detect and set the language of the new file content?

      Using the Language drop down in the menu bar at the top, I can apply the language of choice manually

      After a few lines, is there a way to auto-detect the language and apply it for me so the proper style and syntax highlighting shows without additional clicking?

      If not, can we make that happen?

      1 Reply Last reply Reply Quote 0
      • MAPJe71M
        MAPJe71
        last edited by

        Language is detected/based on file extension.

        1 Reply Last reply Reply Quote 0
        • Josh RichardJ
          Josh Richard
          last edited by

          So there is no hope for anything based on text input?? This makes me sad. I don’t always want to save a file or select the proper syntax… ie. I’m lazy :P

          Claudia FrankC 1 Reply Last reply Reply Quote 0
          • Claudia FrankC
            Claudia Frank @Josh Richard
            last edited by

            @Josh-Richard

            if you provide the distinct logic which of the languages should be used,
            I can provide the python script to set it automatically, but, of course, this means
            you need to have python script plugin installed.

            Cheers
            Claudia

            1 Reply Last reply Reply Quote 0
            • Josh RichardJ
              Josh Richard
              last edited by

              I mean… I know several languages that would give away the language in the very first line… ex: #!/bin/bash

              But other languages could have these context clues on other lines… ex: <?php does not need to be the first line of a valid PHP file

              Claudia FrankC 1 Reply Last reply Reply Quote 0
              • Claudia FrankC
                Claudia Frank @Josh Richard
                last edited by

                @Josh-Richard

                agreed but what if you open a html page with embedded php?
                I guess you don’t want to have php lexer on html page, do you?

                Cheers
                Claudia

                1 Reply Last reply Reply Quote 0
                • Josh RichardJ
                  Josh Richard
                  last edited by

                  Just regex some different syntax? lol idk

                  1 Reply Last reply Reply Quote 0
                  • Josh RichardJ
                    Josh Richard
                    last edited by

                    Would have to be in a certain order though… because I would want the PHP to set even though there is HTML syntax as well… so checking one before another would be important in this case, on new file input…

                    1 Reply Last reply Reply Quote 0
                    • Eduardo JorgeE
                      Eduardo Jorge
                      last edited by

                      would not be able to use a comment line to change the syntax?

                      use it to exchange syntax in the middle of the document?

                      I am trying to set up the O2 compiler “Oxygen Basic” but the syntax is very varied, assimble, syntax C, Basic, and even in Basic accepts variants like End if, Endif,
                      would be good to avoid language vices

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