Questions tagged [buffers]

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

Filter by
Sorted by
Tagged with
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 ...
0 votes
1 answer
72 views

Read viminfo when argc() > 0

Does Vim read the viminfo when called with a file argument? How can I force Vim to restore the buffer list in that case? Use case & context What I want is: When called as vi: enable read/write ...
3 votes
1 answer
1k views

Toggle fzf.vim if already open

I am trying to write a vim function to toggle the fzf window if it is already open using fzf.vim. The use case is if I am in the :Buffers view and I want to change to the :Files view if I try to ...
1 vote
1 answer
35 views

Move between buffers of a certain filetype

scenario: I have a bunch of programs that generate output, the programs and output are open in buffers and the programs are one filetype eg .r and the output is another filetype eg .txt I want to ...
0 votes
2 answers
68 views

How to exclude a specific buffer from the BufEnter autocmd group?

I want to load a plugin when I enter a buffer, so I set this event to BufEnter. But when I start neovim, the plugin loads at the dashboard buffer. I want to exclude that buffer. How can I do it? ...
0 votes
1 answer
33 views

How do I create key mappings for Windows and/or nano Shortcuts?

Having used text editors (mainly Notepad/++) and some IDEs on MS Windows, I've become familiar with their Alt and Ctrl shortcuts to the point that I use them automatically. Having used nano on a GNU/...
1 vote
3 answers
109 views

How to force Vim to delete all the [No Name] buffers?

I often use Vim to manipulate clipboard data. I create a new buffer :enew Paste the data in it Modify the data Yank it :%y At the end of my day, I end up with several [No Name] buffers. I want to ...
2 votes
1 answer
28 views

Configure buffer display name to show directory when buffer name is short

I don't normally set autochdir, but I'm trying it out and seeing what kind of small frustrations I encounter as a way of learning more about vim. For the purposes of this question, my .vimrc is the ...
1 vote
0 answers
33 views

Run macros in background while doing something else

I have a macro that calls APIs to fetch data based on information in a buffer. Is it possible to have the macro continue execution while I move to another window and work on other buffers?
0 votes
2 answers
1k views

Setup Telescope to save and close all buffers, when opening a new file

I'm following a Neovim tutorial on LaraCasts from Jess Archer, setting up Neovim. I've used Vim for a while, but I'm new with Neovim. You can see Jess Archers dotfiles here: Jess Archers Dotfiles. I ...
0 votes
1 answer
177 views

Vim - mapping a text string to specific buffer

I like to know how I can connect/map a specific string to a desired buffer. Let's say I have the following text files: file1: Dog Cat file2: Milk Now, the 2 files are located at different dirs, and ...
1 vote
1 answer
53 views

How to restrict tab-completion to the file name when opening a buffer

I know that I can do: :b home<tab> and vim will autocomplete to all buffers with the word "home" in them. My problem is that this includes all buffers that have "home" ...
0 votes
0 answers
23 views

How do I instruct plugin BufExplorer to open a buffer in an existing window?

How do I instruct Vim plugin BufExplorer to open a buffer in a specific existing window rather than open the buffer in a new horizontal (key f or F) or vertical (key v or V) window?
0 votes
1 answer
209 views

Useful script to manage buffer and window?

I want to create a vertical split from current buffer for reference another file/the same file. After I've done with this split I don't want to see this buffer-for-reference in the split, but: If ...
0 votes
0 answers
36 views

How can I stop Vim from quitting when the last buffer is a `:help` buffer?

I think there is an option that governs this behavior, but I cannot find it.
2 votes
1 answer
220 views

Session - start with buffer 1

Note: Possible fixed bug. See comments. A somewhat minor nuisance, but as the pedantic for these things :P When saving and opening a Session file the Session.vim file does: badd +1 file1 badd +1 ...
2 votes
0 answers
52 views

`E93: More than one match` when `<C-d>` shows only one match

When jumping between buffers in Vim, most the time things work quite smoothly. I like to jump to buffers by writing :b something1*something2, checking if the match is unique by invoking C-d, and if so ...
0 votes
0 answers
28 views

Buffers not close automatically by Vimspector

I have been using Vimspector for debugging Python but like 8-10 months now, the Python terminal buffer that is opened by Vimspector when the debugger runs, is not automatically closed when the ...
0 votes
1 answer
416 views

How to tag/enrich buffers with custom information (that persist naturally)?

I am trying to persist some state about my buffers, specifically terminal buffers, over vim sessions with :mksession through the plugin vim-session by Xolox. The goal is to assign labels to the ...
2 votes
4 answers
564 views

vim : how to set current buffer to a string using `:python`

As example, my current buffer contains below lines di=01;34 ln=01;36 mh=00 pi=40;33 I want to join all lines with :, and set entire buffer to the joined string. How to achieve that, using :python ...
0 votes
1 answer
29 views

How to search hidden buffer during insert-mode completion?

I am trying to write a completion function which has as its source a 386k line (CSS) file. Initially I read the file into a list with readfile() and used a for loop to iterate over each line, matching ...
0 votes
2 answers
131 views

Call range argument to execute in python terminal embeded in vim

Initial window: My expectation: to copy whole or a part of python code in the right window into the left window's python terminal and execute. My .vimrc setting: function! CopyPasteBuffer() ...
0 votes
0 answers
17 views

Is there a way to mark all buffers as "visited"? [duplicate]

I recognize that this is a very minor problem, but I thought I'd ask anyway. I mainly use Neovim, but to keep things simple, I'm going to be referring to and testing with vanilla Vim 9.0. The "...
0 votes
1 answer
24 views

How do I get the first column of the current buffer after scrolling horizontally?

