27 votes
Accepted

Highlighting Mathematica code in $\LaTeX$ document

I too had a need for a better syntax highlighting engine for Mathematica that can be used in different formats (so the javascript plugin is ruled out), so I wrote a better lexer and highlighter for ...
rm -rf's user avatar
  • 88.7k
20 votes
Accepted

Why does setting SyntaxInformation add a definition to DefaultValues

In my view, the Mathematica front end would have needed a complete rewrite a long time ago to be in a shape where it can compete with modern UI's. Looking at MATLAB, it's clear that you always find ...
halirutan's user avatar
  • 113k
19 votes
Accepted

Colored marks appearing in notebook input text?

Various folks at WRI have spent a decent amount of time running this to ground, and I now think it's well understood thanks to a considerable team effort. Here's what we know. Problem #1 — ...
John Fultz's user avatar
  • 12.6k
12 votes
Accepted

SyntaxInformation cannot reproduce syntax coloring of Block

Unfortunately, the current answer is "you can't". These are hard coded into the FE. Module/With, in particular, are not treated as local variables since they are really lexically scoped. If you look ...
Itai Seggev's user avatar
  • 14.1k
12 votes

Highlighting Mathematica code in $\LaTeX$ document

The answer by @R.M. is what I would recommend to anyone who has the ability to install the required prerequisites. But as requested by @murray, here is an example of a complete $\LaTeX$ document that ...
Jens's user avatar
  • 97.1k
12 votes
Accepted

Syntax information for pure functions

SyntaxInformation does not hold its arguments so you can hold it: ...
Kuba's user avatar
  • 137k
10 votes
Accepted

Is it possible to make a custom syntax coloring for "=", "==", and "==="?

1. Syntax Coloring (partially working) Under menu Edit > Preferences > Appearance > Syntax Coloring > Errors and Warnings, turn on ...
Domen's user avatar
  • 22.3k
9 votes
Accepted

How to correctly implement in a new function the scoping behavior of Table, Sum and other commands that use Block to localize iterators?

You can safely ignore the warning and red highlighting. It simply tells you that the variable will be injected into Block by the top-level rule (your function), ...
Leonid Shifrin's user avatar
8 votes

Syntax Highlighting for WL files in Atom/Sublime?

I use language-mathematica with Atom, it includes function name autocompletion up to 11.0.1 as well as links to the WL reference. There's also goto-mathematica by the same author as well as a plugin ...
Graumagier's user avatar
  • 1,130
8 votes
Accepted

Is there a syntax coloring type that highlights only when not in a list?

Here is my argument for why I think this is not possible: First, we'll gather all the SyntaxInformation out there and GroupBy ...
b3m2a1's user avatar
  • 46.8k
7 votes

Customize syntax highlighting for a particular symbol

You may use the InputAutoReplacements option. It has been around since version 4 according to the documentation. By changing the comma ...
Edmund's user avatar
  • 42k
7 votes

What is ColorEqualSigns and how does one use it?

So I delved into this as part of a new effort to review things like SyntaxInformation, function templates, and so forth. Too early to say what will come of this, ...
Itai Seggev's user avatar
  • 14.1k
7 votes

Why are `Control` variables indicated as undefined in the frontend?

Maybe it's my turn to answer this. As the developer of the Mathematica Plugin for IntelliJ, I can explain in detail, why such highlighter bugs are often a limitation that cannot be fixed when the ...
halirutan's user avatar
  • 113k
7 votes
Accepted

Dynamic InputField with syntax highlighting?

Here is what you can do: ...
Kuba's user avatar
  • 137k
7 votes
Accepted

Is it possible to make a notebook behave like text editor such as Sublime Text with regard to code formatting?

To be honest, I still don't know what you're looking for since 90% of what is in your screenshot is already in Mathematica, but if you want to customize, here's something that'll do that on a single <...
b3m2a1's user avatar
  • 46.8k
7 votes
Accepted

Incorrect syntax highlighting? "Variables made special by use in arguments" not working

Welcome to MMA SE! (Note that I think you shouldn't be using Evaluate there: consider i=3; Do2[Print[i], {i,5}].) Syntax ...
thorimur's user avatar
  • 9,010
6 votes
Accepted

How to recognize variables like built-in functions?

You can use the built-in SyntaxInformation[] as follows: ...
xyz's user avatar
  • 605
6 votes
Accepted

How to prevent front end from suggesting Symbol option names (when actually String), and from adding them to Global` context

You can use undocumented "OptionNames" property of SyntaxInformation to customize option names suggestions (and coloring of ...
jkuczm's user avatar
  • 15.1k
6 votes
Accepted

How to set "SymbolContextStyles" for `$Context` symbols?

It is far from being perfect but maybe it can help. Just put this line on top of the notebook, in an initalization cell or wherever. ...
Kuba's user avatar
  • 137k
6 votes

Code not working when I'm breaking it up into different lines

This happens because the expression For is complete at the location of the newline. Mathematica will not attempt to read further. Instead, it will try to ...
Szabolcs's user avatar
  • 234k
6 votes

How to detect unused local variables?

Wolfram Workbench is nice for this, but you could also try the "CodeInspector`" package:
Rolf Mertig's user avatar
  • 17.2k
5 votes

Customize syntax highlighting for a particular symbol

Try $PreRead = ReplaceAll[#, "," -> ","] &; This replaces the Chinese comma once you evaluate an input line: The following quote ...
user293787's user avatar
  • 11.7k
5 votes

SyntaxInformation and Options

I noticed this too, but didn't really think very hard about why it is like this. One likely reason is that you can store an option in a variable. ...
Szabolcs's user avatar
  • 234k
5 votes

Syntax highlighting in text cells

You can set the DefaultInlineFormatType option of Text cells to "StandardForm", and then set the ...
Carl Woll's user avatar
  • 130k
5 votes
Accepted

Syntax information "ArgumentsPattern" for function of function?

This is not currently possible. The SyntaxInformation is set up to color "down values" (definitions of the form f[x_,y_] := ...)...
Itai Seggev's user avatar
  • 14.1k
5 votes

Colored marks appearing in notebook input text?

I know this is an old post but if anyone has the same problem go to Edit->Preferences->Advanced->OpenOptionInspector enter ShowCursorTracker in the look up textbox and set its value to False. This ...
Guiguy's user avatar
  • 51
5 votes

How to program a F::argx message?

There's a nice internal method for this that has existed since at least 10.4: System`Private`ArgumentsWithRules. You can use it to define a nicely handled function ...
b3m2a1's user avatar
  • 46.8k
5 votes

Syntax highlighting indicates I'm unable to comment properly in Mathematica using (**)

Your comments are fine, if in doubt always check the FullForm of the expresion. The problem is only in the syntax highlighting, that has been far from perfect in ...
rhermans's user avatar
  • 36.3k
4 votes

How can one define an infix operator with an arbitrary unicode character?

You can fix the syntax coloring by using a TagBox to customize AutoStyleOptions (the syntax colorer thinks the operator is an ...
Carl Woll's user avatar
  • 130k
4 votes

Is it possible to change the fontsize when printing a notebook in the working environment?

For those like me who were confused even after reading Alexey Popkov's answer, let me provide more detail: Click Format -> Edit stylesheet A window will open that says "Private stylesheet for ...
Nic Scozzaro's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible