Using Multiple Cursors0:00
Next up, we have multiple cursors. So imagine for these three methods, we actually want the visibility to be set to protected. Well, yes, you can do it one at a time, but there's no need. Instead, this is a good use case for multiple cursors. So we can do this in a handful of ways. One, we can click anywhere on the mouse, hold down Alt, and then click on each occurrence. Now you'll see we have three different cursors where I can change that to protected. Okay, so that would be the mouse-specific way. I'm going to hit Ctrl + Z to undo a few clicks though. Another option is to use Command + D. And by the way, this is the same shortcut that you would see in Sublime for its multiple cursor support. So if I hit Command + D, it'll select the next occurrence it finds. So let's do it one more time, and now we have exactly what we had before. Finally, sometimes you want to change all occurrences at once. For this,
Selecting All Occurrences2:08
rename the variable in every location, and you can probably find a package to do it here, but sometimes it's a little inconsistent and not as good as an IDE's implementation. But nonetheless, let's assume we're accepting a variable like Baz, and then we do something with Baz, like so. Yeah, in these situations, if I want to change the variable, I will always use command-d. Or maybe your teacher assigns you write-offs. Jeffrey will not call Paul a buttface, and she makes you do it 50 times. I'll hit shift-option-down to duplicate the line. There we go. But then your friend Kyle gets in trouble for doing the same thing. All right, I'll select my name, control-command-g, Kyle, and he called Brandon a buttface, which he is. Well, now Kyle is done with this work in 10 seconds. You get the idea. In the next episode, we'll move on to something else.
