Questions tagged [buffers]

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

Filter by
Sorted by
Tagged with
18
votes
6answers
11k 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 ...
2
votes
1answer
287 views

Set window-local option in every buffer/window

How do you set a window-local option (number) in literally every window/buffer? I was to bind <leader>t to toggle the number option in every buffer, using a global variable g:linum_status as ...
0
votes
1answer
694 views

vim: count how many buffers been modified?

Pursuing a vimscript function or expression that count how many buffers been modified. i.e., how many buffers :bm could switch to, given that option hidden is set. == Edit == In the hope of used ...
4
votes
2answers
326 views

How to escape from file browsing mode?

I just found out that we can use :e . to enter the browsing mode and then can choose file what we like. But I don't know how to get back to already opened file without choosing it again. I tried &...
0
votes
1answer
189 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?
0
votes
2answers
152 views

how to go back and forth in the view stack in vi

I'm not sure if I'm asking this right (I think this is a buffer thing?) so here is the scenario (in gherkin) As a vim user, i would like to use the silver searcher to search for files which have ...
7
votes
1answer
2k views

How to share the same buffer between multiple vim instances

I work with two displays. I usually open one instance of Vim in display #1 (let's call it Vim #1), which over time ends up having an open buffer for nearly every file in a project. Now I want to ...
6
votes
1answer
2k views

BufWinLeave * mkview with unnamed file: Error 32

Following this good piece of advice, I have added these lines to my .vimrc. augroup AutoSaveFolds autocmd! autocmd BufWinLeave * mkview autocmd BufWinEnter * silent loadview augroup END It ...
6
votes
2answers
924 views

Limit buffer list to current tab

Is there a way to list the buffers specific to the tab that is open currently in vim or macvim?
5
votes
2answers
865 views

Which buffer quickfix file is opened in?

One thing that drives me crazy is unpredictable quickfix behaviour. Say I am editing a file, then I split the window and would like to find something and open in that buffer. I use :Ag whatever to ...
0
votes
1answer
392 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 ...
3
votes
1answer
1k views

autocmd BufAdd/BufCreate/BufNew aren't triggered for new, unnamed buffers (`:enew`)?

I'm trying to set up an autocommand so that new, unnamed buffers are created with ft=markdown. Someone on SO suggested the following: autocmd BufEnter * if &filetype == "" | setlocal ft=markdown |...
5
votes
2answers
290 views

Is there a direct way to select the buffer displayed in a non-active window?

I usually have two windows open, one in which I'm working and one in which I'm viewing some information (compiler messages, relevant library headers, etc. etc.). Now, it's easy to switch the buffer on ...
0
votes
1answer
179 views

Do not reopen buffers of last session

When Vim starts, it always opens buffers of last session too. That is to say, when I leave Vim by closing all windows, but do not explicitly close buffers (by :bd), those buffers will be opened next ...
2
votes
1answer
195 views

Multiple buffers of the same file

I ran into a problem when using the quickfix feature of vim. When I open up my source file in vim, a buffer of that file is created, and its name is shown on the status bar, let's say main.cpp. Then ...
0
votes
1answer
328 views

Jump to specific character after cursor

What I want to do is jump to the first instance of character < X > after the cursor. I already know how to achieve this on the current line, but I was wondering if there was a way to apply this to ...
4
votes
2answers
218 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 ...
3
votes
1answer
242 views

How to feed visual selection into ex?

Is it possible to select the text of a command from a buffer in visual mode and then feed it to ex? Like so I can modify the text of the command in the buffer and then after I press some keys have it ...
3
votes
1answer
1k views

How can I open a temporary file so that I don't get E37: No write since last change?

I have a script which performs some action and then pipes the stdout to Neovim so that I can look at it with syntax highlighting and do all the other nice things I can do with vim. However, as this ...
2
votes
1answer
454 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 ...
0
votes
1answer
252 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 ...
2
votes
1answer
574 views

Get cursor position in all buffers

The line("."), command gets the line in the current buffer. Whats the command to get line in an arbitrary buffer, using buffer numbers?
-1
votes
1answer
49 views

Pass from one buffer to another quicly [duplicate]

I would like to pass from one buffer to another as in this website. Could anyone have an idea how to do such thing? I fact, to open a new window, I use vnew, and to change the buffer I use either :bn, ...
1
vote
0answers
43 views

Search local to buffer [duplicate]

I'm often searching elements inside the buffer to have a visual indication where in lines the 'text' exists but that overrides the search for all buffers. Is there an option to make it local to ...
3
votes
2answers
2k views

set backupcopy=yes doesn't still writes the file twice

