Unlimited Plugins, WordPress themes, videos & courses! Unlimited asset downloads! From $16.50/m
by
Lessons:28Length:1.7 hours
Speedy workflows with atom.io
  • Overview
  • Transcript

3.3 Multiple Selectors and Incremental Search

A lot of times while developing, we need to rename things. And to do this, we usually highlight one of the places we need to change it, and then we'll type in the new name. So rather than naming this Person, we're going to call it Human. Then we'll go and highlight Human and we usually paste over every single place we can find it in. And sometimes this works, but it takes a little bit of time to do and it becomes pretty error prone because one of the places I forgot is this Person inside of the string. So there definitely is a better way of doing this. We'll go and revert our changes, and now what we can do is, since we have the person highlighted, we can hit Cmd+D. And every time I hit Cmd+D, it starts highlighting every single Person. And we can type Human now, and we can see, as we typed it, it updated in every single place we had it selected, and the process of finding every single one of these instances is called incremental search. And to initiate that you usually highlight over it or you can just have your mouse over it. And every time you hit control d it'll find the next incidence. Using Cmd+D works really well when we only have a few instances and when we only want to find a partial amount of them. However when the file is much bigger we probably want to do an entire select. And to do that we can hit Ctrl+Cmd+G, and as we hit Ctrl+Cmd+G, we selected the rest of them. So every time you know you want to select them all in one file, you can hit Ctrl+Cmd+G. But if you just need to hit them one at a time you can do Ctrl+D. And that's really all there is to do for incremental search. Another thing we can look at is the idea of having multiple cursors. And just like incremental search, these are all features that are in sublime text. However, setting up multiple cursors can be a little tricky on a Mac. The way you do incremental search is you you type Cmd+Shift and then up. But as we do Cmd+Shift+up, we can see that we get this crazy view, and this is the mission control. So I'll put this back down and, so how are we going to do multiple cursors. Well, we can go up into the menu and we can hit selection, and we hit add selections above, we can see that we have our two cursors. But to do this every single time is really painful. So the way we'd fix this is by changing the key binding on the Mac. So to change this we'll go into the keyboard section and we can click on Shortcuts and then right here we see Mission Control. We can unselect Mission Control and then we also want to unselect Application Windows. Now back in adding, if we want to select all the space in between these list items to add some filler text, we hit Ctrl+Shift+down. Now we can just type in whatever we want. And the same will work as well if we want to go up, CmD+Shift+up. So every time you see that you need to change text in the same columns using multiple cursors is one of the best ways to go about it. Using incremental search and multiple selectors are really good ways of handling these tedious tasks in our development. But these solutions are only good for a text that already exists on the page. It'd be really cool if we could type in some code that activates boiler plate code for us and then when we combine that with multiple cursors, we can do a lot at once. And this concept is known as using a snippet. So in the next lesson, we'll look into snippets and see how they can increase our workflow.

Back to the top