better alternative This is a topic that many people are looking for. bluevelvetrestaurant.com is a channel providing useful information about learning, life, digital marketing and online courses …. it will help you have an overview and solid multi-faceted knowledge . Today, bluevelvetrestaurant.com would like to introduce to you Vim: Is Netrw A Better Alternative To NerdTree. Following along are instructions in the video below:
“Ever since i ve been using them as my main code editor. I ve been been using a plugin called nerd tree for my file explorer and it turns out don t actually need node tree. Because there s a plugin for this actually built into vim so today we re going to take a look at net true and see what i m actually doing with it so if you new to the channel. You know what to do it let s jump right into it so pretty much every vim user has probably come across metro.
At some point. Even if they didn t realize what it was so let s just switch over to my mains here. And i ll show you what i mean so there s going to be times. Where you ve accidentally opened up a folder within a vin buffer so let s just see what that actually looks like now.
It s gonna look slightly different from what it would normally look like just because when i open up a vim buffer. I also have an extranet reopen. But you would have seen something like this so come over here show you this again so you d see this banner at the top and a list of all your folders. So this is actually net true.
So what net real lets you do is actually open up a folder within a vim buff. But then you can do various things like you can i don t know say cycled through these different view styles here you can do other things like i ve got them listed up on a thing right here. So that s why i keep popping over that so i don t usually use most of the file manager ii things. But you can also do things like you can delete a directory or delete a file so if we try to delete something in here like let s say just press delete on that it will give me a prompt on that so do i want to delete it no i don t so you can do things like show and hide hidden files.
This director doesn t actually have any hidden files in it so. It s not gonna really do much. But let s just quit out of this and bring up just my home directory. So bring up it s not gonna work let s see if it that worked yes.
It did okay so we go down to like my zsh files and all that zsh and we press. The gh and then that will actually hide all those hidden files and bring them back with gh. Again you could also do things like changing the style of sort. So this is sorted by time sorted by size sorted by extension and sort of my name so that s done with the s key.
You know i ll just bring up screen key you know why didn t i think of doing that before i m not even really sure why i didn t do that anyway. So you press s. And you can actually change the sorting style and if you press r. Then you can do a reverse sort so that works as you would expect for basically sorting nothing too special there pretty much and the one last thing.
I want to mention for this is you can do renames as well so if you want to change this it s going to use the move command. So rename and move emerged into one thing like they are just on your regular linux system. So if you want to do a rename and a move at the same time then you can do that now i as i said don t typically use the file manager ii things and i m not going to go into any more of them i will leave a link to all of the key bindings down below. So if you want to check them out for yourself go right ahead.
I typically just use as a way to explore my file tree. I ll typically just use lf to modify my filesystem that s just the workflow that i ve got myself used to so. Let s just have a look at my vim rc and basically have a look at what i m doing because i m not just running net true with this default settings. I ve made a couple of changes to it so the first setting we have in here is net true underscore banner equals zero.
So basically all that does is it just disables this banner over here. So i don t need it so i just hide. It there s no point showing. It i m just gonna hide it anyway because just it s a waste of space.
I don t really see any point in showing it at all then the next one is the actual list style so if we press..
I i don t know if i showed this before i might have i just forgot about it it was like 20 seconds ago. But you can actually change the style of this list. So i ve just got it set to 3. Which is this sort of tree style.
So if we press enter on one of these that ll actually bring it up in here like this rather than if you have it set to one of the other styles. Then you actually be jumping directly into that directory. I m not a big fan of that style. So yeah you can get a rough idea of how that works like that i prefer the tree style use makes it a bit easier to see everything that s going on at once.
That s kind of just the way i like working with it though because it s similar to the way that nerd tree works. So you ll see that a lot of the stuff that i do is to kind of make that true function like a node tree for the things that i care about now as for this browse split like homebrew exactly what this does. But this will give you an example of how you can use the vim documentation to search for stuff for any of your plugins. So let s just try that so help or you could write out a chi and then go netru.
Underscore non other school yes. It is on the school. I can t read apparently. Underscore split okay so type that in and this will bring up the actual vim documentation.
So the other way to get to this is by pressing the f1 key that s bound within that true but for any of other plugins you can just write in help and then whatever thing you want to search for for that plug in or not even just plugins also just for mainline vim stuff. So it seems like this will make it so. When i open up. A new file with a net true instead of opening up in a split.
It s going to replace this previous window in here. So i ll just show you what that looks like in a separate bin buffer so open up that let s just go down to say my zs8 chassis or anything in here. Really so i press enter on this and you had a couple of options like opening up and splits. But i just like it to replace what s in here if i want to do splits.
I m gonna do splits in my own way i don t really like the way that natura handles them. And you ll see my absolute hacks to get splits working nicely like i did in nerd tree. They don t work perfectly. But you ll see that one get to it so if i press enter on here.
You ll see that for some reason. That s not playing nicely with things like symlinks. I m not sure why symlinks aren t playing nicely right now. It might be something i did um.
It might be a net true thing. I can t remember i ll try to work that out but we open up something that i know works likes its angular config. Okay is there even anything in that file gosh history. Yeah there we go there s something actually has stuff in it so all it does it actually replaces this so say we open up this.
There s a fly in my room. So we open up this dot. Doing our see what it s going to do this. Time is just replace.
What s in this window over here as well so that just works like you expected..
It replaces the window. Most of the time. I use that but occasionally i do want splits. So let s just have a look at how those works.
Because that actually the next thing. We ve got in here now by default what naturally we ll try to do is it will split from its current window. Because it doesn t do any special handling for it we ll just treat. This as an extra split within vim now.
I don t like that the problem that you get there is that if you try to split this 20 window here. What it s going to do is you re gonna have this tiny sliver for your net true window in this tiny sliver for your other window. And i know that you can expand them that s that s too much hassle. Oh.
What i m gonna do instead is just write an absolute hack to make it work the way that i want it to work. So. Here s how that works. So basically what i do first off.
I ll open up a vertical split using the netru method. It doesn t matter if it s a vertical split or a horizontal split because we re not going to use it so once that s opened. Then i ll be focused on that file because once you open up something from net true you lose focus on nature and you take focus to whatever you ve opened now. What i do there is actually get the path of the new opened file.
And i ll save that in a variable then i quit out of that new window. Because what it s going to do is it s going to try to split the natural window. And i don t want that once i then close that new split it then puts me back on focus on my main window right then we ll open up a split using the normal vim method and jump over that one and you know what that works perfectly so that s what i ve been doing pretty much since i started using this because it just it s so much nicer than the way that natura handles. It by default.
I know you can play around with the netru settings. But i really like this hack way more so say i want to open up. Say. This bash history in a split.
I can just press capital v. On this and bam. We have a split or if i wanted a horizontal flip. I can do the same thing.
I can press h capital h. And that opens up a horizontal split the horizontal split the way that works normally in metro. Is it will put a horizontal split in this window. Here.
So you ve got this really small one and as i was saying before i know you can resize windows that s a hassle. I just want to do it like this where it s gonna work perfectly. I don t want to really think about it so that s why i do it like this and not really any other method. So next up.
I just have a function for my net true mappings that i ve changed so it obviously got those new ones that i ve added so i ve got one for toggling net true..
I haven t actually mentioned this one yet. But basically what this is going to do is it s going to run this function down here. So by default you can t actually toggle metru. What it s going to do every time you try to run the net true function or the net true command whatever.
It s called is it s gonna open up. A new window of net true this function right here is basically gonna check if nature is open and if it s open it s going to close it it s closed. It s gonna open it i didn t write this function myself. I have no idea what half this stuff does but i found it on stack overflow and stack overflow is a great website.
So that s why i use this so i would recommend using this if you want to have toggleable netru you could write it yourself. But this is just much easier because yes you can as i ve said it is just a normal vim split. So you can quit out of it normally that s a hassle. Though and you don t want to do that so.
Yeah. We ve got control f to open and close that basically occasionally. I ve noticed that it will break on some things i m not really sure what s causing it to break. I need a look into that as well.
But it will actually open and close it so it still works. I don t actually know what s doing that so i ll definitely look into that the other ones. We have in here are for opening a split to the right and opening a split below and this last one in here is a little bit of a hack to fix a problem. The netru has so i don t know if it s just my bindings or what s going on so if i just show you what it looks like without that fix on there just open up a new vm buffer and let s say we want to open up.
I don t know just anything in here. Like this dot doing rc. So if i open that up then so we come back over here. If we then press control l.
It s gonna bring up the net true buffer instead of letting me jump back to the file like it s supposed to i don t really like that it does that i m not really sure what it s supposed to be doing either. I thought it would be about like diving into a folder but if we press ctrl l. On say the dock cache folder for example it doesn t dive into it it just goes over to another net true buffer. So i don t really know what the purpose of this binding is it might just be playing weirdly or it might just be bound weirdly within net true.
However. I don t actually care because. I just get rid of the binding. So i just basically remap it to ctrl w.
And then else so if you don t know that s just the way you jump to a split to the right with the default via bindings basically. Now this next. One in here. Is just to actually make sure that those net true mappings are run on every single file type nothing too special there we went over toggle natura already so i m not going to go back into that one and then this next one in here.
This is another one that i didn t come up with myself basically what this will do is i ll just show. You actually. It s way easy there show you so if we open up a vm buffer and we close our main window. And there s no other windows left.
Besides the netru window basically all it s going to do is just quit out of them i had it configured like this within node tree as well when i quit out of a file that s when i want to put out a file..
I don t want to keep seeing my file tree. I know some people use natural a bit differently than i do but for me i am just using it as a file explorer while i m coding and i use vim for other stuff besides coding as well sometimes i ll just have one file open and because i m just opening up that netra window as soon as i launch them i don t want it to be there for things where i m only just working on one file basically and on that note to make net true actually open up as soon as i open up my vim buffer. All i m doing is this order command right here so auto command vim enter on any file type. I m calling toggle net true so all that s going to do is regardless of the type of file.
I open up. I should probably make that sort of just the sort of files. Where i program on because those are your only files wherever actually care about my file tree so if i m doing say like a a markdown file. I typically don t care about having net through this so i might make it so it s just the code files.
I work on end like the light x stuff. And things like that but for now. It s just gonna open up on everything and then the last thing. We have in here is just to make sure that net row is open variables actually defined because if you remove this line.
It s not going to work properly it ll still actually open up vim. But it s not gonna let you actually use that variable properly basically now net row. Isn t perfect. So the problem with natura is it s not really a problem in nature.
It s the fact that nerd tree exists so because node tree is vastly more popular you have a lot more plugins actually built around the node tree idea so you ve got things like your get built into it and i don t know if you can get devil icons working on natural you might be able to get them in but there s also def icons for node tree and a bunch of other cool stuff that you could use along with it now there are plugins for net true like you have vinegar. I m not running vinegar on my system. Because i don t really see much of a benefit to it. But there are a few most of the plugins for a vim file explorer though are built with natura in mind.
So you ve got to keep that in mind if you do want to run net true. If you re like me. Though and you just want to use it as like a basic file explorer. I don t actually see any reason not to use net true.
I actually feel really dumb for using node tree all of this time i should just use net true and not bothered having to install a bunch of other extensions so for the time being i m sticking with metro. I really like it so far and now that i ve got it working the way that i like it the symlinks not working properly. I m gonna keep using it and i m gonna keep enjoying it basically so if you like this video remember to smash that like button and leave me a comment down below letting me know what you think if you want to see more videos like this then remember to subscribe and engler balcon down below because it ll really help the channel out i m now aiming for 10000. Subs and any help be really appreciated up on that corner.
I ve got the playlist this videos in so go check that out and we ll see other videos like this down below. I ve got my social links through my discord and my telegram so feel free to chuck any of those out if you want to chasme you ll see video updates. I ve also got my support link down below so that s my patreon and all those other methods. So if you want to support the channel feel free to use any of those but as always if you don t want to then you don t have to and lastly.
I ve got my ultimate video platform summer library and my bit tube so if you want to see my videos on platform that isn t youtube go check those out libraries doing really really well lately. So i reckon is probably gonna overtake my youtube again. We ll see how that goes though so i think that s pretty much everything for me. And i m out ” .
Thank you for watching all the articles on the topic Vim: Is Netrw A Better Alternative To NerdTree. All shares of bluevelvetrestaurant.com are very good. We hope you are satisfied with the article. For any questions, please leave a comment below. Hopefully you guys support our website even more.