I'm trying to understand and eventually fix the following behavior: when I save a file using VIM, it triggers the change/write event twice. I'm using Ubuntu 16.10, and I created an empty .vimrc file ...
0
votes
0answers
45 views

Turning on syntax highlighting for test script output to new buffer

I'm using a plugin, bexec, to execute a test script. The plugin opens up a new buffer to the right of my code and it displays the output of the test script: I would like to have syntax highlighting ...
3
votes
1answer
321 views

What is the point of <buffer> in autocmds?

I know that the buffer is the window you're currently working in (or at least that's what I think it is), but why should I use buffer when scripting :autocmd? For example: autocmd FileType cpp,...
6
votes
3answers
4k views

make nerdtree buffer consistent

I like how nerdtree looks as a side-drawer. but if I close current buffer using :bd nerdtree will become a fullscreen buffer and all new buffers will simply take full screen, nerdtree won't toggle ...
16
votes
4answers
12k 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.
4
votes
2answers
800 views

vim sometimes displays full path of file instead of just the filename?

This may seem a little nit-picky, but I like using the wildmenu to switch between buffers: I do :b and then hit tab until I get to the file I want. The problem is that sometimes, vim shows the entire ...
3
votes
0answers
62 views

Persisting unsaved changes to untitled buffers in a session [duplicate]

Sublime Text has a killer feature I'd really like to get working in Vim. It's pretty much the only reason why I can't drop it in favor of Vim yet. The feature is that Sublime remembers unsaved ...
1
vote
1answer
382 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?
2
votes
1answer
614 views

Buffers are left even when `nohidden` is set

I have explictly said in my vimrc that I want nohidden behaviour (I am jumping between files a lot, with long lasting session, and after some time buffers list is very polluted). However when I jump ...
0
votes
2answers
786 views

Switch between header and source files in one buffer

I am currently using vim-altr to switch between head and source file in c++. I use nmap <F2> <Plug>(altr-forward) nmap <F3> <Plug>(altr-back) to move between buffer. However,...
0
votes
1answer
93 views

How to prevent Vim from clearing history?

Is there way to prevent Vim from clearing history after exiting Vim? I want to be able to see the changes I made, while I am using Gundo (or UndoTree), even though I quit vim and the terminal and ...
9
votes
2answers
959 views

Force buffers to always open with vertical split

When I open a new buffer I usually just do :vsp something which allows me to open a new buffer with a vertical split. However, when I don't control how the buffer should be opened (e.g. when typing :...
1
vote
1answer
394 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 ...
12
votes
1answer
967 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 ...
3
votes
1answer
832 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 ...
5
votes
2answers
155 views

How to replace buffer with a search range selection?

I'd like to replace the entire buffer (file) with the current search range selection: :/pattern1/;,/pattern2/p How this can be achieved?
3
votes
1answer
285 views

Run macro between buffers

I know there is a possibility to run a macro in multiple buffers using bufdo. However, what I'm not aware, if there is somehow to use a "intercommunicated macro", e.g: File 1: foo bar bun File 2: ...
12
votes
2answers
3k 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 ...
1
vote
1answer
131 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, ...
4
votes
1answer
816 views

Strange behavior between autochdir and netrw

This has been plaguing me for a while now, but I've only just recently been able to come up with an MCVE. The problem is that when autochdir is on and I use :Explore to open netrw sometimes it will ...
7
votes
1answer
281 views

Improving alternate-file behavior to avoid reopening deleted buffers?

Lured in by the promise of evil-mode, I've been moonlighting in Emacs. It's a wild world with a mix of hairy lose-ends and astoundingly smart features. One feature I really like is a command called ...
10
votes
1answer
7k views

How to open same file in multiple buffers

Is it possible, in one instance of VIM, to open one file in few buffers and edit them independently?
3
votes
1answer
373 views

Externally query a vim server to list the open buffers in it

I'm on linux and I'm querying the list of files open in a gvim server so I can pull it up with gvim --servername <name> --remote <file> To do so, I wrote a helper function that returns ...
1
vote
1answer
1k views

Unmap locally a mapping from .vimrc

Let's say I have the following line in my .vimrc: noremap ge w Sometimes I want to unmap it locally to the current buffer, so I run: :unmap <buffer> ge. When I do this, I get an error message ...
0
votes
0answers
95 views

Vim to behave like nvi when opening line in empty buffer

I want to Vim to behave like nvi when opening a in an empty buffer. This is an empty buffer: ---------------------------------------- ~ ~ ~ ~ ---------------------------------------- After typing ...
1
vote
1answer
76 views

Saving object state between foldlevel calls

I am trying to implement a custom folding function in a way that precomputes all the folds in a single pass and then reports the required foldlevels as needed. To do so, I use a single dictionary that ...

1
4
5
6 7 8