Sublime Forum

Very basic syntax help

#1

I want that when i open new file always open in the maxscript format, how i can do it
{
“color_scheme”: “Packages/Color Scheme - Default/Cobalt.tmTheme”,
“font_size”: 12,

}

thanks

0 Likes

#2

sublimetext.com/forum/viewt … f=2&t=7646

sublime.wbond.net/packages/ApplySyntax

github.com/facelessuser/ApplySy … gs#L44-L48

0 Likes

#3

[code{
// if an exception occurs when processing a function, should it be reraised so the user gets feedback? This is really
// only useful to those writing functions. The average user just wants the plugin to work, so let’s not reraise the
// exception
“reraise_exceptions”: false,

// If you want to have a syntax applied when new files are created, set new_file_syntax to the name of the syntax to use.
// The format is exactly the same as "name" in the rules below. For example, if you want to have a new file use
// JavaScript syntax, set new_file_syntax to 'JavaScript'.
"new_file_syntax": true,
"syntaxes": [
    {
        // I put  MaxScript first because of files like *.tmLanguage. It is unlikely that this rule will result in a
        // false positive, meaning if it matches, you probably want the  MaxScript syntax
        "name": "MaxScript/MaxScript",
        "rules": [
            {"file_name": ".*\\. MaxScript(\\.dist)?$"},
            {"first_line": "^<\\? MaxScript"}
        ]
    },
    {
        // The Cucumber and RSpec rules come before Rails and  MaxScript because they end in .rb and will be
        // identified as Rails or  MaxScript otherwise.
        "name": "Cucumber/Cucumber Steps",
        "rules": 
            {"file_name": ".*steps\\.rb$"}
        ]
    },
    {
        // One could use just the second rule to match every  MaxScript file in a /spec/ directory, but I prefer to more explicit.
        "name": "RSpec/RSpec", "RSpec (snippets and syntax)/Syntaxes/RSpec"],
        "rules": 
            {"file_name": ".*spec\\.rb$"},
            {"file_name": ".*/spec/.*\\.rb$"},
            {"file_name": ".*\\\\spec\\\\.*\\.rb$"}
        ]
    },
    {
        // This rule could be incorporated into the next one, but I prefer to be more explicit rather than less
        "name": "Rails/ MaxScript Haml",
        "rules": 
            {"file_name": ".*\\.haml$"}
        ]
    },
    {
        // This is an example of using a custom function to decide whether or not to apply this syntax.
        // source file should be in a plugin folder. "name" is the function name and "source" is the file
        // in which the function is contained.  They rule should be specified as such.
        //
        //   {"function": {"name": "is_rails_file", "source": "Packages/ApplySyntax/is_rails_file"}}
        //
        "name": "Rails/ MaxScript on Rails",
        "rules": 
            {"function": {"name": "is_rails_file", "source": "ApplySyntax/is_rails_file"}}
        ]
    },
    {
        "name": " MaxScript/ MaxScript",
        "rules": 
            {"file_name": ".*\\Gemfile$"},
            {"file_name": ".*\\Capfile$"},
            {"file_name": ".*\\Guardfile$"},
            {"file_name": ".*\\[Rr]akefile$"},
            {"file_name": ".*\\Vagrantfile(\\..*)?$"},
            {"file_name": ".*\\Berksfile$"},
            {"file_name": ".*\\Thorfile$"},
            {"file_name": ".*\\.thor$"},
            {"file_name": ".*\\config.ru$"},
            {"file_name": ".*\\.rake$"},
            {"file_name": ".*\\.simplecov$"},
            {"file_name": ".*\\.jbuilder$"},
            {"file_name": ".*\\.rb$"},
            {"file_name": ".*\\Podfile$"},
            {"file_name": ".*\\.podspec$"},
            {"file_name": ".*\\.rabl$"},
            // a binary rule does the same thing as a first_line rule that uses a regexp to match a shebang, the
            // difference being DetectSyntax will construct the regexp and the user doesn't have to. So
            //
            //      {"binary": " MaxScript"}
            //
            // is functionally equivalent to
            //
            //      {"first_line": "^#\\!(?:.+) MaxScript"}
            //
            {"binary": " MaxScript"}
        ]
    },
    // {
    //  // This is an example of having to match all rules. In this example, the file needs to have a  MaxScript
    //  // shebang *and* end in . MaxScript. If "match" == "all", DetectSyntax will set the named syntax only if all
    //  // rules match. If "match" is anything other than "all", the syntax will be set if any rule matches
    //  // (the normal behavior)
    //  "name": " MaxScript/ MaxScript",
    //  "match": "all",
    //  "rules": 
    //      {"binary": " MaxScript"},
    //      {"file_name": ".*\\. MaxScript$"}
    //  ]
    // },
    // {
    //  // This is an example of using a contains rule to match files which contain the specified string
    //  // anywhere inside them. It's useful when you can only determine which syntax to use by looking
    //  // at what's actually inside the file. In this case, since the file contains a handlebar template,
    //  // we switch its syntax highlighting to Handlebars.
    //  //
    //  // NOTE: Make sure to always use a specific match or pair this rule with one for the extension or the file or other
    //  // characteristics, otherwise you might end up matching the settings file as well (because it contains the string)
    //  "name": "Handlebars/Handlebars",
    //  "match": "all",
    //  "rules": 
    //      {"file_name": ".*\\.html$"},
    //      {"contains": "<script ^>]*type=\"text\\/x-handlebars\"^>]*>"}
    //  ]
    // },
    {
        // Emblem syntax matches  MaxScript Slim
        "name": " MaxScript Slim/Syntaxes/ MaxScript Slim",
        "rules": 
            {"file_name": ".*\\.emblem$"}
        ]
    },
    {
        "name": "Blade/Blade",
        "rules": 
            {"file_name": ".*\\.blade.php$"}
        ]
    },
    {
        "name": "PHP/PHP",
        "rules": 
            {"file_name": ".*\\.(php|inc|phtml)$"},
            {"first_line": "^<\\?php"}
        ]
    },
    {
        "name": "PHP/Smarty",
        "rules": 
            {"file_name": ".*\\.tpl$"}
        ]
    },
    {
        "name": "YAML/YAML",
        "rules": 
            {"file_name": ".*\\.gemrc$"},
            {"file_name": ".*\\.yml(\\.dist)?$"}
        ]
    },
    {
        // This rule requires the INI plugin to be installed (via PackageControl or [github.com/clintberry/sublime-text-2-ini](https://github.com/clintberry/sublime-text-2-ini))
        "name": "INI/INI",
        "rules": 
            {"file_name": ".*/git/(attributes|config|ignore)$"},
            {"file_name": ".*\\\\git\\\\(attributes|config|ignore)$"},
            {"file_name": ".*\\.(gitattributes|gitconfig|gitignore)$"},
            {"file_name": ".*\\.ini(\\.dist)?$"},
            {"file_name": ".*\\.npmrc$"}
        ]
    },
    {
        "name": "ShellScript/Shell-Unix-Generic",
        "rules": 
            {"file_name": "profile"},
            {"file_name": ".*\\.bash.*$"},
            {"file_name": ".*\\.z(shrc|shenv|profile|login|logout).*$"},
            {"file_name": ".*\\.(bash|sh)$"},
            {"binary": "bash"}
        ]
    },
    {
        // This doesn't really need to be here as ST2 identifies Apache files correctly, but I leave it
        // for instructional value
        "name": "Apache/Apache",
        "rules": 
            {"file_name": "^.*(\\.htaccess|\\.htgroups|\\.htpasswd|httpd\\.conf)$"}
        ]
    }
]

}][/code]Many thanks very kind from you!

0 Likes

#4

Sorry?

0 Likes

#5

oh, excuse my comment was not copy.
what i ty to say that i replace the Word for maxscript but dont work.
where i have to replace properly?
thanks

0 Likes

#6

I still don’t understand your problem, but try to carefully read my links a second time.

0 Likes

#7

1.I want to open new files with maxscript format not plain text
2.I want to have in each new file the maxscript library for autocompletion
3.The only way i know at this moment to get the (2) ítem is to copy ALL the library in the new file and now i can work with the 3dmaxscript library and autocompletion
4.I dont know how to change the APPLYSYNTAX PLUGIN and which part of them has to delete
5.I have this error message in the attach

thanks for be very patient:barrier language+ 0 knowlodge of basic programing is explosive!jajaja

0 Likes

#8

1.&4. Is exactly answered in the three links I already posted above. I updated the last url to point to the correct location since I pointed to the master branch and the code has been changed.
2.&3. This is a job for completions: docs.sublimetext.info/en/sublime … tions.html
5. I can’t see it.

0 Likes

#9

sorry i cant with that information do nothing, not at thi step im.Dont understand how to modified,where to put the “code” anyways i really thanks your effort ant time you spent trying to help me. Probably in another time i will fix that problem for me.

I copy and paste this code for plain text and work fine but i try to use it for maxscript and nothing
“auto_complete_selector”: “source, comment, text.plain, meta.tag, punctuation.definition.tag.begin, css”,
beside you not to much support here…

