Questions tagged [buffers]

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

Filter by
Sorted by
Tagged with
1 vote
2 answers
54 views

How to create a window for specific lines of a buffer?

Suppose we have a file: 1. un 2. deux 3. trois 4. quatre 5. cinq 6. six 7. sept 8. huit 9. neuf 10. dix I want to create a window that shows only lines 5--10 and nothing else. Modifying them should ...
Ayrat's user avatar
  • 123
1 vote
1 answer
208 views

How to get neighboring buffer numbers

Lets pretend I have a Vim session with buffers that look like this: +-------------+--------------+ | | | | | | | | | | ...
ColinKennedy's user avatar
1 vote
1 answer
205 views

MiniBufExpl: List buffers by window

Is there anyway to get MiniBufExpl to only list the buffers that belongs to the active window?
dan-klasson's user avatar
1 vote
2 answers
56 views

How do I keep the buffer list open for 1 more command?

Is there a way to keep the buffer list open so I can select a buffer? I.e., I do ls, then the buffer list shows up with the 'enter a command or press enter' prompt - I would like to press, for example,...
Aaron Parisi's user avatar
1 vote
1 answer
728 views

How to revert to "close file when buffer closes" behavior in Neovim?

The "old" Vim behavior was to close the file when all associated buffers are closed. With the newest version of Neovim, it appears that closing a buffer doesn't actually close the file. As ...
Qix - MONICA WAS MISTREATED's user avatar
1 vote
1 answer
50 views

Run autocommand only after all buffers have been written using :wa

I use an autocmd to copy a directory using rsync when saving a file with BufWritePost. When I save multiple files at once (using :wa), it runs rsync after every buffer save. How can I run rsync or the ...
Ruben's user avatar
  • 131
1 vote
1 answer
69 views

Character level buffer modification

It is possible to modify buffer at the line granularity. E.g. :py3 vim.current.buffer[0] = "abc". But it deletes the attached marks even if a single character is replaced. Is it possible to ...
tejasvi88's user avatar
  • 470
1 vote
1 answer
306 views

Search multiple buffers without replacing

Opening all 49 files in my working folder in separate buffers, I wanted to see if there were any em dashes. I typed :bufdo /— and vim immediately went to work, processing a page of buffers at a time. ...
BrianWilson's user avatar
1 vote
2 answers
135 views

Reloading buffers silently after an executed script changes the underlying files directly

I'm wrapping a command line script in a function and then in a command, which supplies this script with 2 arguments: nnoremap <leader>G :BxSedRi 'src/', 's/\<<C-r><C-w>\> ...
Petr Skocik's user avatar
1 vote
1 answer
491 views

How to recursively open all files except ones in hidden directories from within vim?

In my python project root folder, there are multiple directories, some of which contain hidden sub-directories specifying python virtual environments. I want to open all my python files recursively ...
WalksB's user avatar
  • 507
1 vote
1 answer
377 views

Exclude current vim buffer from buffer list

I am creating a plugin in vim that involves having a sidebar, within which you can switch between several different buffers with different functions. I am wondering how to hide these buffers from the ...
Prismavoid's user avatar
1 vote
1 answer
307 views

Pipe :Ag output to a new buffer

I'd like to search for a regex using Ag. This results in more than 1000 findings. I'd like to save these findings in a buffer to be able to go through them slowly
Salahuddin Ahmed's user avatar
1 vote
2 answers
227 views

How to properly catch errors when running scripts on buffers?

I am trying to write a function to lint buffers in neovim. It seems that the usual recommendation for achieving such a thing is to run the command over the entire range (ie %!lint). This is however, ...
Poh Zi How's user avatar
1 vote
1 answer
508 views

open file in an hidden buffer

I want to open a file invisibly such that I can operate using normal (programmatic) commands on it. How can it be achieved? Preferably, it should be hidden from the beginning. Thanks
eyal karni's user avatar
  • 1,106
1 vote
1 answer
245 views

How to make autowrite apply to :make but not to :buffer?

I have set autowrite so that :make automatically saved the file before running the build command. But now I'm increasingly using :buffer to switch between buffers, and have now noticed that it ...
Ruslan's user avatar
  • 475
1 vote
2 answers
207 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 ...
Rizhiy's user avatar
  • 143
1 vote
1 answer
45 views

How to open a new window and edit it in an automated fashion?

