Questions tagged [buffers]

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

Filter by
Sorted by
Tagged with
1
vote
1answer
70 views

VIM error: WARNING: The file has been changed since reading it!!! How to view the changes VIM is complaining about?

Is there a quick way to see the differences VIM is describing?
3
votes
1answer
26 views

How to use NerdTree to automatic focus on the current opened file position when toggle it on?

When use vim with nerdtree, I opened a file in a project. Press <Leader> key to trigger NERDTreeToggle. On the left side it will list the whole project directory by default. I want to let it ...
0
votes
0answers
16 views

How to add new command to a buffer by buffer number

-buffer flag in :command adds a command to the current buffer but how can I add command to a buffer by a given buffer number.
1
vote
1answer
19 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 ...
1
vote
1answer
41 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(...
1
vote
0answers
13 views

Macro doesn't run properly when executed with :bufdo or :argdo

I have a macro that looks like: :reg a Type Name Content c "a /^where^MkV%yGo^M-- Some typing...:^[pVG:!/tmp/t.sh^M It works fine from any starting position in the file when I replay it ...
3
votes
1answer
63 views

Can not move to other buffers unless I save the current one

I launch vim with two files. I can move from one file to the other by :bp or :bn quite happily. But as soon as I make a change to file1 it won't allow me to move to the other buffer unless I save the ...
0
votes
0answers
19 views

After opening all args with :ba, go back to a single split

Generally when opening more than two or three files in vim, I use a single split, navigating between the files/buffers with :n/:N. Sometimes, however, I want to open all of them in visible splits at ...
0
votes
0answers
22 views

What is happening that the cursor is moved back to line 1 when my first line starts with a number?

Once in a while, I have a file which somehow forces the cursor to line 1 when I switch back to it with Ctrl-^. So, I load 2 or more files, and one of the file starts with the following: 1. blah ...
1
vote
1answer
21 views

How to glob the buffer-list?

Having a command: command! -nargs=+ Foo call s:my_fun(<f-args>) How can I get a glob-match when user say: Foo *met*.c ?
0
votes
1answer
63 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
2answers
51 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
1answer
60 views

argdo vs bufdo for project-wide search and replace in specific folders

I have the following structure: myproject ----src file1.cpp, ..., file10.cpp ----include incl1.h, ..., incl10.h ----data data1.txt, ..., data10.txt I would like to ...
0
votes
2answers
38 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 ...
0
votes
1answer
11 views

Sort quickfix entries by most relevant files?

I have a project that has a lot of warnings. I'm wondering (until I fix all the errors) how I can make my quickfix results more relevant? My compiler script uses %t so it can differentiate errors from ...
0
votes
0answers
12 views

GoToDefinition used to show result in a split window, but now uses buffer

I have this mapping in my .vimrc: nnoremap gd :YcmCompleter GoToDefinitionElseDeclaration nnoremap gf :tab split \| YcmCompleter GoToDefinition<CR> When I press gd, it writes the command :...
1
vote
3answers
211 views

Can I open a file using the index shown by ":scriptnames"?

I am wondering how to open a file or load it into a buffer using the index shown by :scriptnames? 23: /usr/share/vim/vim80/plugin/tarPlugin.vim 24: /usr/share/vim/vim80/plugin/tohtml.vim 25: /usr/...
1
vote
1answer
48 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 ...
1
vote
0answers
29 views

How can I track the event of opening a file in netrw in an autocommand?

I'm trying to solve this problem by creating an autocommand which will track when a new buffer is opened through netrw, and will then immediately close netrw once the buffer is closed. How can I track ...
1
vote
1answer
47 views

Vim splits the window horizontally whenever i switch between buffers if i didn't get the data written to the disk first

I currently use ctrlp to navigate between buffers in vim , but whenever i try to switch to another buffer it automatically splits the current window horizontally into two windows . In order to avoid ...
1
vote
0answers
61 views

How to sort the list of buffers

How to sort the list of buffers Vim displays on entering :b <Tab> by most recent? I'm used to the Spacemacs ordering, which displays buffer filenames in separate rows (vertically) in the order ...
0
votes
1answer
38 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
0answers
47 views

Display all the buffers in all the open vim Windows?

There's this really great feature in Firefox, where you can search all the open tabs by typing % and then typing what open tab you are searching for. Is it possible to do something similar to this ...
2
votes
2answers
68 views

Making functions react to keypress

Im very new to vim scripting. I have the following script in my .vimrc: If there is no user input aka I press <CR> => go to recent buffer If input is 'd' => delete all buffers except for ...
0
votes
0answers
90 views

What's the best way to auto hide a custom bufferline when there is only one buffer listed?

this is gonna be a lengthy question. I'm developing a neovim bufferline plugin which shows a list of all the buffers in the tabline. I'm trying to implement a auto-hide feature, where the bufferline ...
1
vote
2answers
60 views

Open buffer without loading ftplugins

I have huge file and quite slow plugin (loaded by vim-plug) for corresponding filetype. I want following: Plugin is loaded by default Option to fast open this file without loading plugin. Something ...
0
votes
0answers
29 views

Measurement/ tracking the time for editing a file (overall and statistics)

I use vim for coding and also for writing scientific articles and book chapters. It would be very interesting to know the time I spent on a file. For example how many hours or minutes the buffer was ...
0
votes
1answer
56 views

Select buffer from list of buffers filtered by a partial name match?

Let's say I entered a folder with many files and I opened them with vim *. I know that if I want to list all the files inside the buffer I can use the command :ls, and then I can navigate those files ...
1
vote
1answer
35 views

Why does Vim load buffers from old session when new one is started?

The situation is this: I have 2 sessions: s1.vim and s2.vim. First one was saved with files A, B, C in buffers list. Second one was saved with file A. Next I start vim: vim -S s1.vim. :ls shows A, B, ...
1
vote
1answer
35 views

Is there any way of editing multiple files in a buffer at once?

Let's say I have 10 files inside a folder and I open them all with vim *. All those files will be opened in the buffer. Many times when I want to edit all of them at once, I create a small macro that ...
0
votes
1answer
28 views

How to avoid :bnext cycling back to the first buffer? [duplicate]

I like using Vim for presentations, and I use :bnext and :bprev to switch between buffers, where each buffer contains the data for a slide. One annoyance however is that :bnext on the last buffer (...
0
votes
2answers
57 views

Where are buffer level variables stored in Vim? And how to get their RAM / storage usage?

Where does Vim store b: buffer level variables / dictionaries? RAM or some kind of file on a disk? If it stores it in RAM, how to get an estimate of RAM / storage used by a particular variable / ...
1
vote
1answer
106 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 ...
0
votes
1answer
64 views

Useful script to manage buffer and window?

Given the scenario: 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 ...
2
votes
1answer
53 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 ...
1
vote
2answers
175 views

Limit `:bufdo` to only visible/active buffers

Working on a larger project, I tend to switch from topic to topic using git. Some times I want to run a command on all the buffers that are related to the topic at hand. I can do a :bufdo, but this ...
1
vote
1answer
41 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. ...
1
vote
1answer
96 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 ...
0
votes
1answer
54 views

How to implement an autocommand that deletes a buffer when it's being hidden and when it hasn't been modified in the last N seconds?

I'm trying to implement a simple autocommand, which deletes a buffer when it's hidden, with a condition that the file hasn't been modified in the last N seconds. I have the following code in ~/.vim/...
3
votes
1answer
49 views

Buffers that are neither active nor hidden

Both :ls and :buffers display a list with buffer information, giving indicators for each buffer. For example, # means the alternate buffer, and % means the current buffer. The meaning of each ...
1
vote
1answer
32 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 ...
0
votes
2answers
39 views

Automatically resize window based on filetype

I have a nifty autocommand in my vimrc that automatically maximizes any :help window: augroup LargeHelpWindow autocmd! autocmd BufWinEnter * if &l:buftype ==# 'help' | wincmd _ | endif ...
0
votes
2answers
103 views

Append a line after matched multiline pattern

i want to run this global command : /3)\(.*\n\?.*\)\{1,10\};;/ which matches multlines. I want to append a line after the matched block(of lines) across multiple buffers. I don't know where to begin ...
0
votes
2answers
32 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>\> ...
0
votes
1answer
48 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() ...
1
vote
1answer
45 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] ...
2
votes
1answer
31 views

Options readonly vs nowrite

Apologies if this is duplicate. I have searched and haven't found any related questions. What is the difference between the options readonly and nowrite? The reference manual says: readonly: If on, ...
1
vote
1answer
195 views

W11: File has changed since editing started

When a file is changed (e.g. by checking out another git branch), and i reload it with :bufdo e, I get the message W11: Warning: File "foo.bar" has changed since editing started See ":...
2
votes
1answer
111 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
151 views

Periodic W11 "File has changed" warnings when reading file

I'm on Archlinux with vim 8.2.2380. Since running updates yesterday, I'm getting W11 warnings periodically just by having a file open in a buffer which has changed on the FS (e.g. when opening log ...

1
2 3 4 5
8