1

I'm a newb trying to learn neovim. I'd like a layout where a tab window is on the left-hand side and the right hand side has a horizontal split with the terminal window in the bottom and various help texts and other temp buffers on top. The tab window on the left would then contain buffers for source files.

I start off with :vs to split the window. On the left hand side I open a file in a tab. When I open a second file in tab on the left-hand side, it takes over the full width, i.e., only the first tab has the vertical split. How can I make the vertical split dominant?

Edit: Thanks for the preliminary responses. "Window" might not be the right word for what I want; maybe a layout or window container?

This first picture depicts an initial layout I'd like to achieve. You can see the tabs for test.h and test.cpp on the left and the terminal on the right. To create this I first split the initial window with :vs, then used telescope's sf with Ctrl-T to open test.h and test.cpp in tabs. desired neovim layout

But when I switch to the test.cpp tab, it takes up the full width of the screen. Instead I'd like for test.cpp to be displayed like test.h above, in half the width. enter image description here

I suppose I could achieve a similar layout using tmux, but I'd also like to have the right-hand side split horizontally with the terminal in the lower half and helpful docs/context/find results/etc. in the upper half. The goal is to have most of the functionality and UI of an IDE with the control and stability of vi.

2
  • It would be nice if you could give us the list of command you run and a drawing of what you want. The tabs are split in Windows both vertically and horizontally. But each tab take the full screens. Sep 16, 2023 at 16:54
  • Do you still have something open in your question? How can we help you further. Otherwise maybe could you accept one of the answer using the v button next to the arrow voting button. It allow the question to rest :-) Sep 19, 2023 at 5:07

2 Answers 2

1

Each tab takes the full screen.

But each tab can be split in Windows both vertically and horizontally using the commands:

  • :vsplit
  • :split

To achieve the layout you want I would use one tab and three windows:

  1. :e test.cpp open test.cpp
  2. :vsplit create a vertical split for your help file and focus to it
  3. :split split the help window
  4. :term replace the content of the second horizontal split by a terminal.

If you want to have the possibility to visual switch buffers within a tab you could be interested to plugin that provide that.

On Neovim a popular solution is bufferline

2
  • Thank you. If I switch focus back to the lefthand window (test.cpp) and open a new file (e.g., test.h) normally, I see that it maintains the half-width dimensions of test.cpp. But is there no way to have test.h and test.cpp in half-width tabs?
    – jonstewart
    Sep 17, 2023 at 13:57
  • 1
    Not in standard Vim. But there are plugin that add a buffer line to help you switching between buffers like if there were tabs. Sep 17, 2023 at 18:43
0

I think you’ve misunderstood tabs and windows. Vim contains tabs. Tabs contain windows. Windows display (parts of) buffers.

Knowing this, we see that to have a window containing tabs is impossible. But you can have a left window and a right window with completely different buffers (one could be a terminal). If you create a new tab, that layout stays (in the first tab) and you have a new, second tab to create a distinct layout of windows in.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.