Alt L Shortcut For Mac In Android Studio
Android Studio menyertakan pintasan keyboard untuk berbagai tindakan umum. Tabel 1 menunjukkan pintasan keyboard default menurut sistem operasi. Perlu diingat, karena Android Studio didasarkan pada IntelliJ IDEA, Anda dapat menemukan pintasan tambahan di dokumentasi referensi keymap IntelliJ IDEA.
I’m searching for useful Android Studio keyboard shortcut for commenting code, as in Sublime Text or Eclipse.
When I press either cmd + /
or cmd + maj + /
nothing happens…
Line Comment hold both: Cmd + /
Block Comment hold all three: Cmd + Alt + /
Line Comment hold both: Cmd + + =
Block Comment hold all three: Cmd + Alt + + =
Line Comment hold both: Ctrl + /
Block Comment hold all three: Ctrl + Shift + /
Same way to remove the comment block.
In spanish keyboard without changing anything I can make a comment with the keys:
cmd + -
OR
cmd + alt + -
This works because in english keyboard / is located at the same place than – on a spanish keyboard
Be sure you use the slash (/) on right side of keyboard.
For Line Comment:
Ctrl + /
For Block Comment:
Ctrl + Shift + /
You can see all keymap in Android Studio: Help ➤ Default Keymap Reference
On Mac and Turkish Keyboard it is (both for commenting out and uncommenting)
line comment:
cmd +.
block comment:
cmd+alt +.
I use this sequence (not a ‘linear’ shortcut but useful anyway):
- alt+c then alt+b (holding alt) for block comment
- alt+c then alt+l (holding alt) for line comment
(they use the android studio menu)
for German Layout (Deutsches Layout) the default is:
for line Comment:
strg + Numpad(/)
for block Comment:
strg+shift+Numpad(/)
On PC it’s by default set to Ctrl + /. This will toggle commenting a selection or current line.
Reviewing and Changing Keyboard Shortcuts in Android Studio
Keyboard shortcuts can be configured (and reviewed) via the Settings dialog, accessible via File -> Settings
.
Once this dialog appears, to review (and/or add) a shortcut, do the following:
Select Keymap in the list on the left. Note that there is a “Keymaps” option, and depending on the original selection, shortcuts assigned to a given feature differ based on the Keymap.
Type “comment” or text corresponding to the feature for which the keyboard shortcut is to be reviewed/assigned. Each match has a line entry in the list below, and keyboard shortcuts are shown right-justified along with the feature. For example, both CTRL+ALT+SLASH and CTRL+K, CTRL+C are the two assignments for creating a line comment.
To modify a shortcut:
- Select the resultant line corresponding to the feature for which the keyboard shortcut is to be reviewed/assigned
- Right-click, and select the desired Add or Remove option.
I am working with a german keyboard and the slash (/) is on the 7 key, meaning access would be Ctrl + Shift + 7. However, this does not work as this is predefined as something with bookmark 7.
I went to settings (search for keymap) and deleted all existing shortcuts. I than added Ctrl + 7, confirmed deletion of bookmark shortcut and now can work well.
For multiline comment in android studio
select the statement that you want to commented then
use ctrl+shift+/
SINGLE LINE COMMENT
For single line comment
use ctrl+/
on mac, using uk english keyboard layout to reach quickcomment in android studio the key combination is:
cmd + alt(option) + /
For Line Comment hold both:
Ctrl + /
For Block Comment hold all three:
Ctrl + Shift + /
“Back in January 2018, Bang & Olufsen announced that Apple AirPlay 2, Apple’s next generation wireless multi-room audio system, will be integrated into 10 Bang & Olufsen and B&O PLAY multiroom speakers,” Mark Sparrow reports for Forbes.“Petros Belimpasakis, Director and Head of Sound Category and Platform in Bang & Olufsen said: ‘AirPlay 2 is a seamless way to enjoy music from your favourite Apple device and is a natural extension of how people live with music. “With AirPlay 2, Bang & Olufsen and B&O PLAY speakers also work alongside Apple’s HomePod, so B&O users can use Siri to play music around the house.”Sparrow reports, “AirPlay 2 will be available on both new and older Bang & Olufsen and B&O PLAY speakers as an over-the-air update during August and September 2018.”Read more in the full article.MacDailyNews Take: B&O users, rejoice (in August and September)! We are proud to be among the first companies to bring forward the experience of multiroom control in your Apple device and to deliver on the promise that our multiroom speakers connect with all streaming technologies,'” Sparrow reports. How to connect beoplay to mac.
Same way to remove the comment block.
Mac (French-Canadian Keyboard):
Line Comment hold both: Cmd + É
Block Comment hold all three: Cmd + Alt + É
“É” is on the same position as “?/” in english one.
In android studio you can do
single comment with (go to line then Ctrl+/)
and
block comment with ( select text then Ctrl+Shift+/)
Also if you want to change color of commented text
go to File->Settings->IDE settings->Editor->Color & fonts->Java->(Line comment or block comment)
and change properties.
I prefer it to be green which is used in notepad++ editor.
Are you sure you are using / and not ?
On Mac I have found by default:
- Cmd + /
Comments using // notation
- Cmd + Opt + /
Comments using /* */ notation
If you are used with Eclipse, there is something in Settings>Keymap Keymaps: and you can pick Eclipse to keep the same shortcuts.
In LINUX
1.Single line commenting. Ctrl + /
2.For block comment Ctrl + Shift + /
Tags: android
I have started developing with Android Studio. In eclipse I was using Ctrl+Shift+F but in Android studio it does not work, It will be different.
How can I jump to any method in .java
. I was using Ctrl+O in eclipse.
Is it available? Can any one tell me that shortcut for code formatting?
Win
Ctrl + Alt + L
Linux:
Ctrl + Shift + Alt + L
Mac:
Option + Command + L
Reference : Key Commands and here is full commands for Windows/ Linux users and for Mac users
Update for Ubuntu
As Rohit faced the problem in Ubuntu to format code shortcut, because the Ctrl + Alt + L key is used to lock the screen in Ubuntu.
I found that Ubuntu which handles the key event first. So try to change the Ctrl + Alt + L action in Ubuntu just to be sure.
Steps are :-
Go to System Tools -> System Settings -> Keyboard -> Shortcuts Tab -> System -> Lock Screen
Select the row New Accelerator..
will be visible then press any Special key with Alpha key (like Shift + L). You changed the key shortcuts.
Now check format key in Studio.
Alternatively
Ctrl + Alt + Shift + L (for a dialog)
Update came from Henry Chuang, and also in another answer given by user2340612.
You can also use Eclipse shortcuts. Windows and Linux, go to File > Settings > Keymap
, Mac OS X, go to > Preferences > Keymap
and choose Eclipse from the dropdown menu.
You can also use Eclipse’s keyboard shortcuts: just go on preferences->keymap and choose eclipse from the dropdown menu.
EDIT
The actual path is: File->Settings->(under IDE settings)->Keymap
(thanks to @Dhinakaran Thennarasu)
Check Keyboard Commands given in the Studio Tips & Trick documentation.
Just select the code and
on Windows do Ctrl + Alt + L
on Linux do Ctrl + Windows Key + Alt + L
on Mac do CMD + Alt + L
For formatting code on Android Studio on Linux you could instead use CTRL+ALT+SUPER+L. You could use this and avoid having to change the system shortcut. (SUPER key is the windows icon key besides the ALT key).
You will have to apply all ecplise shortcut with Android Studio before use of all those shortcut.
Procedure:
Steps:
Now you can use all ecplise shortcut in Android Studio.
Have some snapshots here.
for code formatting in Android Studio
CTRL + ALT + L (Win/ Linux)
OPTION + CMD + L (Mac)
user can also use Eclipse’s keyboard shortcuts: just go on Setting>>preferences->keymap and choose eclipse(or any one you like) from the dropdown menu.
Check this. Also you can change it as per your preference.
Just to add to @user2340612 answer to switch keymaps to eclipse, the path for Android Studio 1.0.1 is:
Ctrl+Alt+L might conflict with Lock Screen shortcut in Ubuntu. In such case you can change the keyboard shortcut for Reformatting Code as follows:
File-> Settings-> IDE Settings-> Keymap
Search for Reformat Code and change the keyboard shortcut.
Really, I went to this thread because of my Ubuntu locks screen after this shortcut Ctrl + Alt + L. So if you are have the same problem just go to the Settings – Keyboard – Shortcuts – System and change the default shortcut for the “Lock screen”.
For those who are wondering about the alignment issue inside bracket.
JetBrains has this as in their issue tracking.
here is the answer:
I think is clear that for code formatting in Android Studio the combination keys are:
CTRL + ALT + L (Win/ Linux)
OPTION + CMD + L (Mac)
However, we forgot to answer about the Jumping into the method.
Well to go into any declaration/implementation there three ways:
- Goto Declaration
CTRL + B or CTRL + CLICK (Win/ Linux)
CMD + B or CMD + CLICK (Mac)
- Goto Implementation
These commands show a list of all the classes/interfaces that are implementing the selected class/interface. On variables, it has the same effect as Goto Declaration.
CTRL + ALT + B (Win/ Linux)
CMD + ALT + B (Mac)
- Goto Type Declaration
These shortcuts will go into the declaration of the “AnyClass” class.
CTRL + SHIFT + B (Win/ Linux)
CTRL + SHIFT + B (Mac)
Additionally, there is a shortcut for Goto the Super Class. This will open the parent of the current symbol. Pretty much the opposite of Goto Implementation. For overridden methods, it will open its parent implementation.
CTRL + U (Win/ Linux)
CMD + U (Mac)
For Auto Formatting your Java/xml files in Android Studio use following commands:
As you are looking for a single point to go with your work as eclipse did, there is no such built in functionality in Android studio but it gives you the ability to do it through Macro, Follow these steps:
In studio open any of your source code file.
Press Ctrl + Alt + O This is used to find/optimize unused import.
If a dialog open select ‘Dont show it again’ and hit Run.
Go to Edit > Macros > Start Macro Recording.
Press Ctrl + Alt + O.
Press Ctrl + Alt + L. This formats your code. (Shift+ctrl+Alt+L for ubuntu).
Press Ctrl + S ,This saves your file;)
Go to Edit > Macros > Stop Macro Recording.
Save this created macro with name for instance:“Auto Formatting”.
Boom, You have now successfully created your Macro, Now just add/assign a
shortcut to it:
Open Preferences.
Search in the left bar for Keymap.
In the right hand pane, click in the search bar and type the name of your
saved macro(“Auto Formatting”.)
Double click on your item. There might be two, it doesn’t matter which one you click on.
Click Add Keyboard Shortcut.
Set your keyboard shortcut to Ctrl + S.
Finally,Confirm overriding Ctrl + S to be your new macro.
The shortcut that worked for me is
SHIFT+ALT+CMD+L
You can optimize imports to remove the ones you don’t use, and auto import the new classes.
Try this.
- On Windows do Ctrl + Alt + L
- On Linux do Ctrl + Shift + Alt + L for dialog to open and then reformat.
- On Mac do CMD + Alt + L
Note: Here many answers for Linux is just Ctrl + Alt + L
which is wrong. In Linux, doing Ctrl + Alt + L locks the system.
It’s CTRL + ALT + L
for Windows.
For a complete list of keyboard shortcuts please take a look at the user manual: https://developer.android.com/studio/intro/keyboard-shortcuts.html
Best key where you can find all commands in Eclipse is CTRL+SHIFT+L
by pressing this you can get all the commands in Eclipse.
One important is CTRL+Shift+O to import and un import useless imports.
Tags: android