Questions tagged [buffers]
The representation of a file loaded into memory. Edits are performed on buffers.
51
questions
77
votes
4
answers
27k
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 ...
30
votes
3
answers
10k
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 -...
54
votes
5
answers
25k
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.
84
votes
8
answers
72k
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 ...
17
votes
7
answers
4k
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 ...
11
votes
3
answers
4k
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 ...
17
votes
1
answer
2k
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
17
votes
1
answer
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
1
answer
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)...
98
votes
2
answers
68k
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 ...
58
votes
3
answers
20k
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 ...
16
votes
3
answers
3k
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 ...
14
votes
2
answers
5k
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 ...
13
votes
2
answers
1k
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 ...
5
votes
1
answer
2k
views
How to put the difference of two files in another file
I have two files in two different buffers and I want to get the difference between these two files in another file
How can I do this with Vim?
Example:
BUFFER1
rtl.de
sat1.de
pro7.de
spiegel.de
...
5
votes
2
answers
2k
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 ...
5
votes
2
answers
3k
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 ...
4
votes
0
answers
101
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
1
answer
131
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 ...
89
votes
6
answers
49k
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 ...
35
votes
1
answer
11k
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 ...
32
votes
8
answers
25k
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 ...
29
votes
2
answers
11k
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?
22
votes
4
answers
8k
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 ...
21
votes
5
answers
20k
views
What is a scratch window?
Sometimes I see a window open with name scratch.
I know it is some kind of temporary buffer/window.
How can I create one?
:h scratch returns nothing.
18
votes
4
answers
5k
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 ...
12
votes
3
answers
8k
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 ...
12
votes
3
answers
2k
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 ...
10
votes
3
answers
3k
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 ...
8
votes
2
answers
158
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 ...
5
votes
3
answers
477
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" ...
5
votes
2
answers
397
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
1
answer
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
1
answer
3k
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, "&...
4
votes
4
answers
2k
views
How to split view multiple buffers in vim
Working with big projects, I often find myself needing to view/edit several files at once.
If I have multiple buffers open, is there a way to split the window to view multiple files in one command?
E....
4
votes
2
answers
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 ...
4
votes
3
answers
699
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 ...
3
votes
1
answer
606
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 ...
3
votes
1
answer
837
views
Is it possible to simultaneously edit one file in two views?
I've been using Vim regularly for a decade, but still feel rather inexperienced because there is so much of Vim that I am not aware of and do not use.
I sometimes want to see two different parts of ...
2
votes
2
answers
2k
views
Run autocmd when creating/deleting a buffer
I have two functions tex#PDFOpen() and tex#PDFClose() to automatically open and close the pdf file created by a TeX document.
The way I assign them to autocommands is via the following autogroup in ~/....
2
votes
1
answer
294
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 ...
2
votes
1
answer
564
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 ...
2
votes
1
answer
93
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. ...
2
votes
1
answer
69
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
2
answers
175
views
Way to open the list of buffers to easily prune (delete) many buffers at once?
:files is nice, but I want to delete a bunch of buffers at once. I know about :bd n1 n2 ... and :m,nbd, but it'd be nice to manipulate the list (e.g. to delete buffers) in a 'regular' window.
Is there ...
1
vote
2
answers
187
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
1
answer
321
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
1
answer
653
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 ...
0
votes
2
answers
3k
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
1
answer
260
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?