![]() So you can imagine the modes as a merry-go-round. On the right is the buffer mode, in which we were in before. If you cycle back with you would access the file mode and CtrlP would look like thisĪs you can see now, files is the highlighted mode. The highlighted mode is always the active mode, as you can see in the image. You are able to cycle through these modes by pressing (forward) or (backward). The third mode is called MRU(most recently used) files. There is a buffer mode, which shows a list of all open buffers of our current Vim session. In addition to this mode there are three other ones. If we open CtrlP we see the whole path for each file. In the previous chapter we learned about the basic navigation features, but there is much more to explore. opens the file in a new tab, opens it in a vertical split and does the job in a horizontal split. Of course there are shortcuts for the other kinds of opening as well. Replace doesn’t make much sense in my opinion, because pressing Enter() is much faster. The first letter stands for the key, which needs to be pressed to apply the command. You can choose between ab, orizontal, ertical and eplace. If you try to open a file with you have the chance to choose how you want to open it. You are also not bound to to the enter key, when opening files, even though this is the fastest way to open a file in the current buffer. You can still navigate up and down with j and k by holding down Ctrl at the same time. But this doesn’t mean, that you need to blow the dust from your arrow keys. ![]() If you try to go into normal mode, to navigate through the results, the CtrlP view closes immediately. Maybe you recognized it during the first test already: the CtrlP split isn’t modal. Now you should be able to open CtrlP much faster. So let’s configure a proper shortcut for opening CtrlP. Like always, we don’t want to type in the whole command over and over again if we want to execute CtrlP. If you press the split will be closed again. Also the parts of the file paths are highlighted, which match your typed in string. If you type in some letters the result list should get modified. A new horizontal split view should have opened at the bottom now. After installing CtrlP, you should be able to call it with :CtrlP. Good news is there is an active fork where you should download it from. Sad news is he isn’t actively maintaining it anymore. Most search requests still give you kien’s CtrlP GitHub Repository. In the process many other editors adopted this feature in form of a built-in feature (atom) or in form of a plugin (emacs). But there is no official statements in the docs about it. So this is why the corresponding vim plugin has the name CtrlP. In Textmate the shortcut for this feature was Ctrl-P. There was no need to install additional stuff to get the fuzzy search. ![]() It shipped this feature right with the editor itself. In my humble opinion the big hype around this feature started with Textmate. Of course NERDTree and other tree views have their right to exist, but CtrlP is far more useful in most situations. With some practice it is a highly efficient way of navigate to files. Of course you want to type in those parts that make a file unique to match it as fast as possible. This means, that you don’t need to type in the beginning of a file path, but it can be any arbitrary part of the path. The more matches there are, the higher it is ranked in the results. You can type in any region of a file path and the fuzzy search matches it to possible files and directory parts. The magic behind this plugin is it’s fuzzy search engine. It covers a similar area like NERDTree, because it helps you to find and open files very quickly. In this article we will discover one of the greatest and most widely used plugins in the vim world: CtrlP.
0 Comments
Leave a Reply. |