• Login
Community
  • Login

Auto-detect Language when creating new file

Scheduled Pinned Locked Moved Notepad++ & Plugin Development
languageauto-detection
9 Posts 4 Posters 9.6k 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.
  • J
    Josh Richard
    last edited by Mar 28, 2018, 11:53 PM

    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
    • M
      MAPJe71
      last edited by Mar 29, 2018, 12:29 AM

      Language is detected/based on file extension.

      1 Reply Last reply Reply Quote 0
      • J
        Josh Richard
        last edited by Mar 29, 2018, 1:03 AM

        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

        C 1 Reply Last reply Mar 29, 2018, 10:34 AM Reply Quote 0
        • C
          Claudia Frank @Josh Richard
          last edited by Mar 29, 2018, 10:34 AM

          @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
          • J
            Josh Richard
            last edited by Mar 30, 2018, 12:41 AM

            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

            C 1 Reply Last reply Mar 30, 2018, 12:44 AM Reply Quote 0
            • C
              Claudia Frank @Josh Richard
              last edited by Mar 30, 2018, 12:44 AM

              @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
              • J
                Josh Richard
                last edited by Mar 31, 2018, 2:12 PM

                Just regex some different syntax? lol idk

                1 Reply Last reply Reply Quote 0
                • J
                  Josh Richard
                  last edited by Mar 31, 2018, 6:32 PM

                  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
                  • E
                    Eduardo Jorge
                    last edited by Jun 5, 2018, 2:58 PM

                    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