I have recently started writing mathematical documents using Bookdown and RStudio, and I am looking for a way to setup syntax highlighting for LaTeX code. I know that I can customise the syntax highlighting using editor themes, and I have found this tool for creating them, but I don't know what to enter into the "scope" fields to achieve the highlighting I want.
I would like something similar to the syntax highlighting in TeXworks (which is what I'm used to). This has separate highlight colours for special characters, commands beginning and ending LaTeX environments, LaTeX packages, and control sequences. Ideally, I'd also like another highlight colour for text in mathmode, and I would like the highlighting to be the same for text that is inside or outside Bookdown's equivalent of Theorem environments.
Based on trying a few themes and looking at them in the editor, I think that keyword highlighting will highlight LaTeX control sequences and support.function will highlight text in mathmode, but these only work outside of Bookdown's environments.
Is it possible to achieve the highlighting I want? And if so, how?
Related
As my R scripts get long and messy, I would like to create headers that are easily identifiable: for instance, change the color of certain comments in script. I am not looking for something crazy like underlining or changing the fonts for chunks of comments, just changing color, i.e. highlighting comments.
From all my search, the only option is to change the Editor appearance from setting, but I would like to distinguish certain chunks of comments from other comments.
When writing an RMarkdown file in RStudio, I'd like to be able to insert common text snippets using a keyboard shortcut. On the one hand, there are code snippets in RStudio, but they don't seem to work for Markdown. So I'd settle for any other way to create a custom keyboard shortcut for inserting a pre-specified piece of custom text, while I wait for that bug to be fixed.
Turns out you can use code snippets in Markdown in RStudio. Although they don't seem to work at first, you can force snippet expansion using Shift+Tab, as described here. The RStudio team says they'll add that to the official documentation in the future.
Is there a way to disable syntax highlighting in Atom.io?
I have searched a bit and ended up creating my own syntax package (https://atom.io/themes/no-syntax-highlighting-syntax), but maybe there is a better way.
NB: I just want to disable syntax highlighting (ideally keeping only comments and code in a different color), but I still want the other language-related features of Atom.io working. Like language completions, language snippets, language closure/bloc detections, auto-indent, etc.
(Some people argues against syntax highlighting, stating it might be actually harmful to developer productivity. I wanted to try that. Ie. http://www.linusakesson.net/programming/syntaxhighlighting/ and https://www.robertmelton.com/2016/03/21/syntax-highlighting-off/)
You can use Ctrl+Shift+L (or press button bottom right) to select proper language. In your case it would be Plain Text.
Second option is install package https://atom.io/packages/file-types and add in config.cson:
'file-types':
'YOURS EXTENSION': 'text.plain'
Haven't found a better solution yet.
If you are trying to do the same thing as I was - disabling syntax highlighting in Atom.io while keeping comments differentiated, language completions, language snippets, language closure/bloc detections and auto-indent - I would just recommend to install the theme I've created: https://atom.io/themes/no-syntax-highlighting-syntax
Set the file syntax to plain text. You can do this with control alt L or something like that.
I'm trying to build a basic, Markdown-style plain/rich text editor. (One where the text is styled inline, instead of having two panels side-by-side the way most Markdown editors do) (I'm also not going to support the full Markdown spec - no lists or tables, mainly just rich text formatting like bold, italics, underline, etc)
I have a project that consumes the AvalonEdit project (via the source code, not the Nuget package) - I got the editor all setup exactly how I want - then I started to write a syntax highlighting XSHD file when I realized that the highlighter only supports formatting like font colors, italics, bold, etc and not font size, underline and others...
How can I add additional font formatting? Will I have to write a whole new parser/highlighter/whatever? Is there an easy way to hook into and extend the existing highlighter?
I've already made a few small changes to one file in the source (TextEditor.xaml), and I'm willing to change more to make this work - though when I started I was hoping to touch the source as little as possible...
If someone could just point me in the right direction, I'd appreciate it - Thanks!
From the syntax highlighting documentation:
Among the text rendering extension points is the support for "visual
line transformers" that can change the display of a visual line after
it has been constructed by the "visual element generators". A useful
base class implementing IVisualLineTransformer for the purpose of
syntax highlighting is DocumentColorizingTransformer. Take a look at
that class' documentation to see how to write fully custom syntax
highlighters. This article only discusses the XML-driven built-in
highlighting engine.
Having read and/or scanned through that page a number of times, I couldn't fully grok this until I'd looked through the code a bit more, read some posts on the SharpDevelop forums, etc.
And if you're at the same stage I was (and can't quite wrap your head around that quote), the gist is that the editor does these two things (simplified, of course):
It generates lines of visible text (it only bothers with the lines
currently visible on the screen for performance reasons)
It then runs various transformers over said generated text, to style it in various ways
So the "XML-driven built-in highlighting engine" is only one way to find and style text - one that's meant to be a simple implementation of the more 'advanced' way, which is to build a custom text transformer, like a DocumentColorizingTransformer.
And here's some info on DocumentColorizingTransformer that you may find useful (besides the API documentation they point you to):
https://stackoverflow.com/a/23251990/859833
http://danielgrunwald.de/coding/AvalonEdit/rendering.php
In my collegue's version of R the different types of text become different colours when you write in the editor(for example functions are blue while text in quotation marks is green). For me, however, all the text is black which I think makes it harder to get a quick understanding of the code. There is also no automatic line break. Is it because he has the mac version while I have the PC version? Is there som way i can change this?
Thanks in advance!
Edit: changing the settings below will allow you to change the color of, say, R help text or of code but doesn't actually enable syntax highlighting. Per #Roland's comment, your best bet is a different text editor (such as Notepad++,RStudio, or Sublime) or a syntax highlighting package. Apparently the Mac version of the R editor really is just better (per this wiki)
You can change the settings in Edit>RGUI Preferences, under "Console and Pager Colours".