We changed our privacy policy. Read more.

Questions tagged [buffers]

The representation of a file loaded into memory. Edits are performed on buffers.

Filter by
Sorted by
Tagged with
73
votes
4answers
21k views

How to save window, split, and buffer layout?

I have several tasks I am working on in one repository. I would like to create "workspaces" for working on them. One "workspace" or "buffer layout" would have all files I need to work on open in the ...
66
votes
8answers
43k views

Fastest way to switch to a buffer in vim?

One way to select a buffer in vim could be to browse the buffers list, using standard commands as :ls, or with some external plugin / vimscript code to browse a list in a window. Let's say I want to ...
15
votes
7answers
3k views

How to bind a set of buffers to a tab?

When I need to work on different projects at the same time I have the folowing workflow: I create one tab for each project. In each tab I open the files that I want to edit, which makes several ...
21
votes
2answers
6k views

What is the order of WinEnter, BufEnter, BufRead, Syntax, FileType events?

I've gone through the autocmd.txt help, but the information about this is scattered and not always present (eg. with BufRead). Could someone who understands this well list the order of these events -...
9
votes
3answers
3k views

How do I add skeleton text to new vim files?

I use Vim for writing C++, and I have quite a few #include<> statements, comments, etc. that I must include in each new file I create. I've added autocmd BufNewFile *.cpp r C:\(full file path ...
40
votes
5answers
14k views

Dump the output of internal vim command into buffer

How do I dump an internal vim command (not shell command) into a new buffer? For example, I want to dump a listing of all plugins into :enew from :scriptnames so that I can search it.
14
votes
1answer
2k views

What bad things can happen if I use :bwipeout?

I have just discovered the :bwipeout command, for which the :help states: Like :bdelete, but really delete the buffer. Everything related to the buffer is lost. All marks in this buffer ...
4
votes
1answer
2k views

How to set a local variable for a plugin in a BufNewFile autocmd

I currently have autocmd BufRead *.sage \ set filetype=python | \ let b:syntastic_skip_checks=1 which works as intended (sage files are treated as Python, but with Syntastic disabled)...
14
votes
1answer
1k views

What is the difference between a tab, viewport, window, split and buffer?

What is the difference between the following in vim: buffer window viewport split tab
84
votes
2answers
55k views

Close and unload a buffer without exiting Vim

Often, I'll load some information into a temporary buffer, and then close it with :clo!. But this hides the buffer rather than unloading it entirely, even though I have nohidden set. I find this ...
12
votes
1answer
979 views

different search patterns per window / buffer

Is it somehow possible to have different search patterns per window or buffer, ie. I want to search for term A in window/buffer A and term B in window/buffer B so that using hlsearch, highlights ...
13
votes
2answers
3k views

How to iterate over buffers in Vimscript

How can I iterate over the current open buffers and say, load the buffer numbers into an array in vimscript? I know there exists arrays or similar data structures in vimscript. I know that every ...
4
votes
0answers
96 views

Return to previous buffer without going through every jumplist entry [duplicate]

When I've jumped from a buffer to another buffer I use C-o to return and after that I use C-i if I want to jump to that same buffer again. I think this is the common approach. The problem is that this ...
3
votes
1answer
1k views

Close multiple buffers interactively

Is there a way to view a list of open buffers and close several buffers without leaving that list? The best I know of for closing multiple buffers is using :ls to get a list of buffers, memorizing ...
2
votes
1answer
48 views

Prevent cycling / wrapping to first buffer after last

I have opened multiple buffers and I cycle between them using :bnext and :bprevious. How can I prevent vim from cycling to the first buffer when using :bnext on the last buffer / cycling to the last ...
81
votes
6answers
42k views

Is there an easy way to close a scratch buffer/preview window?

One of the plugins I have installed (probably Supertab) provides a nice view of documentation for the currently highlighted item in the completion menu: The (apparently) scratch buffer remains open ...
16
votes
3answers
3k views

How do I have buffers listed in a quickfix window in Vim?

Using vim editor, a common task is to browse buffers. I now use standard commands like :ls or a :bnext. In fact I set in my .vimrc: "move amongs buffers with CTRL map <C-J> :bnext<CR> map ...
40
votes
2answers
15k views

How can I reload all buffers at once?

When working on a feature branch in git, I frequently need to stash my changes to commit a bug fix to the main branch. When I'm done working on the changes, I git stash pop, which updates the ...
29
votes
1answer
8k views

How do you open a new buffer in the current window?

I've got a few tabs open with different window setups. I'd like to open a new blank buffer in the current window, without having any more splits/windows or tabs Is there any way to do this? I know ...
14
votes
3answers
2k views

What is a more efficient way to use buffers?

Lately I've been drastically reducing the number of plugins I'm using so I'm looking for answers using only built-in Vim features. I've been noticing a flaw in my workflow when I'm editing a lot of ...
9
votes
2answers
1k views

Syntax highlighting is gone after :bufdo :e

I'm using console vim within a tmux window, therefore occasionally vim doesn't recognize that files have been modified (gvim does it on a focus change AFAIK) and in order to avoid getting inconsistent ...
18
votes
4answers
5k views

Is there a way to reliably go back and forth in file history

I would like to go to the file I just edited last and next kind of like MRU plugins do. :bnext and :bprev works sometimes, but more often than not I just end up in some obscure file I don't remember ...
25
votes
2answers
6k views

How do I open a new buffer without opening it in a split?

