We’re rewarding the question askers & reputations are being recalculated! Read more.

Questions tagged [buffers]

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

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

Make a buffer active by its number

I'm configuring a terminal buffer and now I have the following problem. I have only one terminal buffer and I need to make it active by its number to avoid lots of CTRL-w j/k/l clicks. Here is what ...
0
votes
0answers
24 views

search highlighting only in the current buffer

I know that I can run a search in vim using /. I prefer having search highlighting turned on, but if I have a two splits with different files open, and I search for a term in one, they get highlighted ...
0
votes
2answers
32 views

Save buffer before opening new file

When I'm in a modified buffer and try to open a file using :e otherFile I get E37: No write since last change (add ! to override) Since this happens fairly often, I'd like to automatically save ...
2
votes
3answers
94 views

How can substitute() operate on a whole buffer?

In normal usage :%s/A/B/g is a simple way to substitute a pattern across the entire buffer. However the command mode implementation of :substitute is subject to many user configurable variables and as ...
1
vote
1answer
30 views

How do you read the contents of a macro into your buffer?

I know that you can use let @x = @w to copy the contents of a macro from one register to another, but how do you read the contents of your macro register into the buffer?
1
vote
2answers
39 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 ...
0
votes
0answers
14 views

buffer name of opened directory in netrw disappears sometimes

I usually open a directory in vim with command :e path-of-dir. Because the plugin Netrw is included by default, this will be taken over by it and a netrw window will open with the content of the dir. ...
0
votes
1answer
27 views

Permit closing window with unsaved changes using vim setting

I wrote a plugin that executes a slow shell script and asynchronously shows the stdout in a popup (split) window. When I try to close my session while the popup is open, I get the message Save ...
1
vote
2answers
80 views

What is the difference between loaded and unloaded buffers?

I was looking at the documentation for the 'complete' option, and I found it a bit confusing: . scan the current buffer ('wrapscan' is ignored) w scan buffers from other windows b scan other ...
0
votes
0answers
10 views

Deleting the temporary buffer created by Pymode

I'm using the python-mode plugin with automatic lint checking. I want an easier way to delete the temporary buffers used to show errors when I use :wa. Sometimes there are more than one. Now I'm ...
1
vote
3answers
32 views

vim : how to set current buffer to a string using `:python`

As example, my current buffer contains below lines di=01;34 ln=01;36 mh=00 pi=40;33 I want to join all lines with :, and set entire buffer to the joined string. How to achieve that, using :python ...
0
votes
1answer
40 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 " ...
2
votes
1answer
50 views

Everytime I call :Explore netrw creates a new unlisted buffer

Is there any way to stay always in the same netrw buffer after selecting a file to edit?
2
votes
1answer
45 views

Session - start with buffer 1

Note: Possible fixed bug. See comments. A somewhat minor nuisance, but as the pedantic for these things :P When saving and opening a Session file the Session.vim file does: badd +1 file1 badd +1 ...
2
votes
2answers
108 views

How do I list only modified buffers in vim?

Sometimes when there are a lot of buffers, it becomes hard to see which buffers have been modified using :ls.
1
vote
0answers
27 views

Random characters appear in my buffer but they are not part of the current file

I really don't know what details to give except for some screenshots and my vimrc file, I think it is because of a plugin but I am really not sure. Random characters just appear. Note that they are ...
1
vote
1answer
44 views

Make vim remember the fileformat of a buffer

I am using vim to view Spyder's Python comman history. I set to :e +=ff=dos to get rid of ^M at the end of each line. When I switch to another file, then switch back, the fileformat is unix again. ...
2
votes
1answer
27 views

fun with symlink and buffers

I have a funny problem. I have the following symlink in /Users/eyalkarni/ AKA ~ .vimrc -> /Users/eyalkarni/vimpy3/.vimrc vimpy3 is a git repository. I opened ~/.vimrc in neovim and now I can't ...
0
votes
0answers
63 views

How to recover file overwritten by vim

I used the command :Texplore to rename a file in vim's file explorer. I closed the buffer that read the old file name into memory, then opened the new file name using a new instance of vim only to ...
1
vote
0answers
32 views

Save :Man window in session

TL;DR: I want to persist :Man windows in sessions I am obsessed with sessions, and use tpope's vim-obsession for managing them. Coupled with a scripted tmux, sessions make for a perfect "quit, go ...
1
vote
2answers
32 views

Can I use syntax highlighting on an unwritten buffer?

I pasted some code into a new, unwritten buffer in Vim. I'd like to do some quick edits on the code without saving it to a file, but it hurts my eyes to look at code without syntax highlighting. Can ...
0
votes
1answer
57 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:...
3
votes
2answers
189 views

autocmd for the event: “the first time a buffer is entered”

I know that the autocommand autocmd BufEnter will be triggered every time a buffer is entered. Is there a way to define an autocmd that will be triggered only the first time a buffer is entered?
0
votes
0answers
37 views

Why is network latency becomes too long when edit in the sshfs mounted files

I mounted the remote server directory to my local machine mount point with sshfs. Thus I could use my local vim to edit my code, it is much faster than editing with the vim installed to the remote ...
0
votes
1answer
34 views

How to open same file in multiple window but with changes present only in one window?

I want to view the initial copy of the file in a separate window while I make changes to the same file in another window. Is this possible?
1
vote
0answers
29 views

How to pin a file to a window(/viewport)

When I have multiple files open in multiple splits, when I open a new file via quickfix ( or Ctrl-P ), it sometimes ends up placing the new file in a window that I don't want to be changed. Is there ...
0
votes
1answer
35 views