Consider the following function function! Exp() call feedkeys(":new ~/.vimrc\<CR>") call search('F') endfunction My expectation from Exp() was that if I call Exp() then 1) I see my ...
caffeinemachine's user avatar
1 vote
2 answers
1k views

How to close the netrw buffer/window from any other window

I would like to have the behavior where I can run :Vex<CR> when pressing <Tab> in normal mode: nnoremap <Tab> :Vex<CR> ... to open the netrw file tree window and then I would ...
stimulate's user avatar
  • 171
1 vote
1 answer
333 views

How to replace entire buffer with the contents of a variable?

I am trying to replace the entire buffer with the output from an external command. Similar to :% !myprog, but only if the command succeeds: let output = system('myprog') if v:shell_error == 0 " ...
Flux's user avatar
  • 1,041
1 vote
1 answer
68 views

Are there any performance difference between :edit and :buffer on existing unchanged buffer?

I used to believe that :buffer file is faster than :edit file if file is an existing unchanged buffer. I even created a tiny function for this: function! myvim#open(file) abort let nr = bufnr(a:...
dedowsdi's user avatar
  • 6,248
1 vote
1 answer
747 views

Pipe the content of the current buffer into an external command and then read the output into a new empty buffer?

I've established that it's possible to take the contents of a buffer (even one that isn't saved anywhere) and pipe it to a command. like so: :w ! petit --wordcount But! Is it possible to take the ...
leeand00's user avatar
  • 3,545
1 vote
1 answer
599 views

How to merge OS'es clipboard with Vim's one? [duplicate]

How can I merge OS clipboard and Vim's one? I want them to be the same, so that I don't have to use "*y or "*p or "*d, instead just y, or p or d. How can I do that?
Torito's user avatar
  • 119
1 vote
1 answer
675 views

How can I open a file from netrw into a new buffer without making it active?

I'd like to add the file to the buffer list without changing the currently active netrw window. I'd also love to make this the default behaviour for netrw. Any advice? I've searched around and looked ...
ergusto's user avatar
  • 111
1 vote
2 answers
30 views

Neovim doesn't open previously unopen file in horizontal split

In classic Vi/Vim when I opened a previously unopened file with ctrlp, NERDTree, etc. and the current file/buffer was unsaved, it would open the new file in a horizontal split. After switching to ...
webermaster's user avatar
1 vote
1 answer
43 views

Unloaded buffers and the :ls! command

I ran :ls! (having only a vague memory of the command and not really knowing what I was going to see) and saw a short list of files (maybe 5 or 6) with 'u' in the gutter. Apart from one of the files, ...
Tom's user avatar
  • 67
1 vote
1 answer
106 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 ...
user2153235's user avatar
1 vote
1 answer
106 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 ...
NeoZoom.lua's user avatar
  • 1,432
1 vote
1 answer
64 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 ...
NeoZoom.lua's user avatar
  • 1,432
1 vote
2 answers
54 views

Set mappings dependent of file type

To execute and debug different kind of programs, I mapped the function keys in the .vimrc-file. E.g. " save and execute perl :noremap <F5> :w<CR>:!./%<CR> " save and ...
Andy A.'s user avatar
  • 233
1 vote
1 answer
109 views

Detect line endings in current buffer, substitute all line endings depending on result

In GVIM, I'd like to save the current file with either \r\n or \n line endings. Depending on the opened file, the appropriate line endings should be chosen automatically. I had a look at https://unix....
Lvn's user avatar
  • 13
1 vote
1 answer
115 views

BufDelete running after window is closed

For some reason, the BufDelete autocommand is being executed right after a window is created, instead before, and i think it shouldn't be like that, according to the docs: Before deleting a buffer ...
henriquehbr's user avatar
1 vote
1 answer
717 views

Tab page is closing when deleting buffer

I'm using bufferline.nvim in order to display both buffers and tab pages on the tabline, whenever i delete a buffer with bd, all the buffers on that tab page are deleted as well, alongisde with the ...
henriquehbr's user avatar
1 vote
1 answer
74 views

Echo filename before deleting buffer

I would like to echo the filename before deleting any buffer (:bd, :q). I wanted to achieve this by using auto-commands like this: augroup DummyCodeGroup autocmd! autocmd BufDelete * lua print(...
Gabe's user avatar
  • 113
1 vote
1 answer
502 views

Can you turn a popup into a regular buffer?

I have a popup / floating window open which is normally used for temporary jobs, like searching the code or opening a quick REPL. Is it possible to turn that into a regular buffer? While I have it ...
TamaMcGlinn's user avatar
1 vote
1 answer
238 views

Vimtex: `latexmk` compiler gives "no file name specified" error even after a new buffer is written to a file

When I open a new instance of vim without any 'filename' argument and write some LaTeX code, I cannot just compile it to pdf with latexmk, because it needs a file to compile from. However, even after ...
The Footprint's user avatar
1 vote
1 answer
91 views

Forcing integrated terminal to scroll down after relayed command

I have a plugin which integrates a terminal that I can send commands through using a custom command I made. The only issue I'm having is that sometimes after the terminal gets clogged, it tends not to ...
daedsidog's user avatar
  • 153
1 vote
1 answer
141 views

Copy lines and execute in terminal window

Edit a python file with vim adddf.py, and type vert term and python3, there are two windows in vim. cat adddf.py def add_df(df,number): import re new_df = pd.DataFrame() nrow = df.shape[0] ...
showkey's user avatar
  • 1,130
1 vote
1 answer
52 views

Buffer opened when compiling succeeds

I am writing a vim plugin for the fortran filetype. In an autoload script, I have done: " File Name: autoload/makes.vim let s:Compiler = get(g:, "fortran_compiler", "gfortran"...
BaRud's user avatar
  • 481
1 vote
1 answer
2k views

Commands to write text to a buffer

I'm writing a plugin that often needs to write text to specific buffers. My current solution is to make the script execute normal commands that open a split with the buffer, write the text and then ...
user avatar
1 vote
2 answers
484 views

Buffer list per window

How could I get something like a buffer/argument list or a filter for individual windows, with a chosen subset of the buffers? So I could have a window just for header files in C (files ending in .h)...
vvv's user avatar
  • 53
1 vote
1 answer
61 views

How to close file/buffer/tab after cerain time of inactivity?

Is there a way to close file after certain amount of time of user inactivity? Lets say I have a encrypted file and I want to close it after 10 min. Is it possible in Vim?
lluke's user avatar
  • 219
1 vote
1 answer
271 views

Ignore some files when using viminfo+=%

I use in my vimrc the following option: set viminfo+=% This allows vim to open the last edited files if you don't pass any arguments to vim. Is there a way to ignore some files? I want to disable ...
matt's user avatar
  • 113
1 vote
1 answer
716 views

Apply templates when new file created

I have a file template which is rendered with replacing some stubs when new file created: augroup templates autocmd! autocmd BufNewFile *.java $r ~/.vim/templates/skeleton.java|call s:...
g4s8's user avatar
  • 223
1 vote
1 answer
508 views

Last buffer order

I usually open files one in a single vim application. Occasionally, I open multiple files at once to fix some mistakes in batch, for example, after static analyzer. If I was edited files in the ...
Eir Nym's user avatar
  • 111
1 vote
1 answer
1k views

VIM: bufnr("%") not matching number from :buffers for NERDTree buffers

I am using NERDTree to open files. If I am on a file path in vim and I hit gf this works fine for files. For folders, gf opens a new NERDTree buffer in this folder which is fine. I can then choose a ...
Timmi's user avatar
  • 11
1 vote
2 answers
318 views

Overwrite buffer with system clipboard by ex command

I'm trying to find the right ex command to overwrite the current vim buffer with the system clipboard. The relevant system clipboard register is "+ in this case. My first guess was to use :%+p; i.e. ...
Mussé Redi's user avatar
1 vote
1 answer
281 views

How to write a buffer which isn't the current to a temp file?

I would like to write a buffer which isn't the current buffer to a temp file. I have found two ways to do this: (assuming buffer 42 is the one to be written) Either use writefile(): call writefile(...
Andy Stewart's user avatar
  • 1,349
1 vote
1 answer
373 views

Is there a way to lock a buffer from changing?

I have NERDTree open all the time and sometimes I forget I have my cursor in there and I try to switch my main window to another buffer and it switched the NERDTree one, which get super annoying after ...
Joff's user avatar
  • 165
1 vote
1 answer
207 views

I don't understand the purpose and behavior of options "local to a window"

I don't understand the purpose of options that are "local to a window", such as for example colorcolumn and how they behave. This is a sequence to demonstrate what I mean: I start gvim. An empty, ...
René Nyffenegger's user avatar
1 vote
0 answers
40 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?
user22476690's user avatar

1
5
6
7 8 9