![]() ![]() Maybe you have some spaces right here like that. Maybe I have a JavaScript object like this and we'll say, name equals Jeff, age is 27. Just hit Ctrl+J a handful of times to automatically bring that up, which is much quicker than probably having to scroll down, then hit the Backspace until you get it to where you want. Now what's cool about this is if this happens to be on a much lower line, it's the same thing. Well, all I have to do is place my cursor where I want the next lines to be joined and then press Ctrl+J and now those have moved up. So then at this point, you wanna join these together. And then maybe here, you have some more Lorem. So I will past in some Lorem text right here. A more common application might be that you have some text. But it's still an option and it gets you into the idea of thinking about how you can use joins better. So clearly, this would only be advantageous if you have big arrays. ![]() ![]() Selected the whole thing, wrap it within an array and then get rid of that closing comma. Add a comma at the end, Ctrl+J to join them together. I'm gonna select all of them Shift+ Cmd+L surrounds them with a single quote. So another way I might do this is I would create the array and then I would do one, two, three, four, five, six, seven, eight, nine, ten. I've actually gotten to a point where I can do it fairly quickly. But actually, you may find keyword may, that this can be faster. So granted, that seemed like a lot of steps. Select the entire line, wrap it within an array and then create our variable, like so. Then at this point, I can remove the final comma. And now I can escape out of the multiple cursors. Next, we will hit Ctrl+J and that's going to join the lines together. Then I'm going to move to the end of the line by pressing Cmd or Ctrl+right and we'll add a comma in. I'm gonna wrap the selected text on each line with a single quote just by pressing single quote. I will select all of them, then press Shift+Cmd+L to create multiple cursors. Here's another way that you might do it using joins, you would put each of them on their own line. It's not too bad, but it's still a pain in the button. Normally, you would say var arr for array and then you would have to do a tedious process where you add all of these with end quotes, like so. I will create a new file for this, script.js. Maybe you're creating a JavaScript array. So if you're thinking, I'm not sure when I would use joins, there are actually a handful of clever ways that you could. I press Ctrl+J and now it has joined them together. And now if I try it again, I've selected these items. ![]() We will get rid of the comma, because we only have one object in this array. Then when I press Ctrl+J, that's going to trigger the command, join_lines. Within here, we have an object with a key for keys and then we setup what we want. Switch back into my user settings, which will not be modified. Because when the editor is updated, those will be overwritten. So rather than changing it here, remember, try not to edit the default settings. And yep, it is set to super+j, but something must be overriding it. And this will present me with all of the various key bindings that are automatically assigns by the editor. I'm gonna go to Sublime > Preferences > Key Bindings Default. So I need to figure out a new key binding for that. But there is one when you first install it and that's Cmd or Ctrl+J. For example, if I go to Edit > Line > Join Lines, you'll notice that there is no shortcut assigned. Sometimes, you'll find that the plugins you install override existing shortcuts. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |