IntelliJ Code Style Indentation Options seem to be ignored [duplicate] - intellij-idea

I've been attempting to get my Intellij IDEA to confirm to a google-like Java standard - however both imports and manual settings seem to be ignored.
Here's how my indentations are currently set:
However my code still formats at 4 spaces, and when I reformat it goes to 4 spaces as well.
Thanks in advance!

This is the setting for your GoogleStyle scheme. But your project most likely doesn't use it. It's not enough to just select it in the combobox. You need to import this scheme into your project.
Click Manage... and Copy to Project, and it should work as expected.
Also, make sure you're setting language-spefic settings, so instead Code Style select Code Style > Java.

Related

PhpStorm AutoComplete code is not working

I'm using PhpStorm over 3 months and it's a good IDE. I do not know what I've clicked yesterday but since yesterday I have issue with code completion in CSS mainly.
On the screen I have VS Code and PhpStorm and also I've opened the same project.
In VS Code it works perfectly. In PhpStorm it doesn't. I tried some Google First Aid like clear cache, update the IDE, turn On/Off Safe mode etc. but nothing changed.
My Code Completion settings:
Based on your PhpStorm editor area screenshot (many thanks for that BTW: not many people do post it even if asked), all your CSS files are treated as a Plain Text. It's rather unlikely to be a glitch, more like accidental settings change.
Settings/Preferences | Plugins -- make sure that CSS plugin is enabled. If not -- enable and restart the IDE.
If still the same: Settings/Preferences | Editor | File Types -- locate "Cascading style sheet" entry and make sure that it has *.css pattern there.
If not there -- it's possible that you have somehow reassigned it to "Text" file type. If it's there -- just add *.css to Cascading style sheet patterns (it will remove it from Text when doing that).
If still nothing: you would need to provide more/new screenshots.

VS Code Intellisense don't suggest snippet at first

I want to use code snippets in VSCode. But when I type, for example, for in javascript file, the Intellisense doesn't suggest snippet "for-loop" - I need to manually scroll the dropdown and select it. Is there any way to make VSCode to suggest snippets at first? Thank you!
UPD: I have found the person with same problem, but he has no answers - link
You need to use editor.snippetSuggestions config option with "top" value. Please, see Customizing IntelliSense article for more tips and tricks.
There is one more way to deal with this issue by setting
"editor.tabCompletion": true,
that way whenever there is a snnipet available it will use it automatically without even opening the list by using tab twice.
File > Preferences > Settings (Code > Preferences > Settings on Mac)
open "Editor" menu on the left
edit "editor.tabCompletion": true
more info: https://code.visualstudio.com/docs/editor/intellisense#_customizing-intellisense
Now that VS Code mostly abstracted away the settings.json file, you can do the instructions shown by Kavu, with this bonus tip:
go to Preferences > Settings
find the Search settings text input, at the top
type in "snippet"
The setting should be at the top of the result set:
Setting editor.snippetSuggestions to top only works for certain snippets: for but not foreach. With top, the snippet does appear higher in the completion list, but for some reason the keyword version is what is highlighted, with the snippet option scrolled out of view (and the scrollbar quickly fades, giving the impression there's nothing hidden)
The editor.tabCompletion to true approach works for both for and foreach.

IntelliJ IDEA doesn't want to indent with tab

I want to indent with tabs, so I checked "Use tab character" in settings. But when I open projects which were indented with tabs, IntelliJ IDEA still asks me if I want to convert the indenting to spaces or keep it that way. Also, it creates new classes with space indenting. How can I solve this?
Your screenshot shows the settings for your Default (1) scheme. Those settings are not applied to your project automatically. It's not enough to just select it in the combobox. You need to import this scheme into your project.
Click Manage... and Copy to Project, and it should work as expected. This needs to be done for all your projects.
Also, make sure you're changing the language-spefic settings, so instead Code Style select Code Style > Java (or whatever language you are using). Those settings may override the default code styles.

Ignore whitespace changes in IntelliJ changebars

I have a file from our repository where I ran auto-indent (because it was a mess), and now the whole file is marked by blue changebars (down the right hand side of the editor window), making it difficult to find my changes.
I am already ignoring whitespace changes in the diff window (as described here: Intellij and changes tab), is there a way to also do this in the editor window?
I couldn't find a way to completely ignore whitespaces, but IntelliJ (I'm using version 2016) lets you set an option to color whitespace-only changes differentely:
Editor -> General -> Different color for lines with whitespace-only modifications
which helps tremendously.
At the moment [idea 13.5] it seems that is not possible to ignore spaces in the standard editor. You can open a support ticket
We also faced this in the company due the different codestyles used, at the end we settle for:
setting a common codestyle that everyone editing the code should [actually must] follow
reformat the whole codebase to the given codestyle
recommit the formatted code [without any addition or deletion, just the reformat]
It took just a bit of time, but at the end now we are working far better. In this way from that moment onward, we would have all the time the code that would aesthetically the same trough next versions.
You can completely disable the highlight of whitespace modified lines in :
Settings -> Editor -> Color Scheme -> VSC -> Editor Gutter -> Whitespace-modified lines
And then uncheck the background color :
Essentially, you want Intellij to use the --ignore-all-space or --ignore-space-change upon a merge.
My developer team also deals with this challenge because we have different code formatting preferences. The result is every merge is painful for no reason. The team loves being able to have their code formatting, but this negates it.
As of now there is no solution. Intellij has the technology to ignore whitespace, so fixing this is really just adding a check box on the merge diff screen or even in the version control settings.
There is a feature requests IDEA-107714
Please up vote it!
https://youtrack.jetbrains.com/issue/IDEA-107714
Try this,
View --> Active Editor --> Show whitespaces
this is guaranteed to solve your problem

Is there a Textmate equivalent of "Format indenting of selected code" in Sublime Text 2?

In Textmate, the keyboard shortcut ⌘⌥[ properly indents all the nesting on selected code.
Is there a similar option in Sublime Text 2? It's the only thing holding me back from switching and I've checked all documentation to try and find something similar.
I'm not sure if Sublime Text 2 has a generic code formatter, but there are a lot of really good packages out there that will provide various formatting for different languages.
Take a look at Package Control (used to manage plugins for Sublime).
http://wbond.net/sublime_packages/community
For formatting Ruby there's a pretty good package called BeautifyRuby. https://github.com/CraigWilliams/BeautifyRuby
What you are actually looking for is "reindent". It's under the Edit -> Line -> Reindent option. Strangely enough it's not bound to a keystroke. Simply installing code syntax packages will not cause them to apply the formatting to existing code.