How to organize Vim buffers, windows and tabs when working with many files

I have been using VIM all my life, but lately Iโ€™ve gotten a little tired of it because I get lost in buffers, windows and tabs when working simultaneously with 20 files or so in a large project (with 500 KB LOC and hundreds of files).

Whenever I do :make :grep , etc., new buffers jump out in the current window. The same thing happens with tags. At some point, this starts to be very confusing, because I really need to focus where everything is in VIM.

What are proven and easy ways to control this behavior?

+3
source share
5 answers
  • Use :hide to get rid of all windows if you really don't need to open them.

  • I'm not sure why tags create a new window for you, CTRL+] should reuse the current window.

  • nnoremap + 4<CW>+ and nnoremap - 4<CW>- greatly simplify window resizing, as well as standard <CW>_ and <CW>| .

  • Get a 22-inch monitor (minimum) and use :vsplit to show files next to each other. I believe this is even more important than having two smaller monitors.

  • Use <CW>L , <CW>H etc. to move windows. Do not forget :tab sp open the current file (or new) in a new tab.

  • :map <LEFT> <CW>h and :map <RIGHT> <CW>l etc. greatly facilitate the movement between windows. :map <C-LEFT> :tabprev<CR> and :map <C-RIGHT> :tabnext<CR> itโ€™s much easier to move between tabs.

And finally, if you need to open 20 files regularly, this may mean that your code is poorly organized. If possible, functions should be contained in a single file, then you just need to focus on one function at a time.

+4
source

I checked Eclim http://eclim.org/ some time ago for a friend. Basically, it allows you to run Eclipse in silent mode, using vim for editing, and so on. Thanks to the extension, it allows Vim to use all the strengths of both worlds, adding, for example, the Eclipse project tree to your favorite editor!

The installation was a bit complicated at that time, but as soon as I started it, it was a really smooth and rather brilliant solution. Try it, I'm sure you will not be disappointed. And installation is probably easier now. :)

Oh, I should also mention that there are several Eclim installations. You can have a carefree Eclipse with vim as the main interface (as I mentioned earlier), you can have an Eclipse and Vim header so you can easily switch back and forth (in the same project at least), or you can have Vim Integrated in Eclipse.

+2
source

Run some vims. I use konsole on my Linux machine. This allows me to open many linux session sessions in one window. I can double-click the tabs to name them, for example. "models", "views", "controllers", etc. In each of these linux terminal terminals, I will have a vim process that usually has 2 or 3 files at a time. Another option is search and an IDE with Vim mode, so you can use most of your commands.

+1
source

As a long-time vim user, it hurts me to say this, but maybe you should go finish the full IDE. In most cases, you can use vim as your editor, but the IDE will handle the files and navigation for you and will probably simplify your workflows and graphical workflows (for example, a structural search will remove pants from grep). What language do you work in?

0
source

Vim-CtrlSpace allows you to organize tabs, buffers, sessions (workspaces) + fuzzy search.
This is quite suitable for working on large projects. This is how I actually came up with this.
I used to use "jlanzarotta / bufexplorer.git" and "xolox / vim-session"

You can check out the demo on YouTube .

-2
source

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


All Articles