VSCode not adding closing brackets with correct settings - json

My vscode editor is set to automatically add closing brackets/parenthesis but does not add them. This is a new issue that only recently began. Has anyone else experienced this issue with global vscode settings?

This may be caused by the new vscode extension GitHub Copilot.
Update your settings.json like the following...
// Must specify rule by language
"[typescript]": {
"editor.autoClosingBrackets": "always"
}
This can become an issue as the new GitHub Copilot will override some settings in settings.json file. In order to take back control from the GitHub Copilot extension you must specify some rules like editor.autoClosingBrackets on a per lang basis.

Related

How to disable Auto ID in Visual Studio 2017

When copying and pasting HTML, VS helpfully renames all my variables to things like "Div1" & "Img1". Why!
I remember when using VS 2010 I think it was, there was a setting that allowed us to turn this "feature" off. Seems that feature no longer exists.
Are there any plugins or extensions or workarounds for this problem?
Seems that people have been complaining about this for years now:
How do I prevent Visual Studio from renaming my controls?
Disable "Auto ID elements" in Visual Studio 2013
https://connect.microsoft.com/VisualStudio/feedback/details/806446/asp-net-web-forms-development-unable-to-disable-auto-id-generation-on-paste-using-new-version-of-visual-studio-2013
You can use the following command (Language: C#) for my Visual Commander extension to paste text as is without renaming variables:
public void Run(EnvDTE80.DTE2 DTE, Microsoft.VisualStudio.Shell.Package package)
{
EnvDTE.TextSelection ts = DTE.ActiveDocument.Selection as EnvDTE.TextSelection;
ts.Insert(System.Windows.Clipboard.GetText());
}
Here is the simplest workaround.
Simply make a comment first, then paste into the comment. When uncommenting, it will not apply Auto ID.
As a keyboard shortcut, it's CTRL+K,C,V,K,U on a new line.
Comment (KC), Paste (V), Uncomment (KU).
You can disable this auto-tag closing in Options > Text Editor > HTML u can find here everything about html editor.Search for AutoTag or Format Html on paste!

How to change automatic variable generation in PhpStorm?

With PhpStorm, if you type function foo(MyClass $, it will propose myClass as the variable name.
But since I added a WordPress project (I accepted default settings for WordPress as proposed), it propose my_class instead.
I really would like to bring back the camel case naming by default, but I don't find where it is configured.
Is there an option for this? Or maybe a configuration file to edit?
In the settings (Ctrl+Alt+S), go to Editor > Code Style > PHP, then click the Other tab. At the bottom of the screen, you should see the Variable Naming Style section. Select camelCase.

Visual studio code comment in HTML files

I am trying Visual Studio Code lately and i've noticed that when i try to add a line comment in an HTML file (using Ctrl+/ or Ctrl+K Ctrl+C) instead of this: <!-- -->, i get this {# #}.
In JS or CSS files the key bindings work just fine and produce the expected result.
So how can i get the proper type of comments in HTML files?
Finally i found what the problem was. I had installed the twig plugin (for the Twig php template engine) and that was causing the comments issue.
I've just installing VSCode 1.1.1 and try to put a comment in an new html file
To do so, your new file must be,first, save in .html format and after that, you can use CTRL-K CTRL-C to put a comment and it works.
Hope that help you
If you don't want to disable/uninstall any plugin, you can create a snippet to put a comment. For example, I create a snippet that add HTML comments in a PHP file:
"comment HTML": {
"prefix": "chtml",
"body": ["<!-- $1 -->"],
"description": "Comment HTML line"
}
You can insert that right after the comment in File > Preferences > User Snippets > {YourExtension}
Then, when you start typing 'chtml' in that kind of files, IntelliSense will prompt that snippet.
Maybe this is a workarround, but it works excellent for me. Hope it helps!
https://code.visualstudio.com/docs/customization/userdefinedsnippets
For me, it was the (Djaneiro) extension, it made the html files default to django template, so it caused the comments to be wrong in HTML (when pressing ctrl + / )
(commenting them with {% comment %})
List of extensions known to cause this unwanted behavior (Based on my own experience and other answers):
Hugo Language and Syntax Support
Djaneiro
Nunjucks
Tornado
Sublime Babel
Babel
Twig
Django by Baptiste Darthenay (v1.0.0)
(Feel free to edit this answer and add yours)
You may need to restart code after disabling your extension (I did).
In your Visual Studio Code windows, go to File->Preferences->Keyboard Shortcut
This will open two files beside each other like in the screenshot below:
here you can change or create your own shortcuts.
Like I just replaced Ctrl+KU to Ctrl+/
Hope this will work for you !!
For me, the offending extension was Nunjucks (the templating language plugin assumes every .html file is a nunjucks html template)
For others having the problem, the Tornado extension is also a culprit. I had to "disable (workspace)" one by one to find it.
Try uninstalling any python extension packs you may have installed! You can then reinstall the python extension you need individually.
Chances are one of the extensions in the bundle of that extension pack is causing the issue
Click (Ctrl + K C) to comment the html.
Click (Ctrl + K U) to uncomment html.
For me, this was caused by the Sublime Babel extension. Disabling it and restarting VS Code fixed the issue: Cmd+K, Cmd+C works again, as does Cmd+/ for toggling. Also, HTML comment blocks are now correctly styled again.
You can configure the file type at the bottom right corner. you probably are on Django HTML. you can set it to HTML.

vim: about adding new rules to indentation configuration files

in order to get correct indentation in my html5 files, I have added lines like this below to my /usr/share/vim/vim73/indent/html.vim:
call <SID>HtmlIndentPush('header')
As you can guess header is a new tag in html5..
Now I don't know if I should leave those lines in that file or create another file in ~/vim/indent/html.vim that overwrites that /usr/share/vim/vim73/indent/html.vim.
What is your advice?
Take into account that I'm versioning my ~/.vim.
I see that you are using Vim 7.3.
Vim 7.4, which is the current "stable" (in quotes) release, has had its support for HTML improved. I checked the indent script and I can see that it does have code for new HTML5 tags, including header.
You could try upgrading your Vim to 7.4 and your problem will probably simply disappear.

Disable rule in sonar

I want to disable a rule from Sonar so it doesn't show the results in the web page.
In my case I want to hide (or not capture) the results about trailing comments.
Is it posible to configure it somewhere?
Thanks.
The right way to do is to put something like this on sonar-project.properties file per project:
sonar.issue.ignore.multicriteria=e1,e2
# tab characters should not be used
sonar.issue.ignore.multicriteria.e1.ruleKey=squid:S00105
sonar.issue.ignore.multicriteria.e1.resourceKey=**/*.java
# right curly braces should be on a new line
sonar.issue.ignore.multicriteria.e2.ruleKey=squid:RightCurlyBraceStartLineCheck
sonar.issue.ignore.multicriteria.e2.resourceKey=**/*.java
There are docs here on how to ignore specific rules for specific files, which links to an example of how to search for specific rules, by language. This page on baeldung goes into additional detail better than the docs
You have to remove this rule in the quality profile that you are using to analyse your project.
Please refer to the documentation that describes all this: Quality Profiles in Sonar.
In web interface for particular rule just press Deactivate button:
Adding to #Vladmir's answer in a new answer as I am not able to comment.
You can not modify the built-in profiles. If you don't see the option of Deactivate, then copy the profile and set it as default. Now you will see the options to activate/deactivate.
An additional note for people ending up on this thread. I tested this quite a lot and finally found that setting common rules (anything that starts with "common-xxxx") from scanner side (pom, command line etc) will be ignored and it wont work. The language specific rules can be passed line arguments and thats why the "squid:S00105" rule is getting ignored correctly. Here is the issue link on the SonarQube JIRA board and it says that it "wont be fixed".
https://jira.sonarsource.com/browse/SONAR-8230
Here is the link to my answer: https://stackoverflow.com/a/60570763/1766402
on how to set it from UI.
You can't deactivate sonar way rules in a built-in profile. so you have to create your own profile by going to the Quality Profile section and choosing your desired language then click on the config icon the select copy with your favorite name and then you can change any rules in that
and then you can deactivate your considered rules
For Java, You can get sonarlint/sonarqube to ignore false-positives by just commenting //NOSONAR at the end of your code statement. As mentioned in my answer here