Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

Questions tagged [buffers]

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

Filter by
Sorted by
Tagged with
0 votes
0 answers
22 views

How to split view all buffers in vim with equal distribution vertical horizontal

How can I split view all buffers in vim with a distribution between vertical and horizontal? Is there a plugin? I know how to make all buffers appear in either horizontal or vertical splits: :ball :...
user avatar
  • 11
2 votes
2 answers
28 views

Opening files in insert mode

How do I make vim open files in insert mode? I've got the line "startinsert" in my .vimrc, and it does what it's supposed to (vim opens in insert mode), but when I open another file it opens ...
user avatar
  • 21
0 votes
0 answers
22 views

A counterpart for BufUnload,BufDelete event but gets fired after a buffer is unloaded

I've defined an autocommand that essentially checks for the remaining buffers' filetype, and for now by relying on BufUnload or BufDelete, the unloaded buffer still gets detected as being present at ...
user avatar
0 votes
1 answer
31 views

Buffer not reloaded after external command? [duplicate]

My buffer is able to reload every time I pull changes from the remote, with: autocmd FocusGained,BufEnter,CursorHold,CursorHoldI * if mode() != 'c' | checktime | endif autocmd FileChangedShellPost * ...
user avatar
0 votes
2 answers
40 views

How to yank the filename of specific buffer?

Is there a (simple) way to yank the filename of specific buffer in insert mode? For example, in insert mode, Ctrl+R % gives the name from current buffer, Ctrl+R # gives the alt one, but what about an ...
user avatar
  • 85
0 votes
2 answers
41 views

How to execute a shell command with the current buffer content and open a new split buffer with the command output?

I have an external command which accepts a SQL. I want to execute it within vim while editing SQL. I found two ways but both are not very satisfying. :w !<cmd> This passes the content of the ...
user avatar
  • 103
0 votes
2 answers
58 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 ...
user avatar
1 vote
0 answers
27 views

How to customize how neovims "shell command buffer" is shown?

I am wondering about the behavior of the buffer that appears in the bottom of the terminal when running a shell command in neovim. How can I make it appear the right side instead? How can I make the ...
user avatar
  • 123
1 vote
2 answers
35 views

How can I open python output in a editable buffer?

I am using this in my vimrc, to get output of current script printed on the screen when I click enter. autocmd FileType python map <buffer> <CR> :w<CR>:!python3 %<CR> How can ...
user avatar
  • 123
1 vote
1 answer
34 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 ...
user avatar
  • 131
2 votes
1 answer
194 views

What's the difference between `BufWinEnter` and `BufEnter`?

I need an example to differentiate the two events in Vim, as I'm having a hard time understanding them.
user avatar
  • 731
1 vote
1 answer
33 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 ...
user avatar
1 vote
1 answer
195 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?
user avatar
3 votes
1 answer
290 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 ...
user avatar
  • 133
0 votes
0 answers
22 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.
user avatar
  • 254
1 vote
1 answer
81 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 ...
user avatar
1 vote
1 answer
51 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(...
user avatar
  • 113
1 vote
0 answers
20 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 ...
user avatar
  • 133
3 votes
1 answer
92 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 ...
user avatar
0 votes
0 answers
22 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 ...
user avatar
0 votes
0 answers
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 ...
user avatar
1 vote
1 answer
52 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 ?
user avatar
0 votes
1 answer
81 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 ...
user avatar
1 vote
2 answers
72 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 ...
user avatar
1 vote
1 answer
95 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 ...
user avatar
  • 155
0 votes
2 answers
47 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 ...
user avatar
0 votes
1 answer
15 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 ...
user avatar
  • 485
0 votes
0 answers
22 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 :...
user avatar
  • 133
1 vote
3 answers
234 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/...
user avatar
  • 229
1 vote
1 answer
52 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 ...
user avatar
  • 371
1 vote
0 answers
54 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 ...
user avatar
  • 11
1 vote
1 answer
56 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 ...
user avatar
2 votes
0 answers
106 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 ...
user avatar
0 votes
1 answer
58 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 ...
user avatar
0 votes
0 answers
79 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 ...
user avatar
  • 3,081
2 votes
2 answers
79 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 ...
user avatar
  • 33
0 votes
0 answers
205 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 ...
user avatar
  • 139
1 vote
2 answers
64 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 ...
user avatar
  • 223
0 votes
0 answers
31 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 ...
user avatar
0 votes
1 answer
126 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 ...
user avatar
  • 375
1 vote
1 answer
41 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, ...
user avatar
1 vote
1 answer
48 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 ...
user avatar
  • 375
0 votes
1 answer
34 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 (...
user avatar
0 votes
2 answers
86 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 / ...
user avatar
  • 3
1 vote
1 answer
195 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 ...
user avatar
0 votes
1 answer
112 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 ...
user avatar
  • 731
2 votes
1 answer
65 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 ...
user avatar
1 vote
2 answers
239 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 ...
user avatar
1 vote
1 answer
100 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. ...
user avatar
1 vote
1 answer
126 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 ...
user avatar

1
2 3 4 5
8