Making Room in Neovim

Author: Olivia Martinez

Published: November 21, 2026

Part two of the Neovim series: finding the buffer, window, and tab workflow that fits you, plus some intermediate editing.

Intro

Ā”Bienvenidos de nuevo! šŸ‘‹šŸ½ This is my second post in my series about Neovim. Part one got you installed and moving around a single file. In this post we’ll be focusing on finding the buffer, window, and tab setup that works for you. At the end I’ll also cover some intermediate editing skills not covered in the first post.

Buffers, Windows, and Tabs

Knowing how to swap modes is just the first half of the journey to using Neovim. Buffers, windows, and tabs make up the other half. By this point you should feel comfortable with the basic motions of editing a file. Your fingers should glide the cursor like lightning strikes its target, fiercely and randomly! (Wait, that’s not right. šŸ§™šŸ½ā€ā™€ļøā›ˆļø)

Let’s go over some concepts and figure out how we can work with them in Neovim.

Buffers are the in-memory copies of opened files. They exist independently from windows and tabs. Technically, buffers can also be other things: documentation, terminals, file explorers, plugin prompts, logs, and checkhealth, to name a few. But when you open a file, Neovim creates a buffer to edit that file. That buffer also has some data associated with it, like a swap file that Neovim writes in the background as you edit (and an undo history, which is saved to disk too if you turn on undofile).

Windows, on the other hand, are viewports that display a single buffer at a time. Windows must always display a buffer. An interesting dynamic here is that a buffer can be displayed by multiple windows at a time, but a buffer needn’t be displayed to remain open. In other words, any given buffer can be shown in zero, one, or multiple windows. If you made an edit through one viewport, you would see the edit happen in the other one if it happened to be pointing to the same buffer!

Tabs, finally, are window layouts. They can hold one or multiple windows in a variety of arrangements. If you close all windows in a tab, the tab closes. You’re always in a tab, but the tab line only appears once you make your second tab with :tabnew.

But when you start out using Neovim, this vocabulary and workspace might feel daunting and cumbersome. Perhaps you’ve tried setting up your workspace only to find each rearrangement tedious. After all, it seems easier to bind one view to one buffer and to be able to move them around with visible tabs like most GUIs do.

🐭 Hold on, do I hear squeaking?

In the following sections I’ll cover three workspace archetypes, each centered around one of the concepts: buffers, windows, and tabs. I’ll describe how each archetype might use these concepts to work with Neovim and what essential commands they should know to get the most out of it. I’m giving each a silly name for levity. There’s no real association behind them, and I could just as well have used other characters, but these are the ones that came to mind.

šŸ‘‘ Sauron’s Path: The Split Workspace

Sauron likes to open one window per buffer and have many files open at once. This workspace is almost exactly like how desktop environments handle applications: you open a file explorer, Firefox, and Spotify, and your desktop environment helps you arrange them on your screen. The big difference here is that in Neovim you must manage all the windows through commands and shortcuts.

This workspace works well with large screens or projects that require you to edit multiple things at once. You likely also run your terminal inside a Neovim window (:terminal) rather than in a separate terminal tab, though no one will bat an eye if you keep it separate. The key point of this style is that Neovim is essentially your command center.

Window Command Description
:new Open a new, empty window in a horizontal split.
:vnew Open a new, empty window in a vertical split.
:split Split the current window into two horizontal windows.
:vsplit Split the current window into two vertical windows.

It might seem tedious to set up four or more files in this workspace, but there are shortcuts. :Hexplore or :Vexplore opens a new window and takes you directly to Netrw, the file explorer Neovim comes with.

For the split commands, note that both windows will display the same buffer when they first split. This is useful if you want to see two parts of the same file. But another way to shortcut file setup is to add the filepath after the split command.

:split ~/Documents/writing/a_panopticons_diary.md
Window Movement Description
CTRL-w w Cycle through windows.
CTRL-w {hjkl} Jump one window in that cardinal direction.
CTRL-w {HJKL} Move the window in that cardinal direction.
CTRL-w {+-} Increase/decrease window height by one line.
CTRL-w {<>} Increase/decrease window width by one column.
CTRL-w c Close the current window.
CTRL-w o Close every other window, leaving only the one you’re in.
CTRL-w = Resize all windows back to equal dimensions.

When I say jump, I really just mean the cursor moves there. Wherever your cursor is, that is the active window. Your cursor will follow you when moving windows or making splits, and it will also refocus to the next available window when you close the window it is currently on, so you don’t have to worry that you’ll lose track of your cursor.

When you move a window in a cardinal direction, it stretches to fill the full length of that edge of the screen: the full width if it moved up or down, or the full height if it moved left or right.

While they’re not motions, the resizing commands accept a count. CTRL-w 10- will decrease the window height by 10 lines. CTRL-w 5> will increase the width by 5 columns.

