In VS Code, I'd like to have one textmate scope (e.g. punctuation.definition.variable) reference another one (e.g. variable.other.readwrite.global) so that the first element always uses the second element's color. Is that possible?
I am not interested in creating my own theme because I want these changes to be dynamic, to stay in effect regardless of what theme is in use. Specifically, the Perl syntax definition for $foo separates the sigil (e.g. $) and the variable name (e.g. foo) into two separate elements, and I would like to treat them as one.
In settings.json you can customize the editor workspace syntax highlighting with editor.tokenColorCustomizations and that will apply to every theme unless you specify it for some themes only.
Docs: https://code.visualstudio.com/docs/getstarted/themes#_editor-syntax-highlighting
Here you can find Docs for creating you own rule for syntax highlighting: https://code.visualstudio.com/api/language-extensions/syntax-highlight-guide
Related
Pydev offers code templates when you create a new Python module. They include variable substitution such as ${my_variable}. How are these variables supposed to be given values?
Those "variables" are not user's variables.
Their whole list is available via button "Edit Variables...". This button appears when you edit a PyDev editor template (either creating a new one of modifying an old one). Their definitions are prefixed within PyDev. You should neither expect to define your own template variables nor expect to modify the definition of the already provided ones.
I updated the vscode to v1_43.
It's too bad to highlight the new syntax.
How to use v1_42 syntax highlighting in v1_43.
prev
new
This is semantic highlighting. Semantic highlights are based on the type of the values, for example globals can be colored differently than local variables.
To disable it, just set:
editor.semanticHighlighting.enabled: false
Try leaving it on however. Semantic highlighting provides useful information and once you get used to it, the old highlighting will instead look wrong
When using "change all occurences" in VS Code, it will just search the whole file for matches and change them. Is there a similar feature doing the same thing, but limiting it to function or block scope?
Let's take an example where I would need that: I'm having a React file with several components and want to refactor a class component to a functional component, so I'm changing all occurences of this.props to props. However, I obviously don't want to change all the other class components as well that are supposed to stay class components. :-)
This seems like such a standard use case, but I'm not able to find it anywhere in VS Code. If it's not possible (yet, or for some good reasons) is there another way to achieve what I'm trying to do?
Check out the 'Add Selection To Next Find Match' functionality. It allows you to highlight the first occurrence you'd like to change, then using a keyboard shortcut, highlight the next occurrence and so on until you've selected all the instances you want to change. When all to-be-changed occurrences are selected, you can edit the selected text normally. Just remember to hit the escape key a couple times after editing to return to a single cursor!
Here are the keybindings for the command, it's Cmd+d on Mac:
https://code.visualstudio.com/docs/getstarted/keybindings
I find it very useful when renaming variables, there's also a shortcut to skip occurrences (Cmd+k Cmd+d) in case there is text you don't want to change in between.
This has been bothering me for a while, but I can't seem to figure out how to change this formatting. Let's take a case class as an example:
I prefer two tabs after a line-continuation; however, IntelliJ seems to force this style:
This behavior seems to be controlled by Preferences -> Editor -> Code Style -> Scala -> Other -> Alternate indentation for constructor args and parameter declarations, which specifies a minimum of 0 spaces, and that simply brings the arg list inline with the opening parentheses. This isn't a big deal by itself, but whenever I copy/paste blocks of code, it reformats everything and I have to go back and shift-tab ad nauseam. Is there a style field that I'm missing somewhere?
There's an Intellij only solution:
Under Wrapping and Braces, disable Method declaration parameters > Use normal indent for parameters.
Then, under Other, enable Alternate indentation for constructor args and parameter declarations and set to the number of spaces you want to indent from the declaration level (in your case 4).
You want "Align when multiline" checked in the code style settings
You can also look into scalari-form plugin. It gives you much more and IDE independent. You are particuliary interested in alignArguments=true and if I remember correctly defaults should make the indentation as you want.
*Note, that it formats code after some sbt task, for instance sbt test, not when you press Ctrl+Alt+L or similiar in IntelliJ
How do I refer to a color name that is defined by a color theme in another part of emacs?
In base16-solarized-dark-theme.elfile the following colors are defined:
(deftheme base16-solarized-dark)
(let ((base00 "#002b36")
(base01 "#073642")
(base02 "#586e75")
(base03 "#657b83")
(base04 "#839496")
(base05 "#93a1a1")
(base06 "#eee8d5")
(base07 "#fdf6e3")
(base08 "#dc322f")
(base09 "#cb4b16")
(base0A "#b58900")
(base0B "#859900")
(base0C "#2aa198")
(base0D "#268bd2")
(base0E "#6c71c4")
(base0F "#d33682"))
Now, I'm trying to define the face colors for the auto-complete package in my .emacs like this:
(set-face-foreground 'ac-candidate-face "base02")
(set-face-background 'ac-candidate-face "base0A")
But it doesn't work. Emacs doesn't give any error, but the colors don't get defined like that.
I can't tell for sure without seeing the rest of the code, but in this particular case, the chances are that you can't refer to them by name.
let bindings are only in scope while the body of the let form is being evaluated.
Whatever is going on in the body of that form presumably makes use of those named values, but the symbols don't continue to hold those values afterwards.
FYI if they did you would refer to them as, e.g., base0A, rather than "base0A" -- the former being a symbol which evaluates to the value assigned to it, whereas the latter is a string value (which could be interned to get at the variable of that name, but typically wouldn't be if there wasn't a good reason for it).