Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Auto-detect Language when creating new file

    Plugin Development
    language auto-detection
    4
    9
    7280
    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 Richard
      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
      • MAPJe71
        MAPJe71 last edited by

        Language is detected/based on file extension.

        1 Reply Last reply Reply Quote 0
        • Josh Richard
          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 Frank 1 Reply Last reply Reply Quote 0
          • Claudia Frank
            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 Richard
              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 Frank 1 Reply Last reply Reply Quote 0
              • Claudia Frank
                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 Richard
                  Josh Richard last edited by

                  Just regex some different syntax? lol idk

                  1 Reply Last reply Reply Quote 0
                  • Josh Richard
                    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 Jorge
                      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
                      Copyright © 2014 NodeBB Forums | Contributors