Notice that the window commands reuse the same directional keys as normal mode. Technically, you could also use the arrow keys, but I’m afraid you waived your right to use the arrow keys when you signed the terms and conditions. (jk)

Also, don’t mistake the width shortcuts for directions. < and > don’t mean move left or move right; they mean narrower and wider.

šŸ’ Smeagol’s Path: The One Window Workspace

Smeagol likes to keep his focus on only one window, and through that window he is able to bring up any buffer he needs to work on. This means every file gets your full attention, and distractions are minimal. This style is more analogous to your phone’s app switcher. When you open Photos, Safari, and Spotify, your phone devotes all of its screen space to one app at a time, and you swap between apps through the app carousel. In Neovim, Smeagol has a system just like that.

This workspace works well if you’re working with a smaller screen or longform content. It also works if you have to share screen space with another application.

Your app carousel in this case is the buffer list. To see it, use the :buffers or :ls command. It will produce something like the table below (without the column names).

Buffer # Flags Filepath Line
1 %a ā€œinit.luaā€ line 12
3 #h + ā€œnotes.mdā€ line 4
5 h ā€œ[No Name]ā€ line 1

The first column is the buffer number. You can use it to jump directly to that buffer; :buffer 3, for example.

The second column contains flags. Flags provide some brief details about the buffer. Here are the ones you ought to know.

Flags Description
% Current buffer. (The one your cursor is in.)
# Alternate buffer. The last one you were in. CTRL-^ or :b# flips between them.
a Active; loaded and shown in a window, possibly in another tab.
h Hidden; loaded, but not shown in any window.
+ Modified; you have unsaved changes.

There are more, of course: = marks a read-only buffer, and u marks an unlisted buffer (such as a help page), which only appears with :ls!.

The third column holds the filepath. If the buffer has no file associated with it, it will show [No Name] until you save it and give it a name.

The last column tells you the last known cursor line for that buffer. That is where your cursor will land when you switch to that buffer.

You don’t have to call buffers by number alone; you can also cycle through them with buffer commands.

Buffer Command Description
:bn Jump to the next buffer in the list.
:bp Jump to the previous buffer in the list.
:bf Jump to the first buffer in the list.
:bl Jump to the last buffer in the list.
:bd Delete the current buffer. :bd {n} deletes buffer n.

:b can also take partial filenames, so :b notes will jump me to buffer 3. You can also tab complete the name.

One note about deleting a buffer: it also closes any window that was displaying that buffer (if it’s your only window, Neovim shows another buffer instead). Additionally, the buffer isn’t fully gone; it’s just unlisted.

Up to now, you might have been following Sauron’s path, so you might be wondering, how do I open files without making more windows? It might feel intuitive to open a window for every file, but you don’t actually have to do that. You just need one window to cycle through buffers.

Here’s what you can do instead:

If your workspace happens to be in-between Sauron and Smeagol, a command you might like is :sb {buffer}, which opens a buffer (by name or number) in a split. If you want that split vertical, it’s :vert sb {buffer}.

šŸ”® Saruman’s Path: The Tabs Workspace

Saruman likes to keep tabs. His approach is a lot more freeform than the other two because he has both styles at his disposal. He could make one tab hold a single window for deep focus, or he could arrange a variety of windows on another tab to view things at a glance. This style is more akin to virtual desktops: to get past the limits of your physical screens, you place your apps on separate desktops that you flip between, keeping each layout organized.

This workspace works best for ever-shifting environments where one half of the day you might be testing software and the other half you might be focused on only one task. It also keeps a Sauron workspace from getting too cluttered and a Smeagol workspace from getting too obscured by letting you compartmentalize each task.

Tab Command Description
:tabe {file} Open a file in a new tab.
CTRL-w T Move the current window to its own tab.
gt/gT Next/previous tab. 3gt jumps straight to tab 3.
:tabc Close the current tab.
:tabo Close every tab except this one.
:tabs List tabs and the windows in each.
:tcd {dir} Set a working directory for this tab only.

Note that tab cycling wraps around: gt on the last tab takes you back to the first.

If you close a tab, the buffers on that tab become hidden. They’re not gone; you’ll find them on the buffer list. Neovim will warn you to save any edits when you quit, but it’s always worth doing a buffer sweep before you go. Run :ls and look for the + flag. Those buffers have unsaved changes. If you’re an editing hotshot, you can use :wa to save everything or :wqa to save all and quit.

Where you open Neovim is your working directory. If you need to work on a project in another directory, you don’t need to boot up a second Neovim instance. :tcd {dir} can change the directory for that tab. This means relative paths, Netrw, and new terminal buffers will all start from that new directory. Commands you run from Neovim, like :make, :!git status, or any other :! shell command, will run there too. Technically, a window can have its own custom working directory too with :lcd {dir}. This takes priority over :tcd, but it’s rare that you would want window-level working directories over tab-level.

Finding Your Workspace