In the normal case, the first column is 1. But after a command like z10l to scroll rightward now the first column visible is 11 instead of 1. How do I get this 11? My trying: I found that vim.fn....
2 votes
2 answers
291 views

How do I delete/unset a buffer local option (such as autoread)?

In a new buffer, the expression &l:autoread evaluates to the value -1, indicating that the local option autoread has not yet been set with :setl autoread or :setl noautoread. When I set the local ...
0 votes
0 answers
53 views

How to "keep" Lexplore/Rexplore/Explore position?

When navigating large projects, in IDEs like intellij, I keep opening and closing the navigation/file tree tab and moving around files. On vim I tried to create a similar functionality, adding to my ~/...
0 votes
2 answers
39 views

Misunderstanding of interaction between local options, moving between windows, and WinLeave, WinEnter, BufLeave, BufEnter events

This what is logged in :messages when I'm printing the value of nu and rnu upon the 4 events WinLeave, WinEnter, BufLeave, BufEnter during the action, done twice, of opening :help and closing it. 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 -...
1 vote
1 answer
144 views

Automatically save deleted lines to a new file?

I have a to do list that I manage in vim. I want to keep track of things I remove from the list. After I type dd to delete a line, I want to write this line to a different file. I only want this ...
0 votes
1 answer
34 views

Making certain buffers invisible to commands involving "all" or bufdo

For my projects I generally open several tabs some of which might involve terminals or directory trees or quickfix (since ShellCheck sends its error messages there for instance). When I want to use ...
0 votes
2 answers
103 views

VI - Insert buffer before

I've recently begun using buffers, rather than tabs, to sort files in vi. My question is, can I create a buffer such that, instead of getting this: [:enew] [:ls] 1 main.c 2 foo.txt 3 [No Name] I got ...
2 votes
3 answers
183 views

Open all files listed in current buffer

I have a file/buffer that contains multiple file names with line numbers. Example: Declaration of x fileA.h +3 Usage of x fileB.c +10 I can open a file with the cursor in the given line ...
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 ...
1 vote
1 answer
497 views

How do you use buffers/panes? Possible to move a buffer into another pane?

I recently switched from VsCode and I am quite confused about the window/pane system of neovim. It seems like these are the only options to actually use panes in neovim: https://stackoverflow.com/a/...
-1 votes
1 answer
43 views

:BufExplorer and its split variants sends me to another tab

If I have BufExplorer open in another tab, any of the following commands will send me to that other tab instead of opening BufExplorer in a new subwindow in the current tab: :BufExplorer :...
3 votes
1 answer
392 views

navigating multiple files - arguments and buffers

I've been learning vi (as an autodidact) for some weeks. Actually I'm not yet sure about if I'm using vi or vim (does the command vi open vim if vim is installed?). Now I'm trying to edit multiple ...
-1 votes
1 answer
49 views

What is the meaning of command `:4w`?

As title. I just read a post that people accidentally delete(wipeout) their unsaved work by trying the command :4w. A bloody lesson to him, but I also want to prevent this from happening to myself. ...
0 votes
0 answers
24 views

":bufdo cd ~/Some/Folder/Path" doesn't affect all files

I have about 15 files in my buffer list [1]. In my one and only tab, I have three modifiable subwindows, none of which have unsaved changes. I issue :bufdo cd ~/Some/Folder/Path, and Vim lists each ...
1 vote
1 answer
81 views

How does Buffer Explorer Vim Plugin (BufExplorer.vim) determine its colours?

I've customized a colour scheme over the decades. Recently (possibly within the last year), I upgraded BufExplorer and found that it lists all of the buffers in mostly orange or yellow. Orange is my ...
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 ...
1 vote
1 answer
55 views

What's the benefit(s) of deleting buffers that are not loaded into a window?

As title. Say that I have 20 buffers and only 4 buffers are shown (Assume in my current tab, I only have 4 splits). Since 20 buffers are there and each one is attached with some LSPs, I assume that ...
1 vote
2 answers
94 views

Navigate arglist via filename?

I like doing things like :b css to jump to the single css file I'm working on. But of course this only works if I only have 1 css file in a buffer. I'm under the impression that it is not possible to ...
0 votes
1 answer
326 views

How to get the total lines of a file before it's loaded into a buffer?

As title. My target is to disable a plugin before it is applied to a buffer that will be loaded with the content of a file. I can get the file name before it is loaded. The file to be opened is ...
0 votes
1 answer
272 views

How to grep only the contents of the current file?

I have this alias to grep under the cursor (for the entire project): " bind K to grep word under cursor nnoremap K :grep! "\b<C-R><C-W>\b"<CR>:cw<CR><ENTER>...
1 vote
1 answer
86 views

What happen internally when I set `bufhidden` to `delete`?

As title. Would the buffer I set the option with the value delete really get deleted immediately? If not, when will it be deleted and what is this mechanism? Sorry for maybe a bad question but I'm ...
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 ...
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 ...
2 votes
1 answer
83 views

What's the benefit of using unlisted buffers?

As title. Which command will make some buffers unlisted and why it is designed to do so? I guess this is related to memory management but I'm not sure about this.
0 votes
2 answers
3k views

navigate the buffer list

I've been looking for years for a way to quickly select a buffer from the buffer list. scenario: open the buffer list with :ls select the desired buffer with arrows or whatever open said buffer ...
0 votes
2 answers
26 views

Event with the same timing as BufEnter but triggers on vsplit?

As title. I have a pair of autocmds which needs each other: One on WinLeave, this one is fine since it will be triggered when I call :vsplit. One on BufEnter, this one is NOT fine for the edge case, ...

1
2 3 4 5
9