Visual Studio Code double quote syntax - visual-studio-code

I just upgraded VS code to v1.20.1 and now I have errors everywhere telling me to replace double quotes with single quotes.
First of, I'm thinking of disabling this feature, since I'm a double quote guy. I have checked my user settings(File->Preferences->Settings) and searched for any tslint validations that has got to do with quotes and couldn't find any.
Second of all, I thought to myself that maybe it could be good practice to use single quotes in JS and I should get used to it.
I though doubt this might be good practice, if not please do prove me wrong.
My question are:
Is or will in the later feature using single quotes in JS will be considered as good practice?
How do I disable double quotes validation in VS Code?

Using single or double quotes is a matter of programming taste, at least for me.
To disable quotes validation you need to edit tslint.json (or create it: Create a tslint json file command) in project's folder, find the rule "quotemark" and set the following:
"quotemark": [
false
]
As you see, it is a linter configuration, instead of vscode one. More information of this rule on tslint documentation.
If you want to continue with your double quotes set:
"quotemark": [
true,
"double"
]
Hope it's useful for you.

Related

Does VSCode snippet syntax allow optional parameters to a command

I recently started using a 3rd party extension for language supporting robot programming (RoboDK). The extension is pretty good but doesn't include many of the commands I would like to use and doesn't correctly (at least to me) handle optional arguments to commands. I'd like to 'extend' the extension to support additional commands (and potentially provide this feedback to the developer).
I'm specifically using ABB's RAPID robot language.
Example:
MoveL robtarget, speeddata, zonedata, tooldata \WObj:=WObj0;
For MoveL, var1 thru var4 are required but \WObj:=WObj0 is optional. The '\WObj0:=' part of the string is a constant (if supplying the option) and WObj0 would be a variable of the expected type for MoveL (a work object, in this case).
Is there a way to edit the snippets json to not enter the optional part unless I start typing a backslash followed by text? I also would like to keep the optional part in the snippet as a reference so I don't have to remember every optional argument as some commands have many options.
Here's an excerpt from the snippet.abb.json file:
"movel": {
"prefix": "movel",
"body": [
"MoveL ${1:var_robtarget}, ${2:var_speeddata}, ${3:var_zonedata}, ${4:pers_tooldata} \\WObj:=WObj0;"
],
"description": "Linear motion"
},
Which results in the code with var_robtarget, var_speeddata, var_zonedata & pers_tooldata all highlighted and the remainder is plain text:
MoveL var_robtarget, var_speeddata, var_zonedata, pers_tooldata \WObj:=WObj0;
Is there a way to edit the snippets json to not enter the optional
part unless I start typing a backslash followed by text?
No, I don't think there is any way to do that within the same snippet. You could make another snippet with the backslash prefix but that is cumbersome.
Here is a simple way to do what you want but you will have to delete any optional variables you don't want:
"body" [
"MoveL ${1:var_robtarget}, ${2:var_speeddata}, ${3:var_zonedata}, ${4:pers_tooldata}${5: \\WObj:=WObj0}${6: anotherVar};"
]
That last variables are also selected when you get to them. If you don't want any just hit Delete.
In the above demo I am just tabbing and deleting.

Prettier keeps replacing asterisk characters with underscores

I'm trying to write some markdown text in Visual Studio Code and whenever I write this:
*some text*
It's being replaced by this as soon as I save the file:
_some text_
I narrowed it down to be caused by the Prettier extension. I tried looking for a setting that might control this but didn't find any - well none that was obvious to relate to the issue.
I'd really like to keep Prettier enabled for markdown files as it also keeps tables nice and tidy.
Is there a way around this one issue?
UPDATE:
I am aware that both asterisk and underscore works for italic emphasis when the file is shown through a markdown viewer, but when reading the file as pure text, the asterisk feels more natural to me for emphasis and I'd much prefer keep using it if possible.
I also feel the same way, but from what I can tell Prettier simply does not have that option (https://prettier.io/docs/en/options.html)
Prettier is not a kitchen-sink code formatter that attempts to print your code in any way you wish. It is opinionated.
https://prettier.io/docs/en/option-philosophy.html
Given that philosophy, I doubt this will ever change. As for me, I think I'm going to try to just get over it.
I think the only way to avoid this would be to use something different, for example:
https://marketplace.visualstudio.com/items?itemName=DavidAnson.vscode-markdownlint

How can I debug a VS Code Problem Matcher

I'm trying to write a custom problem matcher for VS Code. My matcher matches nothing, even though testing the regular expressions on the output seem to work. I'm not even sure VS Code loads my problem matcher, let alone see which regular expression matches and which isn't.
Is there a way to debug a problem matcher? I'm basically stuck with no way to move forward.
This is an old question, but I found this site super helpful:
https://regex101.com/
It allows you to debug regular expressions. You can put an example line of compiler output and try your matcher against it.
One issue I had to figure out is that the VS Code expression is stored in a JSON file, so it has extra escape characters that should be removed if you're using the regex somewhere else.

How to customize formatting warning in Webclipse for Angular 2 Typescript?

Webclipse gives a lot for formatting warning for the Typescript code, for example, for blank spaces and for using double quotes instead of single quotes. The latter one is annoying since using double quotes for strings is quite appropriate.
Is it possible to customize these warnings?
It appeared that the Webclipse setting for warnings are in the file tslint.json in the root directory of the Angular application. The easiest way to change these settings is to use the Eclipse Quick Fix option, and then use the hint to remove this warning from tslint.json.

Shortcut for clike languages comments not working/implemented?

I'm using the Brackets code editor to code in C++ and I'm having a hard time having the shortcut for lineComment and blockComment working...
The shortcuts are [Ctrl+/] and [Ctrl+Shift+/], they work perfectly for CSS, JS.. etc but not with C++ files.
I looked into the clike.js file in the CodeMirror folder of Brackets, the blockCommentStart, blockCommentEnd and lineComment are correctly defined.
Is it a known issue? has anyone found a workaround?
Before that,I was coding with Notepad++ and this feature was the one I used the most. It's really hard not to have it anymore
You said you saw that blockCommentStart, blockCommentEnd and lineComment are correctly defined in clike.js. From CodeMirror documentation
This file defines, in the simplest case, a lexer (tokenizer) for your
languageā€”a function that takes a character stream as input, advances
it past a token, and returns a style for that token. More advanced
modes can also handle indentation for the language.
It is used to highlight the c++ file. But also it could be used to auto comment line with shortcut. However it is probably not implemented for C++. For this feature comment addon from CodeMirror might be used http://codemirror.net/addon/comment/comment.js since The addon also defines a toggleComment command, which will try to uncomment the current selection, and if that fails, line-comments it.
This was a Brackets bug, but it was fixed in the Sprint 39 release.
(Fwiw though, language metadata in Brackets is defined in a file called languages.json - although Brackets extensions can add to / modify this metadata as well).