how do i remove an auto generated fold region in android stuido? - android-studio

Ive tried to uncheck everything in "File -> Settings -> Editor -> General -> Code Folding". Ive tried "selection/remove region" och "Ctrl+m" och "Crtl+." "Ctrl+alt+-". The automatic folding makes my code incredibly hard to read I just want it gone without removing the fold panel. automatic fold I don't want

Related

How do I keep all my regions collapsed when opening/closing activities?

As the title says - I have some regions where its filled with many lines of code and I want to keep them collapsed till I manually expand them.
How do prevent Android Studio from expanding every region automatically?
I found the solution by going to Settings - Editor -> General -> Code Folding and thereafter checking "Custom folding regions" >.

Convert java to kotlin on paste

So I checked "Don't show this dialog next time", but it turns out that it will then never convert the code again.
Where do I remove the checkmark again so I can get back to converting the java code to kotlin when pasted?
Thanks in advance.
https://developer.android.com/kotlin/get-started.html#convert-to-kotlin-code
Preferences -> Editor -> General -> Smart Keys -> Convert pasted Java code to Kotlin (at the end of the page)
In my case I needed to have the "Do you want to convert ..." dialog again, despite the option to convert checked.
Preferences -> Editor -> General -> Smart Keys -> Scroll to the end -> Convert posted Java code to Kotlin (checked)
Preferences -> Editor -> General -> Smart Keys -> Scroll to the end -> Don't show Java to Kotlin conversion dialog on paste (unchecked)
File -> Invalidate Caches / Restart

Vertical Line in Android Studio

I don't know why but sometime in Android Studio Editor, it shows vertical line as shown in screenshot below.
Don't know about other editor but it happens in Android Studio.
So why it is showing and how to hide it?
That line historically represents the margin of A4 paper, which is useful only if you need to print the code.
Old school says that you should keep your code inside that margin, to guarantee much portability.
But.. nowadays in the real life, it makes no sense to me! Because we always use advanced editors, bigger displays, and I never needed to print any single line of code.
So, if you want to do it:
Newer versions
Editor -> General -> Appearance -> Show hard wrap guide
Older versions
Editor -> General -> Appearance -> Show right margin
or
Editor -> Appearance -> Show right margin
For Mac
To remove line go to:- Preference-> Editor -> General -> Appearance -> Show hard wrap and visual guides. Uncheck it to remove.
It is as follows in the newer version of Android Studio:
Editor -> General -> Appearance -> Show hard wrap guide
im Mac
Open Android Studio and Click
cmd + ,
and follow this step:
Android Studio has changed layout again, so you can find this option at:
File -> Settings -> Editor -> General -> Appearance -> Show hard wrap and visual guides
As it is mentioned earlier, if your code is of that length, it is pretty obvious that it is not that readable, i.e. clean. Being old school, I keep it at 80 characters and spill occasionally.

Disable rearranging methods while auto-formatting

I'm using Android Studio 2.2 and I like auto-formatting my code using ctrl-alt-L. The problem, however, is that it also reorders all of my methods. (For some reason, it wants to put all of my static methods at the top of the class.) Is there a way to disable the rearranging of methods while auto-formatting?
Note: I'm guessing that I could go into Settings -> Editor -> Code Style -> Java and under the "Arrangement" tab delete all of the "Matching rules", but there has to be a simpler way than that, no?
From IntelliJ support at Jetbrain, you can configure default behavior for "Reformat Code" action using ctrl + alt + shift + L shortcut, where you can enable/disable Rearrange code option: https://www.jetbrains.com/help/idea/2016.2/reformat-file-dialog.html.
Also, after a reformat action (i.e. ctrl + alt + L) there will be a pop-up that will say something like, "No lines changed: code is already properly formatted. Show reformat dialog: Ctrl+Alt+Shift+L". The word "Show" will be linked to the "Reformat File Dialog" which is another way to get to the dialog to enable/disable the Rearrange code option.
Arrangement behavior can be customized in File -> Settings -> Editor -> Code Style -> Java -> Arrangement.

Android studio auto fix

I don't know what the exact name is for s feature like this, but I will just describe it.
I am using android studio and I added some java classes from a different project. Now it says
"missing package statement: yada yada". But there is not option in the error popup to just automatically add the missing package statement. I know it seems lazy to not type it, but I like to do things quickly.
When there is an error like this, is there a way for android studio to automatically added the needed lines of code like eclipse would?
This is a common frustration. While not a perfect solution, I found https://stackoverflow.com/a/16616085/967131 to work for me.
For Windows/Linux, you can go to File -> Settings -> Editor -> General
-> Auto Import -> Java and make the following changes:
change "Insert imports on paste" dropdown value to "All"
check "Add unambiguous imports on the fly" option
On a Mac, do the same thing in Android Studio -> Preferences
That way, as you type, or when you copy and paste, many imports will be added automatically. Those that aren't are ambiguous; put the cursor on the class, press alt+enter and select which version of the class you meant.
For Windows/Linux, you can go to File -> Settings -> Editor -> General -> Auto Import -> Java and make the following changes:
change "Insert imports on paste" dropdown value to "All"
check "Add unambiguous imports on the fly" option
On a Mac, do the same thing in Android Studio -> Preferences

Resources