Intellij IDEA 11.0.2, set tab size for custom file type? - tabs

I'm using a fully licensed version of Idea.
I just created a custom file type for *.jade files. Generally, I use a 4-space tab-size, but for *.jade files, I want to use a 2-space size.
That's it. I don't want a work around. I want to be able to set a specific tab size for only *.jade files.
http://www.jetbrains.com/idea/features/code_style.html
says: "...tab and indent size can be specified per file type."

It's not possible to specify indent settings separately for custom file types right now. Such functionality is provided by the language specific plug-ins (even some language plug-ins do not allow to set custom indents and use settings from the General tab).
There is already a feature request submitted 7 years ago and with zero votes. Feel free to vote.

Related

Color/highlight or Add an icon to a specific file under project files

I have a very important file at the level of my project which is called veiw.yml. I would like to color/highlight or put an icon on it, in order to make it more attrective for me. In other words I want color or add an icon on one of my yml file at the level of my project files, that match the exactly regex expression ^views.yml$.
Is there any way I could do the trick with phpstorm or change the phpstorm Atom Material Icons plugin configuration to add another icon to his iconslist?
Any idea, help would be appreciated.
There are many options that can be used based on what exactly you want to achieve (why you need to highlight such file -- maybe you do not need highlighting but want something else and you do not know about such possibility):
Just add the desired file(s) or folder(s) to the Favorites and use it instead of locating that file in a Project tree all the time.
NOTE: Bookmarks have now replaced Favorites that existed in earlier versions of the IDE.
You can bookmark specific file with Mnemonic Bookmark (0..9 mainly) and then open such a file with just one key press from anywhere. This will also add a special mark next to the file name.
NOTE: this is a per file thingy, no patterns.
https://www.jetbrains.com/help/phpstorm/bookmarks.html#add-mnemonic-line-bookmark
https://www.jetbrains.com/help/phpstorm/bookmarks.html#navigate-bookmarks
If it has to be a different color in the Project view panel... then just define custom scope at Settings/Preferences | Appearance & Behavior | Scopes and then (once scope is fully saved) associate that scope with specific color at Settings/Preferences | Appearance & Behavior | File Colors (ensure that appropriate checkbox is selected, which is by default).
You will now have different backgrounds under such files in the Project View panel and other lists where file names are used.
https://www.jetbrains.com/help/phpstorm/configuring-scopes-and-file-colors.html
https://www.jetbrains.com/help/phpstorm/settings-file-colors.html
ProjectTree Color Highlighter plugin (https://plugins.jetbrains.com/plugin/13951-projecttree-color-highlighter) -- allows assigning custom colors to custom files.
NOTE: does not support patterns, only manually assigning files. Therefore this can be treated as a Plus or as a Minus, depending on your needs.
Extra Icons plugin (https://plugins.jetbrains.com/plugin/11058-extra-icons). It allows assigning custom file icons based on folder or file name patterns. You can even bring your own icons.
NOTE: From the 2022.1 version it is a paid plugin now (only $5 USD per year but still).

Sublime text 2 Snippets - autocomplete

I've created a bunch of snippets in Sublime Text 2, but I cant remember them all off the top of my head. I've seen in a number of tutorials that as people start typing their snippets tab-triggers it will start to provide a list of the matching snippets. I don't see this.
Is there a setting somewhere for this? Or do I need to create a special file (completions file?). For most snippets I have the <scope> commented out as I may use in a PHP or HTML file for example depending what I am working on.
Most of my snippets tab triggers start the same elq- prefix, so it would be very helpful if it were to start showing me the options as I type.
The setting auto_complete_selector controls when Sublime automatically offers the popup for possible completions. The default value for this setting is:
// Controls what scopes auto complete will be triggered in
"auto_complete_selector": "source - comment",
This means that it will automatically pop up for any file that's considered a source code file, except within a comment.
The scopes for the file types that you mention in your question are text scopes and not source scopes, which stops the popup from appearing.
One way around that would be to manually invoke the auto complete panel by using the appropriate key binding, which by default is Alt+/ on Linux or Ctrl+Space on Windows/OSX. When you do that, the popup for possible completions at this point is manually displayed.
To allow this to work more automatically, you would need to modify the setting for auto_complete_selector to be more appropriate for your situation.
To do that you could select Preferences > Settings - User from the menu and add or modify the auto_complete_selector setting as follows:
"auto_complete_selector": "source - comment, text.html",
This says that the selector should always be displayed in source files except inside comments (like the default) and also within HTML files.
You could also use text instead of text.html if you want it to work in all text files of all types, although this would possibly get quite annoying while working with plain text files. Substitute an appropriate scope or set of scopes here as appropriate to dial in the places you want this to be automatically offered.

Custom code snippet for WebStorm and PhpStorm

I use custom code snippet for Sublime Text like custom comments, function, reusable block code, CDN and more.. but I could not do that in WebStorm and PhpStorm IDE.
Here is my building block code snippet (comments) for Sublime Text:
/*============================
comments
============================*/
and this code blocks for HTML5 comments
<!-----------------------
comments
----------------------->
Moreover I'm new user for JetBrains software. Can I use custom code snippet above in JetBrains software ?
It's called Live Templates in JetBrains IDEs.
Available at Settings/Preferences | Editor | Live Templates.
You can use existing Live Templates as is, alter them to your needs or create your own.
Creating own is better be done in own group -- they will be stored in separate config file so easier to share, no possible conflicts with built-in ones (easier to update between versions etc.). It also makes perfect sense to use separate group per language -- the same abbreviation can be used for different languages/context but abbreviation within the same group must be unique.
BTW -- I'd say -- do not edit built-ins at all -- just disable specific built-in template and create your own version of it in separate group. This way you can always see what fix/change devs have made in new IDE version etc.
Full official tutorial/how-to is available here: https://confluence.jetbrains.com/display/PhpStorm/Live+Templates+%28Snippets%29+in+PhpStorm
You may also be interested in other articles:
https://confluence.jetbrains.com/display/PhpStorm/Tutorials
in particular (since you have used Sublime in the past): https://confluence.jetbrains.com/display/PhpStorm/PhpStorm+for+Users+of+Text+Editors
Finally I get a tips ! PhpStorm allows you to create your own live templates (code snippets) to optimise your workflows.
Open the settings dialog and head into Editor | Live Templates, you can see the available live templates grouped by language. To add a new template click the + (plus) button and select Live Template. Specify the abbreviation (the short bit of text you type that will be expanded to the full code snippet) and a description.
Then provide the full code snippet in the Template text field. You can include variables in the template in the format $<variable name>$, which will allow you to provide values when the template is expanded. PhpStorm recognises $END$ as a special variable indicating the final position of the cursor after the template has been expanded and values have been provided for all variables.
Next click the Define warning text to specify which language the template is for and optionally the context it is available in.
Now the template is ready to be used. Open a file and type the abbreviation that was specified earlier, then hit Tab to expand the template. The cursor will be positioned on the first variable, provide a value then hit Tab to keep moving through all available variables. The final position of the cursor will be the location of the $END$ variable.
Further Reading
Creating & Editing Live Templates
I don't think you can do this, however you can add custom tags in Settings > Editor > TODO.
//TODO & //FIXME are already implemented.
But this custom tags are not working for HTML.
Maybe you can find an extension to do that in Settings > Plugins.

Limit the allowed file size for <input type=file> in pure HTML (no JS)

There are several topics* about setting up a max file size for a input type=file, but there is apparently no pure-standard HTML way to do so (nothing in the HTML spec).
So, is there any pure-HTML way to set a max file size on a input type="file"?
Is there a request for such feature, like a maxsize="..." attribute to let the browser filter out the files the user can selected, or do we have to stick to Javascript File API for years (or ever)?
*Topics:
JS File API: Limit the size of an file upload (html input) or How to check file input size with jQuery?
HTML never-saw-that-in-any-standard: HTML Upload MAX_FILE_SIZE does not appear to work
This is not part of the HTML spec, so there is no "pure HTML" way to do this.
I could only find this mention from 2013 with no reaction. Couldn't find any mentions in https://github.com/whatwg/html/issues
Sounds like it's something you could suggest, see FAQ - Is there a process for adding new features to a specification? for the recommended way to suggest new features to the working group. Please post the link to the discussion here if you do bring it up.
Though since there's a JS workaround, I guess this won't be high on anyone's to-do list.

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