What we want to do though, is we want to skip this second instance. Command > D again, and we get a cursor down below, and I hit the arrow key there so we lost it. So if I come here and select this and say Command > D, it puts a cursor there. You can use Command > D to add one cursor at a time. So we wanna change the first one, we wanna leave the second one the same, and we wanna change the third one. So what we really wanna do here is we wanna change two of them, but not one of them. One of these things is a variable name, and the other one is a reference to an element in the HTML. Now, if you're paying close attention though, you'd notice that what I just did would break the application. And I have changed all three of those instances at one time. I now have a cursor on all of these instances, and I can hit backspace, and then I can type lampColor. I can add a cursor to every single one of these instances with Command > Shift > L. And it's highlighted the colorInput that is down below in the goButton.addEventListener method. It's highlighted the colorInput in document, getElementById. And now you can see it's highlighted, and you can't see it on the projector but it's highlighted the colorInput. So let's say that we wanted to rename this or change this value, this colorInput value to something else. If I put my cursor on colorInput, notice that DS code is highlighting other instances of colorInput here. ![]() So for instance here in this file, I'm gonna decrease the font size here so we can get more text on the screen. Once you understand how to use them, you'll start to find places to use them. And so what I wanna show you is some cases in which you would use multiple cursors. Like it's a cool technology, but when do I actually use it? It's kind of like artificial intelligence. Now, multiple cursors are very powerful, but a lot of people have trouble understanding when I should actually use one. > Burke Holland: Another concept that's become very popular in editors over the past few years is the concept of multiple cursors. Transcript from the "Regex Find & Multiple Cursors" Lesson
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |