Sublime Forum

Syntax Keyword Highlight Update

#1

Hello Everyone,

I am new to Sublime so please excuse my ignorance and very much appropriate any help provided. I am a IT / Network Engineer and for years I used NotePad++ to do coding and viewing for my Cisco equipment with keywords I selected to be highlighted in different colors. After playing with Sublime, I am wanting to use it more and more. I downloaded the Package Cisco Syntax for this wonderful App, but it is not highlighting all the keywords I would like. The base is nice, but I would like to add to it. This is where I need a little help. I am not much of a Programmer in the sense of Coding Languages. Bash is the most used while currently working to learn Python.

With NotePad++ you can create and define a language, create keyword lists and assign a color to them. Examples screen shots below.


The Cisco package is in text which I am currently not understanding how it calls out and works. I have placed the full code below but my current questions are:

What is the name support.function.cisco doing or calling out? Where is this function and how does it create the highlighted color?

{ “match”: “access-list”,
“name”: “support.function.cisco”
},

Same question here.

{ “match”: “tunnel-group”,
“name”: “support.class.cisco”
},

!-- Complete File Name: Cisco Definitions.json-tmLanguage

{
“name”: “Cisco”,
“scopeName”: “text.cisco”,
“fileTypes”: [“cfg”,“txt”],
“patterns”: [

	{ "match": "^\\s*no ",
		"name": "invalid.illegal.cisco"
	},

	{ "match": "access-list",
		"name": "support.function.cisco"
	},

	{ "match": "crypto ",
		"name": "string.unquoted.cisco"
	},
	{ "match": "any",
		"name": "string.unquoted.cisco"
	},
	{ "match": "deny ",
		"name": "support.constant.cisco"
	},

	{ "match": "permit ",
		"name": "constant.character.escape.cisco"
	},
	{ "match": "object-group",
		"name": "markup.list.cisco"
	},
	{ "match": "object",
		"name": "markup.list.cisco"
	},

	{ "match": "host",
		"name": "markup.list.cisco"
	},

	{ "match": "^[\\s]*!(.*)",
		"name": "comment.cisco"
	},
	{ "match": "static",
		"name": "constant.numeric.cisco"
	},

	{ "match": "tunnel-group",
		"name": "support.class.cisco"
	},

	{ "match": "crypto",
		"name": "support.class.cisco"
	},

	{ "match": "\\d+\\.\\d+\\.\\d+\\.\\d+(/\\d{1,2})?",
		"name": "constant.numeric.cisco"
	},

	{ "match": "[0-9a-fA-F]{0,4}:([0-9a-fA-F]{0,4}:)+[0-9a-fA-F]{0,4}(/\\d{1,3})?",
		"name": "constant.numeric.cisco"
	}
  
],
"uuid": "f3ba50f0-2bad-48b7-9509-f6d72e353ddb"

}

Thank you for any help sent my way

0 Likes

#2

To have syntax highlighting for your language you need two things:

  • syntax definition, which is applied to the text and add so called scopes to the keywords and structures (the pasted syntax definition is a old one and differers from the link)
  • color scheme, which adds color and highlighting to the scopes

So you have the syntax definition, which states “this is a keyword”, and the color scheme, which says “keywords should be bold and highlighted with the color red”. Since both should refer to the same names there is a scope naming convention. Hence you can easily change the highlighting without messing around with the syntax definitions. In addition there are very nice things you also can do with the scopes, e.g. limit completions to be inside strings.
Therefore you just need to match your keywords and add the corresponding scope to it.

1 Like

#3

Checkout the “Network Tech” package.

Lots more Cisco syntax supported

0 Likes