تماشای این درس نیاز به اشتراک حرفه‌ای دارد.

Installing Advanced New File0:00

One thing that initially annoyed me about Sublime was that creating files was just a little annoying. So for example, maybe you want a new controller. Well, you'd right-click, hit New Controller, create the controller, Command-S, and then save it as foo-controller.php. So yeah, it's not terrible, but you do it enough, it needs to be a very streamlined process. So instead, I will delete that, and we're going to tackle this a different way. I'm going to pull in a package here. So Package Control, Install, and I want Advanced New File here. Let's pull that in. Now, sometimes you pull in a package and it doesn't really give you much information for

Creating Files by Path1:01

So if I hit Super, Alt, N, that creates an Advanced New File prompt. Let's try it. Command, Alt, or Option, N, and now you'll see this little panel at the bottom. So we can type out the full path. And what's cool is we have tab completion here. So I can type H, Tab, and it fills in the rest. foo-controller.php, and now we're done. And as soon as I save it, you can see it show up here. At least for me, that's a far more streamlined way to go about it. But now, what about when I want to add a new controller in this same directory?

At least for me, that's a far more streamlined way to go about it. But now, what about when I want to add a new controller in this same directory? I'd rather not have to do this whole thing. That would definitely get old, right? It would be nice if I could just say another controller, and it would default to the current directory. But the thing is, I don't always want to do that. Sometimes I do want to start from the project root. Okay, so how do we do that? Well, as it turns out, there's an alias we can use for this purpose.

Using Current Directory Alias1:49

Okay, so how do we do that? Well, as it turns out, there's an alias we can use for this purpose. So if I'm in a current directory, in this case, controllers, if I create a new file with Command-Option-N, I can start with a colon, and that's just the predefined alias that points to the current directory. So I could then say :newcontroller.php, and it will show up here. Pretty nifty. Now actually, this package has a ton of configuration, and we won't go over all of that. But if we view the default settings, well, right off the bat, we can see that we can set aliases.

Deleting and Renaming Files2:43

Well, yes, if you have this sidebar open, like I generally don't, you could right-click and hit Rename File and do it like that. But again, it just sort of adds up. Instead, Advanced New File offers that feature. So if I hit Shift-Command-P and look for Advanced New File, again, remember, we have fuzzy searching here. All right, we can create a file. We can delete the file. That's useful. So I could say Shift-Command-P Delete Current File, and that immediately removes it.

That's useful. So I could say Shift-Command-P Delete Current File, and that immediately removes it. Pretty useful. But let's bring that back. So app/Http/Controllers/foo-controller, like so. In our case, though, I want to rename the file. OK, but if I were to change this to bar-controller.php, well, it doesn't retain the current directory. It again defaults back to the project root. So yeah, I don't necessarily want that. What's the solution?

So yeah, I don't necessarily want that. What's the solution? Well, once again, we can use a colon, or we can configure this. For example, one more time, let's create it, foo-controller. And if I now do Shift-Command-P, rename, and I start with a colon, it will once again adopt the current directory. So we could say another controller.php, and it will stay the same. Or you could do this. If we visit Package Settings right here, notice this section, Rename Default. So when we are renaming a file, what should the default value be?

Configuring Rename Defaults3:58

If we visit Package Settings right here, notice this section, Rename Default. So when we are renaming a file, what should the default value be? Why don't we copy that, and let's go into our user-specific settings, and I'm going to paste this in here. OK, so notice we can use these special values. Like if I say File Name, and let's try it. I'll hit Command-P and switch back. Now actually, a quick note on this. If we quickly do another controller, whatever. When you want to switch back between two files, you can hit Command-P, and by default, the

If we quickly do another controller, whatever. When you want to switch back between two files, you can hit Command-P, and by default, the first option will be the last file you visited. So what this means is, you can hit Command-P, Enter, and constantly switch back between the two most recent files. And you'll see me do this at LayerCasts all the time. It's a good little tip. OK, but anyways, if we try to rename this file, you'll now see that it defaults to the current name. If we were to change this to File Path, well that will be the entire path.

current name. If we were to change this to File Path, well that will be the entire path. Rename, and there you go. Or, if we want to use the file directory, it'll do the full path minus the name of the file. All right. Rename, and now we can change it. And this is useful if it does need to go to a different directory, and you want that option. In our case, I'd be fine leaving it off completely, to be honest. Or maybe File Path.

دوست دارید گاهی خبرهای Laracasts را ایمیل کنیم؟