ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Syntax​Definition​Helper

by matthew-dumas ST2

This is a plugin/module for Sublime Text 2 to aid in the creation of language syntax definitions.

Details

  • 2014.01.09.00.03.02
  • github.​com
  • github.​com
  • 8 years ago
  • 22 minutes ago
  • 9 years ago

Installs

  • Total 368
  • Win 224
  • Mac 87
  • Linux 57
Jul 4 Jul 3 Jul 2 Jul 1 Jun 30 Jun 29 Jun 28 Jun 27 Jun 26 Jun 25 Jun 24 Jun 23 Jun 22 Jun 21 Jun 20 Jun 19 Jun 18 Jun 17 Jun 16 Jun 15 Jun 14 Jun 13 Jun 12 Jun 11 Jun 10 Jun 9 Jun 8 Jun 7 Jun 6 Jun 5 Jun 4 Jun 3 Jun 2 Jun 1 May 31 May 30 May 29 May 28 May 27 May 26 May 25 May 24 May 23 May 22 May 21
Windows 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Mac 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Linux 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Readme

Source
raw.​githubusercontent.​com

Syntax Definition Helper

This plug-in contains two tools to aid in the creation of basic syntax definition files.

The Problem

Working with P-List and JSON files can be annoying when attempting to deal with syntax definitions. Furthermore, not looking directly at a file of the syntax definition type you're creating can cause you to miss tokens. Even further than that, people don't seem to understand regular expressions well enough to make basic regular expressions.

For these reasons, and extreme laziness on my part, I made these tools. The Syntax Definition Helper creates a new syntax definition based on user input while the user is staring at a file that contains no syntax highlighting. It creates very basic regular expressions based off of the selected text, and allows the user to choose a scope and a comment, as well as edit the regular expression for that token.

The syntax definition edit helper opens up the current syntax defintion, and allows the user to add basic patterns to the definition in exactly the same way as the Syntax Definition Helper.

Getting Started

Once installed:

Press ALT-CTRL-6 to start the Syntax Definition Helper Wizard Press ALT-CTRL-7 to start the Syntax Definition Edit Helper Wizard

Alternatively, you can define a new key binding for this command.

How to Use

Create A Syntax Definition

  1. Open a file that doesn't contain a syntax definition
  2. Press ALT-CTRL-6
  3. Type "yes" and hit enter
  4. Type the file extensions this will apply to (Ex: .asm .txt .x86) and hit enter
  5. Give the language a name and hit enter.
  6. Press Enter or enter your own UUID
  7. Name the language root scope. This should be something followed by the file extension. (Ex: For XML I would enter Text.XML)
  8. Select a group of tokens (for example, command tokens -- if end last next continue for while loop do) then click into the dialog entry box and hit enter
  9. Edit the regex and hit enter.
  10. Add a comment to the group, describing it (ex: Control Tokens), and hit enter.
  11. Choose a named scope from the default color scheme list (ex: comment.py), and change the final extension to the extension you used for the root scope. (xml ex: comment.xml)
  12. Repeat 8-11 until you run out of groups or tokens to colorize.
  13. Enter "no" at the token prompt and hit enter.
  14. Wait for Sublime Text 2 to save and reload syntax definitions.
  15. Set the syntax to your new syntax defintion and observer the colors.

Edit A Syntax Definition

  1. Verify that the syntax in the file you're planning on editing is set to the correct syntax.
  2. Press ALT-CTRL-7
  3. Press Enter
  4. Perform the steps 8-15 from the above set of instructions.

Clicking into the text edit area in the dialog and pressing escape will cancel the entire process at any time. If you change your mind, and decide to not make the changes, then do this.