Menu

Copy existing language to new language

Number_8
2007-11-27
2012-11-13
  • Number_8

    Number_8 - 2007-11-27

    Hello,

    I am working with a language very similar to VB.  Is it possible to copy the VB settings to a new language, then edit that language, adding and removing keywords/operators/etc. as necessary?

    That would be a lot more efficient than creating the new language defs through the User Define dialog.

    Thanks for any advice...

    CB

     
    • fidvo

      fidvo - 2007-11-28

      While step-by-step instructions would be too detailed for this post, I can at least point you in the right direction.

      The langs.xml file stores the language settings.  In my langs.xml file (which I haven't edited but might be out of date) VB starts on line 67.  You'll need to copy lines 67-70 and paste them somewhere else in the file.  I would suggest manually editing at least the name and ext parameters in the file, then restart Notepad++ and do all the rest through the User Define dialog.

      I believe this will work, although like I said, I haven't actually tried it, so make a backup of your langs.xml file before editing it.

      I hope this helps.

       
      • Number_8

        Number_8 - 2007-11-28

        Thanks for the reply.

        I added an entry to langs.xml (copy the vb section and changing the name and extension).  I also copied the vb.api file to myExt.api.

        Unfortunately, Notepad++ doesn't recognize the new language.

        If I use the Define Language dialog, I get a userDefinedLang.xml file in my <user>\application data\Notepad++ dir.  What I would like to do is fill in that file with all the settings of VB, but without doing it item by item in the Def Lang dialog.

         
        • fidvo

          fidvo - 2007-11-28

          Oops.  You're right.  Maybe now I'll learn not to post without testing first.

          Unfortunately, the format of the UserDefinedLang.xml looks to be different than Langs.xml, so you might be stuck.  At the very least, you should be able to copy the keywords from the "instre1" tag from the Langs.xml to the "words1" tag in the UserDefinedLang.xml.  Then copy the WordStyles from stylers.xml (which also has a vb section).  It looks like there are only about ten lines or so that you would need to copy over.  You may need to do a little more cleanup, but I think that will work.

          I know it's more work than you had hoped, but that's the best I can come up with.

          (Just a reminder: make sure you make backups of all the files first)