Questions tagged [buffers]

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

Filter by
Sorted by
Tagged with
4
votes
1answer
275 views

Switch to viewport by name?

Typing :buffers gives a list of loaded buffers. Can I switch to a viewport that views one of those buffers by name? I know that :buffer NAME will load the named buffer in the current viewport. But I ...
6
votes
1answer
1k views

How to see if Vim has a file opened or not, or has a buffer open

Sometimes I want to open vim in preparation of opening a file in the directory tree. So i start it without a file: vim Then I use a map to open NERDTree: :NERDTreeFind<CR> This fails with ...
3
votes
1answer
769 views

Manipulate content of background (non-current) buffers from vimscript

Given some text stored in a variable, is it possible to write this text to an arbitrary buffer in the background? I ask about buffers specifically because I'm aware of writefile(), but I want to write ...
1
vote
1answer
2k views

Change buffer focus on enter?

I set up my .vimrc so that NERDTree automatically shows up on the left when opening vim for editing a file (autocmd VimEnter * NERDTree). This means, that NERDTree is the active buffer instead, and I ...
0
votes
1answer
76 views

How to add a fallback when :b buffer change fails

I have 2 ways to open a file for editing: :b <filename> to switch to an opened buffer -- imagine that I have a lot of folders containing index.html so by using :b I know I am working on the one ...
0
votes
1answer
486 views

How do I open a quickfix result in a new buffer?

When I have the quickfix window open (e.g. from :grep foo<cr>:cw) I can go to the window and hit Enter and it will open the file under the cursor in an existing buffer. Is there a way to open ...
2
votes
0answers
196 views

:q will not let me exit vim [closed]

When using nvi I have a file that I want to exit but everytime I use :q it just opens this thing and I can't exit out of it. Does anyone know what it is and how to get rid of it? Note: this is nvi ...
2
votes
1answer
164 views

How do I jump to the next search result in a different window?

Sometimes I have two windows open and I search for a word that appears in both. Hitting n only cycles through the results in the active window. It'd be really convenient to somehow jump to the next ...
0
votes
2answers
2k views

neovim: how to close the terminal buffer by just pressing enter?

NVIM v0.2.2 Build type: Release LuaJIT 2.0.5 Compilation: /usr/local/Homebrew/Library/Homebrew/shims/super/clang -Wconversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_MSGPACK_HAS_FLOAT32 -...
1
vote
1answer
144 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(...
1
vote
1answer
261 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 ...
0
votes
1answer
36 views

Is there a way to change the "current buffer"--the one that gets defined when I use "n" and "N"?

Once in a while I do work on a large number of files (i.e. today it was about 1,700) using a command such as: gvim `find . -name *.cpp` and I use the "n" (no changes) or "wn" (made a change) to go ...
0
votes
1answer
54 views

Don't reset vim tab to the beinning line

I have a question about tabs within vim and I'm using VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Jan 17 2018 20:33:56) Included patches: 1-1255 Compiled by _pbuild@amd64.ports.openbsd.org tab ...
2
votes
2answers
284 views

How to execute a bash command from the normal mode and send the output on a different buffer?

I have a bash_file that operates on a latex file to produce a pdf. #!/bin/bash /usr/bin/pandoc/ filein.md -t beamer -o fileout.md ; /usr/bin/pdflatex/ fileother.tex ; /usr/bin/evince fileother.tex ...
2
votes
1answer
1k views

Syntax highlighting gone when using buffer

At work I usually keep only a few files in buffer, typically a Yang file, a Java file, and possibly something like a readme file. In such an environment, the Yang syntax highlighting does not work. ...
3
votes
2answers
1k views

Close multiple buffers interactively

Is there a way to view a list of open buffers and close several buffers without leaving that list? The best I know of for closing multiple buffers is using :ls to get a list of buffers, memorizing ...
0
votes
2answers
124 views

Add new buffer after current one

How can I create a new buffer just after(next to) the one I am on ? Let say I have three buffers opened (1, 2, 3) and I am (my cursor) currently in buffer 1. If I add a new buffer (with :edit for ...
2
votes
1answer
872 views

Copy output of bash command to system clipboard?

If I run: :w !node It will take my current buffer and send it to stdin and run the code in node. If I run: :redir @+ | echo "bob" | redir END It ends up on the system clipboard. But if I want to ...
1
vote
0answers
577 views

vim + jq :: how to format possibly incorrect text in unsaved file [duplicate]

This is very similar to how-to-run-bash-command-over-current-file-and-replace-buffer-with-result But I need to know how I can access current buffer when the file does not exist? i.e. I open vim goto ...
3
votes
2answers
578 views

call function in context of buffer

How can I call a function in vimscript in the context of a specified buffer? For instance, line2byte works for the current buffer. I am implementing a callback, where I receive a buffer number as an ...
20
votes
6answers
13k 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
373 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
740 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 ...
5
votes
2answers
369 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
209 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
183 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 ...
8
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 ...
7
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 ...
7
votes
2answers
1k 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
984 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
435 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 ...
4
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
297 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
234 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
211 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
354 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 ...
5
votes
2answers
245 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
267 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
489 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
275 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
632 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
366 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 ...
17
votes
5answers
13k 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
889 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 ...

1
4
5
6 7 8