12 Shortcuts That Will Make You A Better Programmer

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello and welcome to this video on programming shortcuts in this video I'm gonna show you 12 of my top programming shortcuts that will make you look like a god and also save you some time first my name is Alex on this channel I post a Java tutorial just like this one every single week so if you might be interested in seeing that then please consider subscribing if you're like me and you like to improve yourself and keep learning with the time you have and I've got this great product I want to make you aware of it's called audible they make audio content like audio books podcasts and meditation I've used it for an audio book called how to build a billion dollar app and also a Y Combinator startup series which helps startups get off the ground audible gives you access to thousands of titles and it's something I personally use all the time visit audible trial Comics Li to get started on your free trial and get a free audio book that could be one of the ones I just mentioned again that's audible trial com this get started with these shortcuts by going to file new job project I'm just kind of call it shortcuts you finish and then inside here we'll just make a dummy class I'm just gonna call it main for now we're the main method and hit finish this will be a mix of regular shortcuts and Eclipse shortcuts Eclipse shortcuts are specific to this development environment but if you have a different one or IntelliJ they might work with that as well let's get started so the first one that I use the most is going to be cut so you have a line of code that you print out then you have another one one two three save and run but I decide I want to put ABC after so what I'll do is on Mac you would do command X like this or on Windows you would do ctrl X and then go to the one you want boom I put it after run it and now it's how I want it that's most of the time what I'll use the cut shortcut for is just cutting code and putting it after or before on a different line next is copy so see how before I print it out the whole thing system dot out dot print fine system that adds a print line it's really annoying so what I could have done instead is just dude control-c or command-c go to the next line and then paste it control-v or command-v so that's to copy and paste and then just change the one I want and I know you may be familiar with most of this but I want to show you how useful these shortcuts are specifically for programming because they are super useful so we have cut which is command or control X which lets us move things around we have copy control or command C which lets us copy without deleting that line and paste it as many times as we want and that was paste ctrl or command V so we got those three down and those are the top three I'd say shortcuts for programming that I use next this is one I use a lot most people don't do this but I do all the times the save shortcut so when you change something this little Save icon floppy disk is up here and there's a little star that means your file isn't saved yet so we could click it save the star goes away and the program can be run so when we run it now we have no problems and it's updated instead of every time I want to save it I have to scroll my mouse all the way up here click and then run what I can do is actually do ctrl or command s and now the star goes away and we can run it like normal because we already saved it just by clicking a few keys on the keyboard instead of going all the way up here all the time this is useful because you want to save very often when you're programming so you don't lose anything like something simple like this I just deleted a line and do ctrl or command s to save it so it's updated next we've got select all which is super useful for making new files or transferring entire pieces of code so say I want to duplicate this file what I could do he's go to new class call it main - and if I want to take all the contents in here into here I could highlight all of it copy and then paste into here and then just fix the error I could do that or if this was really really long imagine having to physically move your mouse all the way down to line 1049 and then scrolling all the way up moving your mouse to like the very top so that the scroll comes out waiting until the very top it can be kind of annoying so like big pieces of code like this if you want to grab everything you do ctrl or command a like this this highlights everything in the window and then now since it's all highlighted that you can do is you can cut it or most of the time you'll just copy it and then command a here and then now we can paste it in this is what happens when we paste it but notice we don't want two of them we kind of want to replace the whole thing so what we can do is control a or command a this whole thing delete it and then paste the new code in and make our change so commander control a lets you highlight the whole thing to which you can delete or copy or cut because it's highlighted I'll just delete this now now let's go to the next one which is called find in replace so say for whatever reason this was one two three one two three I just copied and pasted and now saved it and ran it let's say this was one two two for example instead of having to go through a long list of things and see is that - is that a - there yeah what we can do is command or control F which will bring up this little window called find and replace so in here we can type what we want to find we can find one two two click find and then it'll go through the whole thing and find what you typed in if we typed in twelve here it sees three twelves and goes through one by one and the cool thing about the is that we can actually replace those twelve with something else so say we wanted to replace one two with three three or can be a character it can be anything so they want to do - a 1 or whatever it we can click replace to get the highlighted one replaced like that or we can do replace all which will go ahead and replace all of them I usually do one at a time because if you have a bunch of code and you do replace all it might accidentally replace some that you didn't intend to that's fine in a place that is super useful now say I want to get rid of this - a because it looks kind of bad what we can do is copy that put that and find and then replace that with nothing so we can do replace all and then it kind of deletes it the next shortcut is comments say we didn't want to run the first two lines of code what we could do is highlight them and then do command or control forward slash this will turn these lines of codes into comments which means this code won't get run so I'm just going to save it with the save shortcut run it and now we see only this line is printed because these are now comments which means they don't get run to uncomment them we can do that same shortcut by highlighting them and doing command or control or it slash again and now these pieces of code will get run you can do this for individual lines so you don't have to highlight them I use this shortcut all the time I bet every day I use this shortcut because it's so easy if I have a whole block of code that I actually don't want to run because I want to focus on another part and see how that's working I can just comment that code and focus on what I'm looking at next shortcut is tab so say we have like an if statement I'm just going to put a simple if statement here cut this and put it in here but say we cut and put it in here but the formatting was kind of wonky like this notice how what's inside of curly braces in Java gets formatted so that there is a little tab here it's tabbed in to make it more readable well this right here looks kind of messy so I want to tab in all of these so that it looks better since that was only three I could go one line at a time and tab them in but say if they were all kind of messed up what I can do is highlight all of them and just press tab to tab in all that line of code to make the blocks more organized and then a bonus one you can also do shifts tab to bring them back out now we'll just delete all this the next shortcut is a really fun one in something I didn't realize till about a few months ago you know how you type system dot out dot print line all the time you type this all the time well in Eclipse I don't know if this is similar for IntelliJ but you can do this out and then control space and that will autofill system dot out dot print line except you only have to type six characters which is really nice that's a good one I do that all the time in my videos so if you ever see that that's what I'm doing I'm gonna open back up main two for a second and I'll just copy these lines over using controller command C paste them ctrl or command V save it now I'm going to show you a way to search across multiple files with controller command F we can search through one file if we hit find it'll show that 12 in here but not the 12 also in main - so what we can do to search across multiple files is do the shortcut ctrl H it's not command H because this is an eclipse specific shortcut so we can search for the string 12 in here you could use regular expressions but we're just going to do a simple one we're going to go on over to the file search tab and type 1 2 in here and this is going to go through all the files that have the filename pattern here so that Java is what it's filled with hit search and now it shows everywhere inside of the all these project we're one to is so it even shows in my Java tutorials projects under the GUI to Java file I have one to found in there and it also shows main and main - so ctrl H for Eclipse under file search we'll go through all those files instead of just one another super awesome one is formatting again so before we could like tab in to make it all nice and stuff let's say we have that if statement again but say it's kind of like the parentheses are weird for some reason and these are off and this I'm just going to cut and paste this in here say maybe like the formatting is very weird like this what you can do to format this entire file without having to go in manually is do command shift F that formats the entire file for you in the blocks and structure that it was intended to be really awesome I love this except it comes down to kind of personal preference like I personally don't put the extra space here so I like to keep that there and sometimes it might not format exactly how you want but this is a really quick way command shift F to just format the whole file and that's a really cool one last programming shortcut I'm going to show you is the opening a method shortcut this thing we've got this class main let's make a method in here so that we can actually use this shortcut it'll be public so that we can see it void we don't need static because we're gonna call it a different way say hi I love to say hi method man this isn't a lot of my videos we're just going to print out we can print out using sysout control space boom and we'll just say hi save run nothing happens because nothing's in the main method but say we want to say say hi in main to what we can do is just make that main object main just call it something M is equal to a new main object it's like this this main class knows a main method which we can ignore because that just runs code and it knows say hi so this M object now since its main knows say hi so we can do m dot say hi like this if we save and run and main to then we see how I printed out what if there's a bug here or say hi isn't working how I expected and I want to look at the code what I can do is control or commands hover over the method name and then click it this shoots you back to where the code is implemented for that method and it's super awesome I use this all the time it's so useful imagine having to like go to the main class like searching and then scrolling through all the methods you can just control or commands hover and click it and I'll show you right there I use that all the time bonus tip you can also control or command hover over other things so like this class here you can click the class and it'll show you back up there this is how I use regular shortcuts and Eclipse shortcuts put together to make my programming a little easier and also just look really cool doing it and if some of them are basic like cut copy paste but I wanted to show you how I use them as a programmer so I hope you liked this video I'll see you in the next video have a great day [Music]
Info
Channel: Alex Lee
Views: 36,965
Rating: 4.6945372 out of 5
Keywords: programmer, programmer shortcuts, better programmer, programming, be a better programmer, programming shortcuts, keyboard shortcuts, programmers, shortcuts, java shortcuts, eclipse shortcuts, code shortcuts, coding shortcuts
Id: zGFko8iL-ho
Channel Id: undefined
Length: 15min 6sec (906 seconds)
Published: Tue Apr 07 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.