In VSCode, I'm using the Twig Language 2 extension to deal with Twig-like syntax inside HTML files (actually I use the Pebble templating engine). I configured VSCode so the brackets are colorized:
"files.associations": {
"*.html": "twig"
},
"[twig]": {
"editor.bracketPairColorization.enabled": true
},
"workbench.colorCustomizations": {
"editorBracketHighlight.foreground1": "#15d31e",
"editorBracketHighlight.foreground2": "#15d31e",
"editorBracketHighlight.unexpectedBracket.foreground": "#ff0000"
}
The colorization (green, in my case) works well when the {{ and }} brackets are used "at the elements level" of the HTML file, but not when they are inside a string. For example:
Since the Twig/Pebble blocks are interpreted even when they are inside a string, it would make sense, in my opinion, to highlight the brackets there too.
Is this possible?
The extension 2gua.rainbow-brackets does apply Bracket colorization within Strings... but it doesn't seem like you can edit the choice of bracket colors, and they don't contrast well with the color of string text
Related
How to enclose curly braces in parenthesis in vim?
Initial string:
{a: b}
Final string:
({a: b})
The string possibly span multilines:
{
a: b
}
Assuming you are in normal mode and on any curly bracket character (opening or closing).
The manual/vanilla version (without any bracketing plugin) would be
c%(^R")
With:
^R meaning CTRL+R
the default register (") being filled with the content of the dictionary.
ca{ that should be used instead of c% if you're anywhere within the dictionary.
With my lh-brackets plugin, I would use v%( or vi{( -- unlike the vanilla version, will leave the default register unmodified.
With the popular surround plugin, I guess (I may be wrong as I've been using my plugin for decades) it would be something like ys%( or ysa{(.
PS: the fact your dictionary spans on several lines doesn't make any difference here.
With the vim-surround plugin you can visually select the text first e.g. va{, then surround with parentheses using S). I find it easier to remember this visual surround sequence v{motion}S<char> than the other options
I have something like the following under properties for an application settings configuration:
"my_setting" : "[{width:1, height:2}]"
I want exactly the string contained in the value (including the square brackets) to appear on the application settings. Unfortunately, the opening square bracket indicates a function and the deployment throws me an exception due to it. How can I escape the beginning square bracket?
The escape sequence for ARM templates is the left bracket itself (i.e. just put two together)
"my_setting" : "[[{width:1, height:2}]"
How can I escape the beginning square bracket?
We could use the concat function to avoid to using the special characters
"variables": {
...
"left": "[",
"right": "]",
...
},
Please have a try to use following code. It works correctly on my side.
"my_setting": "[concat(variables('left'),'{width:1, height:2}',variables('right'))]",
I'm trying to change my sublime theme/colour scheme and i get
'unexpected trailing characters'
When I try to save the /User/Preferences.sublime-settings with this config
{
"theme": "Afterglow-green.sublime-theme",
"color_scheme": "Packages/Theme - Afterglow/Afterglow.tmTheme"
}
{
"tabs_small": true
}
I can't work out why I would be getting that message?
Your settings files in Sublime (all of them) need to be valid JSON. Yours should be as follows:
{
"theme": "Afterglow-green.sublime-theme",
"color_scheme": "Packages/Theme - Afterglow/Afterglow.tmTheme",
"tabs_small": true
}
Note that everything is enclosed in one (and only one) outer dictionary, denoted by curly braces {}. There should also be a comma , at the end of every key: value pair, except for the last line. If there is only one line, don't use a comma.
Just out of interest, what is the "tabs_small" setting for? It's not one of Sublime's default settings.
The selected answer is correct, however this prompt can also occur during application startup.
If this error occurs when you're starting Sublime, navigate to C:/Users/{Your User}/AppData/Roaming/Sublime Text 3/Packages/User and open Plain text.sublime-settings.
The issue with JSON can be resolved here.
When working with blocks of code in VIM, I'm able to easily re-indent blocks of code via selecting a region in visual mode (SHIFT+v), then just hit =. This re-tabs lines of code, uses the correct indentation depths, hard-tabs vs spaces, etc.
I have a large set of functions I need to re-factor, and I have several blocks of code with braces on the same line as if/else keywords, ie:
if(something) {
doFunction(something);
} else if(somethingElse) {
doFunction(somethingElse);
} else {
// default stuff to do
}
And I would like to change the brace and spacing style to:
if ( something ) {
doFunction( something);
}
else if ( somethingElse )
{
doFunction( somethingElse );
}
else
{
// default stuff to do
}
The differences include:
Having the opening/closing braces on their own dedicated line
The argument to if, else if, and functions has a space separating the beginning and end of the argument list from the surrounding round brackets.
There is a space between if/else if and the argument brackets, but not for function names and the argument brackets.
Is there a way to set this style as the default in VIM, and to also have re-indentation commands change the style to match the latter of the two I've provided? I've found tools to enforce things like line endings, tabs-vs-spaces, etc, but not style details like those shown above.
Thank you.
The indentation scripts in vim are not constructed for so complex tasks. I would advise you to use the indent command, in particular the following arguments:
-prs, --space-after-parentheses
Put a space after every '(' and before every ')'.
See STATEMENTS.
-sai, --space-after-if
Put a space after each if.
See STATEMENTS.
You should read the command's man page for more details.
Obviously, this command can be used to filter the buffer's content using:
:%!indent
How I can recive colored result from Replace Function?
Regex.Replace("My Document", "My", ?);
EDITED:
I soleved it:
if (richTextBox1.Find("ab") > 0)
{
richTextBox1.SelectionBackColor = Color.LightGreen;
}
(Parts) in strings don't have an inherent color. A string is only a sequence of characters. Some terminals however use "escape characters" that are interpreted as meta-data on how to typeset parts of the string.
For instance the linux shell uses data like "\033[31mHello\e[0m World" to highlight Hello in red. But there are always terminals that will not recognize such directives.
Some control components (i.e. the RichtTextBox) use such directives as well and provide transparent methods to insert directives.