0 Likes

#10

This is not possible, not in the default ST, at least.

You have to change the syntax manually. It only takes a few seconds using the Command Palette:Ctrl/Command+P and type the name of the syntax.

To learn about Package Control which allows you to easily install & update packages that extend Sublime’s functionality:
sublime.wbond.net/installation

I’m not familiar with the packages that FictheFoll suggested, but maybe one of them will help you with some of the things you’re trying to do.

@FictheFoll: Any thought about sticky-ing a post regarding how/why to install PC, where to find the the official & unofficial docs, etc.? Not that these can’t be found with a quick googling. But I remember when I first started using ST and all this stuff was bewildering!

Alex

0 Likes

#11

Thanks Alex!
“This is not possible, not in the default ST, at least.” OK

0 Likes

#12

Although I did just look at the ApplySyntax plugin and it looks like it allows you to do what you want.

0 Likes

#13

you know how to customize ApplySyntax for Maxscript?

0 Likes

#14

@quodlibet

I don’t see how this is relevant here, especially since I linked him a package that does exactly that. It even includes instructions for installation using package control and the package control site itself has quite a noticable “Installation” tab in its nav.

I also remember that I was a bit confused about the first package I tried to install (I was entirely new to git), but package control was linked on the second or third plugin which is how I got it. It’s good that most packages include a link and instructions for package control now, it hasn’t always been like this. I don’t even include instructions for manually cloning my packages anymore because if you really need to do that, you’d normally also know what you are doing and how.

The docs are pretty visible at sublimetext.com/support - which is probably the first thing I’d check and way more visible than a forum thread.

0 Likes

#15

oh my friend i apologize i dont want hurt you with my ignorance,i know you kindly link doc for me but still is not understandable at this step or very confused to me,sorry i really apreciated your effort.

0 Likes

#16

@FichteFoll Fair enough.

@Makenson We’re reaching the point, as @FichteFoll pointed out, where you need to try to do some stuff yourself. I seem to recall starting off with Sublime frustrating but kind of fun :wink: If this is just frustrating, maybe Sublime is not the right tool.

Have a look at @FictheFoll’s first post again. All the pieces you need are there:

  1. Install Package Control
  2. Install ApplySyntax
  3. Configure ApplySyntax

Feel free to write back about what you tried and where you had trouble and we’ll try and get you back on track.

Alex

0 Likes

#17

ok i bought a Mastering Sublime Text book so i will stop asking and try to study these things.Thanks anyway and excuse me.
I apreciated all your effort

0 Likes

#18

I hope the book helps you along. As I said though, feel free to write back as you try things. When troubleshooting things, it really helps if you can describe what you have tried already.

Alex

Edit: I think we went off-topic here and it’s probably my fault. Apologies for that. Keep trying; write back. :smile:

0 Likes