I know I can use :new to open a new buffer in a split window (defined by set splitbelow and set splitright). But how can I just open a new, empty buffer without opening it in a split?
7
votes
2answers
144 views

Can I cycle through buffers while skipping ones I've opened?

Let's say I have a vertical split, and four buffers open. I'd like to be able to have one buffer open on the left, and cycle through just the other three on the right. Something like :bnext but ...
3
votes
2answers
730 views

Efficient way of cleaning up the buffer list

Very often, after days and days of coding, opening vim -S session everytime, I end up with a fair long buffer list that I want to clean. Therefore I use :ls to list all buffers, and then :bdelete ...
3
votes
1answer
511 views

How to keep the screen position from "zt" after switching buffer

When I use zt to scroll the screen relative to the cursor and then switch buffers with, say, :bn followed by :bN, the screen jumps back to the position before executing zt. Using for example ctrl-d ...
19
votes
6answers
12k views

How to go to previous open buffer from Vim command line?

I am trying to write a Vim function which should make the window go to the previous open buffer. How can I do it from the command line? My first idea was to find out some CTRL-O command line ...
5
votes
2answers
237 views

Closing all buffers that represent .js files?

Can I close all buffers by regex, for instance all buffers that hold open .js files? Effectively what I want is :bd *.js But even with ! if more than one .js is open I get, E93: More than one ...
4
votes
1answer
2k views

Buftype=nofile when switching buffers with :Vexplore

When I open up :Vexplore in a split and open a file in it, the file in the other split ends up with buftype=nofile set so I can't write in that file or anything. But the new buffer that was opened ...
4
votes
2answers
2k views

How do I make netrw behave with respects to cycling through buffers with :bprevious/:bnext

I have my vim setup according to "Solution #1: Replicating Tabs with Buffers" on this site buffers-vs-tabs with the vim-airline plugin. If I open numerous files in buffer 'tabs' :bprevious/:bnext ...
2
votes
1answer
461 views

How to create a new 'secure scratchpad' buffer?

I want to be able to create a new buffer (and a new window with which to interact with it) to work with secret or sensitive info, e.g. passwords. Ideally, none of the contents of the buffer would ...
10
votes
3answers
5k views

Reopen the most recently closed buffer

When writing to a file, I often accidentally type :wq instead of :w since the two keys are right next to each other. But since I almost always have more than one buffer open, Vim stays up and whatever ...
4
votes
2answers
706 views

Is there a way to list recent buffer history?

I just started using buffers in Vim and I couldn't figure out how to list recent closed buffers. Is there a simple way (like :ls) to list those? Are they actually stored by Vim? Maybe I'm misusing ...
4
votes
3answers
363 views

Is it possible switch buffers in order of accessing but not opening?

At first I am going try to explain you "order of opening". For example, if I'll open files in this order: 1_file.c 2_file.c 3_file.c 4_file.c :ls command will give me: :ls 1 "1_file.c" ...
2
votes
2answers
467 views

Switching buffers in VI while skipping any terminal in VI 8.1

I am using multiple files within the same tab and when I switch buffers using :bn I reach the terminal, at which point I have to issue the command again to move. Here is the catch, I am using keymaps ...
2
votes
1answer
665 views

Vimscript: How to check if a buffer is modified

Given a buffer number i, I want to check if the buffer has been modified after the last save. How do I do that in vimscript? I tried to use getbufvar() like the following: if getbufvar(i, "&...
2
votes
1answer
90 views

Mapping specific for diff mode and vimdiff

My idea is that whenever &diff is true for a buffer, I would like some mappings to be active when that buffer is the current buffer. The following attempt works for when I open a session in diff ...
1
vote
1answer
57 views

Why does g+ sometimes skip a leaf of the undo tree?

I'm trying to understand how to move in the undo tree with the following default mappings: u, <C-R>, g- and g+ Here's my understanding of things, which is probably wrong or incomplete. Each ...
1
vote
1answer
74 views

Make vim remember the fileformat of a buffer

I am using vim to view Spyder's Python comman history. I set to :e +=ff=dos to get rid of ^M at the end of each line. When I switch to another file, then switch back, the fileformat is unix again. ...
1
vote
2answers
46 views

Close buffer in the other instance

When a file is being opened neovim warns that swap file already exists, at which point you can't safely open a file without first closing it in the other instance. I frequently have many projects ...
0
votes
2answers
2k views

neovim: how to close the terminal buffer by just pressing enter?

NVIM v0.2.2 Build type: Release LuaJIT 2.0.5 Compilation: /usr/local/Homebrew/Library/Homebrew/shims/super/clang -Wconversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_MSGPACK_HAS_FLOAT32 -...
0
votes
1answer
197 views

How can I prevent some buffers from being reachable using bnext, bprev? [duplicate]

I'm using a combination of buffers and splits. What I want is for :bnext or :bprev (or some equivalent) not to open buffers that are already opened in some other split or tab. Is this possible?
0
votes
1answer
254 views

What are viewport, layout and workspace in relation to tabs

I'm making tentative steps into using tabs in Vim. It seems a bit ridiculous, I've been using tabs in everything for the last 18 years: Visual Studio Every browser since Opera came up with them ...
0
votes
1answer
379 views

how to control the :bp / :bn files I loop?

I'm using :bp to re-open the previous file I worked on, and :bn to go back, but I'm stuck on a loop with 3 files, and I only want to loop over 2 of them. Is there a way to edit the buffer and pop the ...