How do I stop my own highlighting while inside another highlighting group? - syntax-highlighting

I have a brace coloring plugin that highlights code like this:
but I want it to stop highlighting inside macros. What I tried so far was adding my highlighting groups to the cPreProcGroup syntax cluster which is used for exclusion in the definition of the cDefine group in c.vim:
syn region cDefine start="^\s*\(%:\|#\)\s*\(define\|undef\)\>" skip="\\$" end="$" keepend contains=ALLBUT,#cPreProcGroup,#Spell
Appeding my groups to cPreProcGroup didn't work.

Related

Does an Indesign syntax highlighter exist?

Does anybody know of a non-manual method of highlighting syntax when pasted in InDesign?
I'm trying to show code of a project in an InDesign documentation but don't want to have to manually highlight the code, and preferably add numbered rows too.
Is there a plugin to achieve this?
This is the style in which I'd like to format the code.
Cheers
Not sure if you worked out an answer to this, but there's no magic button that will solve your problem.
However, InDesign does have a facility in each Paragraph style called GREP that can do what you're looking for.
This lets you write 'regex' or 'regular expressions' that are just rules for what to apply a given character style to. Yes, they look about as meaningful as Harry Potter incantations at first glance, but 2 or 3 simple regexes will get you a long way.
For instance:
(\<|<)!--\s*.*?\s*--(\>|>)
Will target HTML comments only.
(?<=").*?(?=")
This will target anything wrapped in straight double quotes.
(?<=\().*?(?=\))
This will target any text inside parentheses ().
There's an '#' symbol button in that GREP style next to where you type the regex - that gives you a drop-down menu that is almost like a 'Regex Wizard'. Try that too.
When you've got a regex that works, create a new character style for the text color and select it in the 'Apply Style' input.
Regexr.com has a tool that is good for testing this stuff. Paste your code sample in the bottom panel and your line of regex in the top. The bits that it targets will turn blue.
There is a searchable community panel on the left where people have probably already written expressions like the one you need.
I'm working out a JavaScript highlighter at the moment. It's a shame there's no communal 'Indesign style sharing library'.
Best of luck.
If had luck pasting syntax highlighted code into a Rich Text editor like Libre Office and then pasting it into Indesign. Just make sure whatever font your syntax highlighted code is in is also in InDesign because you'll get font missing errors when you pre-flight the book.

How to change multiple entries in config files

I notice in VS2013 that if I highlight text with a view to making a change, the same text is highlighted elsewhere in the file. However, I can't seem to find the option to reflect the change in multiple places when I start typing.
Is this feature just for information only or can I actually do multiple replacements by typing the change once?
This is not supported out of the box.
But there is a nice plugin you can use to enable this, called MultiEditing.
H/T to Scott Hanselman :)
Also note that even in standard VS2013, you can edit multiple lines by "box-highlighting".
This is where you create a "box-selection" either by holding down Alt and dragging a box around the text, or by Alt+Shift+ArrowKeys. Then start typing and the same text will appear on multiple lines.
e.g. with the following text:
Some text to demonstrate
Some info to demonstrate
Some more to demonstrate
...if you Alt+drag a box-selection around all 3 occurrences of the word to, and then type which, it will look like this:
Some text which demonstrate
Some info which demonstrate
Some more which demonstrate
This also works with copy/paste - the pasted text gets applied to all lines within the box-selection.
It's pretty hard for me to describe here, so try it yourself!

How do I add features to a syntax definition in Sublime Text without editing it?

