Lesson 18 of 26

Ctrl-P

Duration: 2:47 Watch on YouTube (external link, opens in new tab)

Markdown version

In this lesson

Roy installs the Ctrl-P plugin, a fuzzy file finder, through the vimrc file and PlugInstall, restarting Vim because it reads the vimrc on load. Pressing Ctrl-P lists the files in all subfolders of the current location, and typing part of a file name finds the file so that Enter opens it. He compares this with browsing in NERDTree and finds a combination of the two useful.

Transcript

401 words

[00:11] (external link, opens in new tab) Another very powerful plugin that I like to have running inside Vim is Ctrl P. And this is basically a fuzzy file finder. Let's say we want to install this and so I can explain what it really is and how to use it. Let's install it again by pasting this inside vimrc. So, let me go back into Vim and let's do a home slash sorry dot vimrc

[00:42] (external link, opens in new tab) And add this plugin. So, I'm going to put an O here. Paste a new line. Escape. Right quit. Now let me turn on Vim again and do a PlugInstall. And the reason I restarted Vim is because Vim Vim has to read the vimrc file on load. And technically we can also create later like a function that automatically reloads the Vimrc file. But for now I just do it this way and it's it's pretty nice and simple.

[01:13] (external link, opens in new tab) So now we have Ctrl P installed. So what does it actually do? Let me close this current window. If I press Ctrl P, what you see is that I have this menu inside which actually shows all the default the number of files that I can actually search through. And there's a lot of stuff in there. So, let me instead quit and go into just the current Vim. Just open Vim here directly in this. And if I press Ctrl P, it actually shows all the files in all the subfolders of all the places that I'm in.

[01:48] (external link, opens in new tab) Let me press escape for a second. Let's open NERDTree so you can see what I'm talking about. NERDTree. Let's see. And this is the NERDTree. And this is all the file the files on my current file system. So instead of searching for something inside NERDTree, I can technically just press Ctrl P and just type part of the file name and it will automatically try to find that file somewhere inside my folder structure.

[02:23] (external link, opens in new tab) First and you can see that it's the first thing that's already selected. I just press enter and I have the file. Let me switch to hello world. Ctrl P. Hello world. Enter. And I have the file. So it's a very very powerful very very easy to use plugin. And technically you're not you don't even need a tree of files on the left but a combination of both of these is very very useful.