So after going through all these workspace archetypes, you might be telling yourself, I don’t fit into any of these. It’s okay if you don’t! These are meant to be illustrative, not prescriptive. The nice thing about Neovim is that you get to define how you want to use it.

Perhaps you’re lamenting how much effort it takes to open a file right now, but do consider how much time other editors take, too. If you come from a mouse-dependent or mouse-dominant editor, you likely have not timed how long it takes to open files, navigate folders, or find your cursor. That tedium goes unnoticed because modern operating systems are designed around the mouse. And if you ever had to go looking for a setting, well, I think you should consider that too. I’m by no means telling you there is some categorical imperative to use Neovim over other editors. Just that working keyboard-only is different, and there is a learning curve.

Something else worth considering is your use case. Oftentimes, your work dictates your workspace. So if you find yourself struggling to work with files at some point, consider rearranging your workspace so that you’re not battling buffers and windows.

Personally, I was more like Sauron when I started using Neovim and became more like Smeagol afterwards. I occasionally use tabs, but because I don’t like to work on more than one project at a time, I rarely need them.

Intermediate Editing

Okay, now that we’re done with that, I’d like to show you some more editing skills. Last post I went over the basics, but I neglected to mention some common editing tools: find and replace, column editing, and macros.

Find and Replace

In Neovim, we know it as the substitute command, :s. The command operates on a given range. It’s divided by three delimiters, which can be almost any punctuation mark (except \, ", and |), so long as you’re consistent. Common alternatives are #, @, and +. For our example we’ll use the conventional forward slash /.

:{range}s/{find}/{replace}/{flags}

:{range}s is the area where the substitution takes place. It can be % for the whole file, a line range like 1,20, or a visual selection (enter Visual Line mode with V, move up/down to expand your selection, then press : — the command line fills in :'<,'> for you, and you type s after it). :s on its own defaults to the current line only.

/{find}/ is the search term. Regular expressions are supported. You can escape special characters with a backslash, e.g. \/ searches for actual forward slashes. Matches highlight as you type.

/{replace} is what gets substituted in. Like the search term, you’ll see a live preview of the replacements. Special characters can also be escaped with \.

/{flags} are optional. By default, :s only replaces the first match per line and doesn’t ask for confirmation. Add g to replace every match on each line. Add c to confirm each replacement.

Put together: to replace ā€œhereā€ with ā€œthereā€ across the first 100 lines, replacing every instance per line and confirming each one, you’d run :1,100s/here/there/gc.

If you edit filepaths, consider alternative delimiters! This substitution is much easier to read as :s#/usr/local#/opt#g than :s/\/usr\/local/\/opt/g.

Block Editing or Multi-Cursor Editing

I never knew you could edit text like this until I used Visual Studio Code one weekend and accidentally pressed the wrong button. Honestly, I don’t think it’s super useful, but maybe you come from VS Code or a similar editor and you need this feature.

For this edit, every line needs to reach the column where you’re inserting; if a line is too short, the edit will skip that line. Your cursor positioning matters a lot here.

  1. Enter Visual Block mode with CTRL-v and move up/down over the lines you want to edit.
  2. Press I, type your text, then press Esc to exit. (The text only shows up on the first line while you type; the rest fill in when you press Esc.)

Why I? Remember how I means ā€œinsert at the start of the lineā€? Well, in Visual Block mode, it’s still doing that, except the boundary has changed. I isn’t working from the whole line, just from where your block starts. That’s why cursor positioning matters.

We can also add things to the end of lines. Instead of I, use $A (end of line, append); this one works even on lines of different lengths. Or, if you want to replace a certain region, c will remove the selected area and put you into insert mode.

Macros

Sometimes a task is repetitive no matter how you square it. Macros, aka Complex Repeats, let you record your keystrokes to a register and replay them. (Remember how I said there were special registers in the first post? šŸŖ)

  1. Start recording: from normal mode, press q followed by a lowercase letter or a number. I’m using y for my example. (Using the uppercase letter, like qY, appends to that register instead of replacing it.)
  2. We always start in normal mode; from here we perform our keystrokes. I’m going to insert a bullet point at the start of the line and move the cursor down one line, 0i- <Esc>j.
  3. Once you’re back in normal mode, pressing q again will stop the recording.
  4. Replay your recorded keystrokes with @ followed by the register, e.g. @y.

You can prepend a number to have the macro run multiple times, 100@y, and @@ will repeat the last macro you ran. Macros can also work with your custom mappings. (We’ll cover mappings in part four.)

What Comes Next

Sauron, Smeagol, and Saruman aren’t the only three ways to work, and you don’t have to pick just one path forever — plenty of people mix and match depending on the task in front of them. What matters is understanding the pieces well enough to build a setup deliberately instead of stumbling into one.

That covers the workspace model. The next post in this series will be a grammar class, heads up there will be a pop quiz! We’ll cover Operator-pending mode, text objects, and Ex commands. See you in the next post: Neovim as a Language (coming soon).

Further Reading