For example, I would like to highlight #param, #type, and #return (i.e. epytext declarations) in my Python docstrings. I have figured out how to do this by simply editing Python/Python.tmLanguage; however, I would really like to put this in its own file, for a couple of reasons:
I don't always want to apply this highlighting. It's only for projects that use epydoc as their documentation tool; in other projects, I would want to highlight reStructuredText instead.
When Sublime Text updates, I'd like to have my own syntax as an overlay onto the included features. there are several features of Python that Sublime's author may choose to include in future versions and I don't want to have to manually figure out what I changed each time an update modifies the base Python syntax definition.
I keep my own editor configuration in version control, but I want that to be my own original stuff; I don't want to be burdened with having to carry copies (possibly proprietary? I don't know, it doesn't seem to have an independent license) of syntax definitions that come with Sublime.
Is there a way to put highlighting rules into a separate file, perhaps to only be applied to a particular scope?
Sounds to me like you want to create your own syntax file, inherit from the Python syntax file (source.python), and make your changes and customizations there. Sublime Text 2 uses the .tmLanguage format for syntax files, which is a bit complex, but fortunately most of the work has already been done for you, just by inheriting from source.python.
What you want to do is set up a regex pattern to match the substrings that you want to highlight, and give that pattern a name; something like punctuation.definition.comment.epydoc, to follow the convention set in Java/JavaDoc.tmLanguage. Then, check your color scheme file (ending in .tmTheme) and make sure there are settings for the scope that you've chosen -- or for one of its parents, since ST2 should use proper scoping rules for this sort of thing.
To use the syntax file you've created, stick it in Packages/User (so that ST2 doesn't overwrite it on upgrades), open a Python file in the editor, and then select your new syntax from the dropdown list in the bottom right corner of the window. If you've set up everything correctly, the epydoc strings should change to be whatever color you've set in your color scheme.
Good luck! And post a link somewhere when you've got a syntax file that works, so others can see and use it, as well!

How to change the highlight color for matched braces in VS2010

I need to change the highlight color for the matched braces in VS2010.
I have tried the following setting but it doesn't work at all.
Any suggestion is welcome.
Thank you
From Microsoft
...There are two Fonts and Colors options for brace matching: "Brace
matching (Highlight)" and "Brace matching (Rectangle)". Not all
languages use both settings. Each language implements its own brace
matching functionality, which can lead to inconsistencies in which
options are used in which language. For example, C#, HTML, CSS, and a
few others do not use the "Brace matching (Highlight)" option at all,
which is why it doesn't do anything when you change it in those file
types. However, "Brace matching (Rectangle)" should still work for C#,
HTML, and CSS, which it sounds like is consistent with your
experience. Some other languages will have the reverse behavior, i.e.
"Brace matching (Rectangle)" will do nothing but "Brace matching
(Highlight)" will work...
Not a good answer, but that's where VS2010 stands right now. Incidentally, when I changed
"Brace Matching (Rectangle)" Background color, it works for me in C++ and C#, if I have my cursor immediately left of an open brace or immediately right of a closing brace.
Good luck.
(tools) (options)
under (environment) (fonts and colors)
show settings for (text editor)
under (display options) there are two brace matching entires
(Brace Matching Highlight) is the one that you want.
Change it, maybe restart vs 2010 for good luck.
I use Visual Assist X for that task. After setting up visual assist for Visual Studio, you can change the bracer match and mismatch color under the display tab in the Visual Assist options menu.
Change Highlighted Reference in Item background dropdown
Watch it, if you use ReSharper, these settings will have no effect.
You first have to enable the Fonts and Colors in the newest ReSharper version.

Vim custom syntax highlighting background only

I want to customize syntax highlighting in Vim (GUI version). There is an existing syntax file for my language. I want to add to that syntax highlighting a background colour to each line if that line starts with >. I figured out that I can basically achieve this by
:syntax match Output /^>.*$/
and adding
:hi Output guibg=LightBlue
to the colourscheme. The background of the text in these Output lines gets coloured then in light blue, but it overrides the foreground colour as well. So most of the syntax highlighting disappears. How can I keep the foreground syntax highlighting in these lines?
Also: Is there a way to extend the highlighting of the background to the end (right end of the screen) of these lines?
Here is how to preserve the syntax, I'm matching lines starting with {
:hi Output guibg=LightBlue
:match Output '\%>0v{.*'
Edit: since you want the opposite you need
:match Output '^[^<].*$'
Try this:
:hi Output guibg=LightBlue guifg=NONE
The easiest way to achieve what you're looking for is with the :match command as Eric Fortis has pointed out.
The only way I know of to achieve this with syntax highlighting will require you to match the entire line as you are currently doing. You will then need to specify, using the contains=... modifier, which syntax elements can be in your line. I'm also pretty sure these elements will need to have the contained attribute assigned to them. This way any element found in your line i.e matched by the .* will preserve it's highlighting.
See :help :syn-contains for more.

Resources