I have just made the switch from Espresso to Sublime Text 2 and cannot work out how to edit the closing brace location on CSS code blocks. I am very particular about coding style and prefer the following:
element {
property: value;
property: value;
}
element {
property: value;
}
When an opening brace is invoked in Sublime Text 2, the closing brace appears directly after it with the cursor carat in between the 2 braces. I would like to set it so that the following takes place:
element {
[carat-location]
}
Properties can then be added within the braces. Once done, tab is keyed and the carat is moved to the following location:
element {
property: value;
}
[carat-location]
I have been able to set this in Espresso by editing the Sugar packages but I have not been able to track down where Sublime Text 2 adds these settings (if at all).
You can create a snippet. Tools/New Snippet...:
<snippet>
<content><![CDATA[
{
${1}
}
${2}
]]>
</content>
</snippet>
Save it as Packages/User/CurlyBrackets.sublime-snippet.
Then, add a shortcut in your Key Bindings - User:
{ "keys": ["{"], "command": "insert_snippet", "args": {"name": "Packages/User/CurlyBrackets.sublime-snippet"},
"context":
[
{ "key": "selector", "operator": "equal", "operand": "source.css" }
]
}
This way, when you'll press {, in css files, you'll have what you asked for.
Related
I'm trying to customize my VSCode theme using textMateRules. What I want to do is to change the color class names, but not all of them, only specific ones.
For example, in the project I'm working in, we have classes: A, B, C, D ...
A and B are "special" classes and I would like to highlight them differently (let say in red). This is what I added for now in my setting.json file:
{
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": "entity.name.type.class",
"settings": {
"foreground": "#FF0000",
}
},
]
},
}
But it is highlighting all the classes names (including C, D and all the others).
Is there a way to add more rules to the scope, like a regexp match?
As recommended by #rioV8 I used the Highlight extension:
And I added this in my setting.json:
{
"highlight.regexes": {
"(A|B)": {
"decorations": [
{
"color": "red"
},
]
}
},
}
I'm trying to change the color of the word after import in JS, in VS Code. I attached a screenshot of what I mean.
Screenshot:
What I'm referring to is underlined in red
I didn't find a valid entry in the textMateRules for this.
I'd appreciate some help. Thanks :)
I don't know which flavor of javascript you are using but you can use the following in your settings.json:
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": "variable.other.readwrite.alias.js",
"settings": {
"foreground": "#FF0000"
}
}
]
}
How to know which scopes a given token has
In your command palette type:
> Developer: Inspect Editor Tokens and Scopes
This will show a popup of information related to the token at cursor:
You will see applicable scope entries at the bottom for textmate scopes, you can use any of the options listed, but the topmost option is the most specfic option
If you use the Inspect Editor Tokens and Scopes command (from the Command Palette) you will see this scope:
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": "variable.other.readwrite.alias.js.jsx",
"settings": {
"foreground": "#ff0000",
"fontStyle": "bold underline"
}
},
]
},
You cannot add a colored underline without also changing the font color also.
If you really want to color the line differently than the text (and many other formatting options, see https://code.visualstudio.com/api/references/vscode-api#DecorationRenderOptions
use the Highlight extension:
"highlight.regexes": {
"(import\\s+)(.*?)(\\s+from .*)": {
"filterLanguageRegex": "javascriptreact",
"decorations": [
{},
{
"borderWidth": "0 0 2px 0",
"borderColor": "red",
"borderStyle": "solid"
}
{}
]
}
},
LOL: you probably just wanted to change the word color, not the underlining. Nevertheless, the Highlight extension gives you many more options, like outlines, borders, backgroundColor, letterSpacing, even before and after css properties - so you can easily make the text you want to stand out.
Everytime I try to use ctrl-shift-up or ctrl-shift-down inside of the new windows terminal preview, it scrolls the terminal view up or down. I tried going into the profiles.json file and set the "command" : "scrollDown" and "command" : "scrollUp" to "unbound" but it has no effect.
If I try to bind scollUp to something else, let's say ctrl+alt+b, then it correctly adds the keybind to the command. It seems like there's a default windows keybinding that is set to scroll the terminal view up and down using ctrl+shift+arrows.
Not sure if you found the answer, but I was looking for this too. Found the below in a microsfot devblog that works currently:
If there is a default key binding included in the defaults.json file
that you would like to free up, you can set that key binding to null
in your profiles.json.
{
"command": null, "keys": ["ctrl+shift+w"]
}
Link to full article:
https://devblogs.microsoft.com/commandline/windows-terminal-preview-1910-release/
you can add
{ "command": { "action": "sendInput", "input": "\u0000" }, "keys": "ctrl+shift+up" },
{ "command": { "action": "sendInput", "input": "\u0000" }, "keys": "ctrl+shift+down" },
so when you press the keys, it replaces the undesirable command with sending a null character to the input (that, of course, does nothing lol)
I'm currently setting up VS Code for Python development. I'd like to have triple-quoted docstrings highlighted as comments, not as strings, i.e. grey instead of light green in this picture:
I know that I can adjust this in the TextMate rules for this theme, but I can't figure out the right scope for Python docstrings. I thought I would be something like this:
"editor.tokenColorCustomizations": {
"[Predawn]": {
"comments": "#777777",
"textMateRules": [
{
"scope": "string.quoted.triple",
"settings": {
"foreground": "#777777"
}
}
]
},
}
but that does not have the desired effect, even after restarting the editor. Does anyone know what the right scope is?
Just to expand on the comments above, the scopes are:
For docstrings: string.quoted.docstring.multi.python for """ ''' (or .single for ' ")
For triple quote strings that are not docstrings: string.quoted.multi.python
The scope string.quoted.triple is not used, even though it appears in settings.json autocomplete.
Try using this one
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": [
"string.quoted.multi.python",
"string.quoted.double.block.python",
"string.quoted.triple",
"string.quoted.docstring.multi.python",
"string.quoted.docstring.multi.python punctuation.definition.string.begin.python",
"string.quoted.docstring.multi.python punctuation.definition.string.end.python",
"string.quoted.docstring.multi.python constant.character.escape.python"
],
"settings": {
"foreground": "#777777" //change to your preference
}
}
]
in eclipse or vs or si, I can type alt+← to navigate to last view(back) or alt+→ to next view(forward), is there any keyboard shortcut or plugin to do this in sublime text.
i tried searching in package control and nothing seems related
You can define that behavior in the user key bindings.
Preferences -> Key Bindings - User
And then define there the combination of keys that you want. E.g. In this case, those commands would be Ctrl+4 and Ctrl+6
[
{ "keys": ["ctrl+6"], "command": "next_view" },
{ "keys": ["ctrl+4"], "command": "prev_view" }
]
This is an old question, but I wished to do the same. I found that such navigation can be configured in Sublime Text 3 via user key bindings:
Preferences -> Key Bindings - User
Include these { braced lines } in the [ array ]:
[
{ "keys": ["alt+left"], "command": "jump_back" },
{ "keys": ["alt+right"], "command": "jump_forward" }
]
(For earlier versions of Sublime, there's an extension https://github.com/timjrobinson/SublimeNavigationHistory)