Lesson 17 of 26

NerdTree in Vim

Duration: 3:39 Watch on YouTube (external link, opens in new tab)

Markdown version

In this lesson

Roy installs the NERDTree plugin by copying its line from Vim Awesome into the vimrc file and running the plugin install command. He opens it with NERDTreeToggle, moves between it and the file with Ctrl-W because it is just another window, opens folders and files with o, and shows its help with a question mark, including commands for bookmarks and for creating folders and files. Mapping a key shortcut to the toggle command is left for a later video.

Transcript

465 words

[00:07] (external link, opens in new tab) One of the most powerful useful plugins you'll find for Vim is called NERDTree. And if you go to Vim Awesome, you can see the details for NERDTree here. So, I'm going to show you how to install it and how to basically use it. And this is a it's a longunning plugin. Basically, if we're using one of the install plugins frameworks such as Vim plug in this case, we're just going to copy this, put it in our vimrc file. So, I'm going to go to the command line here and say Vim

[00:41] (external link, opens in new tab) Vimrc and I'm going to add press O here. Sorry, I'm gonna make sure you're v this is visible to you. Undo. Going to press O. Actually going to press commandV here to paste that. That should be enough for us. Let me command right quit. And this time if we say cd

[01:11] (external link, opens in new tab) Vim course and we do a vim for let's say basics and hello world and I want to open up the NERDTree. First I have to install it. So, I'm going to say command plugin install at the bottom, which will install the NERDTree. And at this point, I'm going to close this window.

[01:42] (external link, opens in new tab) And if I want to open the NERDTree window, all I have to do, there are multiple commands to do this, but one of the common ones is command NERDTreeToggle. Where is it? NERDTreeToggle. This one. And this is the window for NERDTree. basically yet another Vim window. And if it's a window, we can just move between those windows with command control W and then J or L. So W L to go right, control WH to go left.

[02:18] (external link, opens in new tab) And we can of course close it by calling NERDTreeToggle or just command quit because it's just another window. And here we can press O to open the various folders. We can press O to open the file and go directly to start editing it. I can again navigate to the window CRW and open this file instead. Let's go back and open this file.

[02:51] (external link, opens in new tab) Now you can do much more than that. You can actually have commands that do bookmarks etc. If you want to see all the commands, press question mark. You can see all the commands that you can have inside NERDTree. And that includes actually creating new folders, creating even new files, etc. So, it's a very powerful file explorer which kind of makes it feel like it's a bit easier to work with multiple files this way.

[03:22] (external link, opens in new tab) Now, you might not want to type NERDTree toggle, etc. And we're going to take a look at mappings and how you can make you can map command key shortcuts to bind to specific commands like NERDTreeToggle in a separate video.