How do you work with large projects in VIM

I have big projects with many levels of folders. Some files are called the same, and depending on the name of the folder, their function changes. for instance

/admin/action1.php /action1.php 

Firstly, this applies to administrative tasks, and secondly, to users. Vim is very clogged with tabs and buffers, and it is difficult to move around. Pros I use: NERDTree CtrlP MiniBuffExplorer

I use gVim for Windows, and plugins like YouCompleteMe are not parameters.

  • NerdTree - Too awkward to navigate between large project folders
  • CtrlP - you need to know what you are looking for, typing names all the time
  • MiniBuffExplorer - has the number of files in the form of ridicculus, takes up a lot of space on the screen and it is impossible to find anything
  • Vim-Session - "Open Save" tab / window for the project

enter image description here

As you can see in the picture, there is a way for many tabs to remember that the witches tab corresponds to the witchcraft part of the code. MiniBuffExplorer doesn't help much.

So my question is how you could work with a large project in VIM to maintain organization, preferably by their function or section of code. Is there a clean way to do this? Is there a way to group buffers or tabs, for example:

 Migrations Seeds Admin Controllers Admin Views Config 
+6
source share
4 answers

I don’t think the tools are to blame. This is more how you use them.

  • Tabs are not intended at all as proxy files, as in other editors. Tabs are workspaces that let you arrange your windows as you like. They are the best candidates for your

     Migrations Seeds ... 

    scenario.

    Here is one possible way to create the Migration tab:

     :tabnew | lcd path/to/Migration 

    From there, all the windows created on this tab inherit the Migration working directory, and each :e :sp :vs or even :vim will be launched from this working directory.

    In addition, this will cause NERDTree and netrw to display the contents of your local working directory by default.

    See :help seeting-tabline and :help setting-guitablabel if you want to change the name of the tab.

  • You should use CtrlP path mode to match across the entire path, not the file name:

     fbruse 

    will match:

     foo/bar/user 

    but not:

     baz/vroom/user 

    With the tab settings above, CtrlP offers must be kept in the Migration directory, which speeds it up significantly.

    CtrlP is not perfect: it can be slow in large projects, so make sure you read all the documentation.

  • A list of open buffers "always on" may be a good idea when you have a small number of them, but like tabs, it clearly does not scale. It's a lot better to show the list when you really want to switch buffers: less screen property and brain cells for nothing!

  • Remember that while you can define a list of local window arguments, AFAIK cannot determine a list of local window buffers. Since the argument list always leaks into the buffer list, and the buffer list is global, buffer commands will always process the same number of buffers, regardless of which tab you are on. Therefore, limiting the overall usefulness of tabs.

  • Files are not a good metaphor for working with large projects: you have to store a complex symbol map β†’ a file in your head, while your program consists of functions, classes, arrays, variables ... not files.

    Using tags ( :help tags ) is a very convenient way to skip your project:

     :tag foo :tag bar<Tab> :ptag /baz<Tab> 

    And CtrlP :CtrlPTags makes it almost fun.

FWIW, tag-jumping is my favorite navigation technique, and I usually don't use tabs or windows.

+6
source

You can look at Vim-CtrlSpace , it is quite suitable for working on large projects. This plugin helps you work with tabs, buffers, sessions, etc.

You can check out the new demo video on YouTube.

+2
source

I use gVim for Windows, and plugins like YouCompleteMe are not an option.

This statement is false. Checkout is my other answer on this topic.

Good luck.

0
source

Vim is not an IDE ; It seems to me that you are pushing the limits of what makes sense (open at the same time) in Vim. You can easily configure simple integrations that allow you to open a file in Vim from within the IDE.

I suggest you use every tool where it is best: an IDE for managing and navigating large projects, and Vim - excellent text editing capabilities!

-1
source

Source: https://habr.com/ru/post/954677/


All Articles