hey guys what's happening my name is cal and in today's video i'm going to be sharing with you
10 of my favourite android studio shortcuts these are shortcuts that i personally use and they've
sort of slowly been integrated into my workflow over the last few years and they're pretty much
shortcuts i couldn't live without now hopefully there's some shortcuts in here that you're not
using that you could maybe after watching this video start using to make your workflow a bit
faster and a bit more efficient and just overall make you a better android studio developer
cool so the first android studio shortcut i want to share with you guys is duplicate current line
command d on a mac or control d on windows so say you're creating a simple class in java so you've
got an id name and created and then you want to have a few more date fields well you could
just hit command d or control d and duplicate that current line a few more times and change
the text to whatever you like the second android studio shortcut is basically the
opposite it's delete whatever current line you're on command delete if you're on a mac and control y
if you're on windows all it does is removes the current line rather than have to hit backspace
a bunch of times you're just going to remove the complete current line and next up we have generate
code or generate constructors and getters and setters so it's command n on a mac or alt insert
if you're on windows and if you've followed along with any of my previous android studio tutorials
you'll have most likely see me generate some code of some description so here i'm just generating
a constructor so command n or alt insert and i'm going to generate some getters and setters
i believe if you have a good understanding of the code you're generating there's absolutely no harm
in generating a code in fact i think it will save you a lot of time next up we have neatly format
code or reformat code and on a mac it's command option l and on windows it's ctrl alt l sometimes
when you know you copy and paste from somewhere else it just doesn't all quite line up correctly
well if you hit command option l or control alt l it's just going to reformat everything back to
what you've defined in your preferences and if like me you like to have your curly brackets on
the next line if you head into preferences editor code style java wrapping and braces
braces placement next line for each one of those and if we reformat our code once again now that
we've made those changes in the preferences you can see that it's put each curly bracket
on a new line which has made my little ocd brain quite happy and content the next android studio
shortcut is also a bit of a neatening one it's optimize imports control option o on a mac and
control alt o on windows basically all this does is if you add in a few extra import statements
and then you remove the things that use those imports we organize our imports and it removes
all of the import statements so that the only ones that are left in the file are the ones
that are used moving on our next shortcut is find class or open class and it's command o
on a mac or control n on windows say you want to move to a different class you can just search
for it and then open it up so in this example i've just searched for my main activity and i've opened
it up this is a really useful shortcut if you're working on a bigger project and all your different
files are nested in a bunch of different folders and you know that that class exists so rather than
searching for it the old-fashioned way looking through the files you just got to search for it by
the text next up we have go to declaration and i don't know this is a bit of a stretch that whether
this is even a shortcut but it's a huge time saver and one of my favorite ones so it's just command
click or control click basically say you've declared a object and we're going to declare
our android shortcuts object and just giving it some dummy data because it doesn't really matter
and then if you hold down command or control and hover over the method you can actually see
the little mouse is changed to pointer finger and then if you click on it you go to the declaration
of the method and you can so say if it's a really basic method and you just want to see what it does
you can quickly pop in have a look at what the method does and then head back to where you were
next up we have go to line and on a mac it's command l and windows it's ctrl g not a super
useful shortcut if you're working on a lot of solo projects but if you're working together
as part of a team it's a really great one you can just tell your mate hey have a look at this file
line 51 and you can just quickly pop there and have a look next up we have find and file and i'd
be surprised if anyone's watching this and they don't already know this shortcut but i figure it's
worth mentioning just in case someone doesn't use command f it's one of the most useful shortcuts
well in anything you do on a computer really hit command f or control f and search for anything
in the file it's really useful i mean use it on your web browser use it in android studio use it
in everything and finally following up from that we have command shift f or control shift f which
is find in project it does exactly the same thing as command f or control f except instead of just
looking in the file that you're currently in it's looking throughout your entire android
studio project this is a particularly useful shortcut i find when you're refactoring your codes
so there you have it 10 pretty useful shortcuts in android studio if there's any that i missed or
you thought you know that one wasn't a very good shortcut or you know i missed any important ones
do leave a comment below and i'll be sure to check it out that was it if you like this different sort
of style of video consider giving a like but yeah i'll catch you guys in the next video or tutorial
you