how to close a single window by mentioning filename opened in that window

I want to close a window by mentioning window name in command line. For example, let's assume I have opened 1.c, 2.c and 3.c in different windows in vim. Now i'm in 2.c and i want to close 3.c. Is ...
2
votes
0answers
37 views

Why does renaming with :saveas not open the new named file in the current buffer? [closed]

When editing a file named oldFile, with the command :saveas newFileName I expected vim to save the current buffer under the new named file (i.e. newFileName) and set the filename of the current buffer ...
0
votes
0answers
35 views

Open all but one buffer in a separate tab

I have following in my ~/.vimrc to make sure that nerdtree opens for every tab: autocmd VimEnter * NERDTree I also have this in the ~/.vimrc to make sure that every new buffer opens in its own tab: ...
1
vote
1answer
150 views

Creating a hidden buffer

I know that with commands like sbuffer you can create a new buffer and display it in a split window, and commands like enew can create a new buffer in the current window. But is it possible to not ...
0
votes
1answer
44 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:...
0
votes
0answers
690 views

How to display all buffer names in tabline?

How do I display the list of all buffers in the tabline? I am using the lightline plugin, with the following settings in my .vimrc: set showtabline=2 let g:lightline = { 'colorscheme': 'PaperColor' } ...
0
votes
1answer
43 views

how to make buffer bar longer, show the names of more buffers

Currently my buffer bar (I don't know if this is the right word) looks like this: Even though my terminal is super wide, it displays the names of only 4 buffers I have open and then an ellipsis (...) ...
3
votes
1answer
82 views

Skip the quickfix list when buffer switching using :bn

Often when editing LaTeX files, you are constantly switching between your .tex, .sty and .bib files which are often in their own buffer. To navigate between those, I use the :bn and :bp commands ...
2
votes
1answer
28 views

How can I set Vim to switch to a buffer after I add it?

TLDR: Can I make Vim automatically switch to the buffer that I just opened? Please tell me if I'm using Vim wrong in this case or something. I'm currently working with foo.txt. I want to look at ...
4
votes
2answers
87 views

Open new file while keeping the focus on the the current buffer

It is possible to open a new file with :edit or :tabnew but without jumping to that new buffer ?
3
votes
1answer
106 views

Is it possible to simultaneously edit one file in two views?

I've been using Vim regularly for a decade, but still feel rather inexperienced because there is so much of Vim that I am not aware of and do not use. I sometimes want to see two different parts of ...
0
votes
1answer
66 views

Copy text from one buffer to another using Vimscript

I need to process text line by line in one buffer and append the processed text to another buffer in Vimscript. I can do this by using buffer switching ex commands, but I suspect it will cause ...
2
votes
2answers
119 views

How to set group of tabs and 1 single terminal in Vim 8?

I am a Vim beginner. I know you can do :tabnew file1 file2 to have Vim open up a bunch of files name file1, file2 spread across as tabs. I know you can move forward and backward between tabs. My ...
0
votes
1answer
64 views

Why buffer tab plugin not work with Neovim 0.4

I installed the latest Neovim 0.4 from scratch, install 'vim-plug', then add only 4 lines to my init.vim: call plug#begin('d:/neovim/nvim/plugged') Plug 'ap/vim-buftabline' set hidden call plug#end() ...
0
votes
2answers
150 views

Shell running inside vim windows

Is there a way that a open up a window or buffer, where i can run my bash commands? I thought on something like you know it from VS Code(1). The code windows on the top and a small command prompt on ...
0
votes
0answers
57 views

How to properly organize persistence of the vim state of all opened buffers?

Before switching to vim years ago I was using Sublime Text and it perfectly handled situations when I just close it and open again. Nothing is lost and at the place where I left it off. So I'm aiming ...
0
votes
1answer
89 views

how to control the :bp / :bn files I loop?

I'm using :bp to re-open the previous file I worked on, and :bn to go back, but I'm stuck on a loop with 3 files, and I only want to loop over 2 of them. Is there a way to edit the buffer and pop the ...
0
votes
1answer
63 views

how to set shortcut for CtrlPBuffer, just like ctrl-p for CtrlP

question for CtrlP users I have ctrl-p mapped to open file from the filesystem. I want to map ctrl-y to open a buffer that is already opened. how should I change my vimrc? does anyone know? Thanks!
2
votes
0answers
58 views

display list of buffers `ls` without scrolling down

Is there a way to display output at the bottom of the screen like ls does, but without scrolling down to accomodate the output? The Vim Wiki (no https) has the following snippet :nnoremap <A-n>...
0
votes
0answers
45 views

Why does not Vi buffer operation "n (double quote) work in Vim?

I have read from a book that, vi allows the following commands: "ayy, which means yank the current line into buffer named a. "dP, which means paste the content in buffer named d before the cursor. ...
0
votes
1answer
17 views

Open a second file and quit the previously opened one without saving

If I do something like this: vim i # Write some tmp text # This tmp file served it's purpose, want to quit this one and open a new one :e newfile # E37: No write since last change (add ! to override) ...
4
votes
1answer
48 views

track deletion and insertion of lines

The marks in vim knows the deletion and insertion of lines before it and their positions will keep updated. Is there a way to achieve these pragmatically? I am running an async task which is ...
1
vote
3answers
126 views

edit many files in one buffer

I have enjoyed coding not too large projects in one single file. This way I can press * on an identifier and find it without having to hop across buffers. But naturally this doesn't scale and at some ...
1
vote
1answer
69 views

How to get neighboring buffer numbers

Lets pretend I have a Vim session with buffers that look like this: +-------------+--------------+ | | | | | | | | | | ...