Questions tagged [buffers]

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

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

How to reload vim buffer

I built a cpp environment with YCM, EasyGrep and some other plugins. With YCM, I can jump to declaration/definition, with EasyGrep, I can grep a keyword easily. But I found something weird: Saying ...
1
vote
1answer
29 views

Commands to write text to a buffer

I'm writing a plugin that often needs to write text to specific buffers. My current solution is to make the script execute normal commands that open a split with the buffer, write the text and then ...
1
vote
2answers
21 views

How to close the netrw buffer/window from any other window

I would like to have the behavior where I can run :Vex<CR> when pressing <Tab> in normal mode: nnoremap <Tab> :Vex<CR> ... to open the netrw file tree window and then I would ...
2
votes
1answer
8 views

Can't exit buffer using leader mapping - 'cannot make changes'

I have a leader key set up, and a mapping that allows me to exit windows without typing :: let mapleader = 'f' map <leader>q = :q<CR> Today I installed MattesGroeger/vim-bookmarks using ...
0
votes
1answer
42 views

Updating buffer content from another buffer

I want to update one buffer content from another buffer periodically, for this I need to delete all lines from the target buffer firstly, then to write new lines to it. The number of lines are varying,...
2
votes
1answer
29 views

Saving setting to buffer

Is there a way to save the value of a setting to a buffer or a file? For example, when I type :set guifont It displays the setting I want to use but as soon as I start typing in the buffer it ...
1
vote
1answer
40 views

Buffer list per window

How could I get something like a buffer/argument list or a filter for individual windows, with a chosen subset of the buffers? So I could have a window just for header files in C (files ending in .h)...
1
vote
2answers
86 views

How to create a new tab or window from a buffer?

I have several open buffers and want to open a buffer in :ls in a new tab or window. I have found a way to do accomplish this, either by first executing tabnew or C-w v and then selecting the buffer ...
6
votes
1answer
59 views

How can I view the name of the swapfile being used for the current buffer?

Let's say I recovered a bunch of swapfiles in quick succession: gvim -r .swv gvim -r .swu gvim -r .swt And then cycled through them all a few times before finding that one of them was nonsense. I ...
2
votes
1answer
40 views

Auto updating for file content similar to tail -f

Is it possible to setup vim for auto updating on changing of file content? I think about working with logs that can extend if new event happened. What I expect is that vim will spot a file change and ...
1
vote
2answers
48 views

`a` append to buffer commands

Similar question, yet not duplicate of: How can I reload all buffers at once? If :wa writes all, would not :ea be expected to reload all? How could one script :ea to behave this way? What are the ...
2
votes
2answers
110 views

How do I make the h key go to prev tab if at start of file?

And, to get back again: how do I make the l key go to next tab, if at end of file? I'd also like to make hh go to previous buffer, and ll go to next buffer. I know that'll add a delay to recognising ...
3
votes
2answers
77 views

How can I ensure Vim doesn't quit entirely when the last window is closed, unless it's empty?

I'd like to mimic the behaviour of i.e. TextMate and VScode and friends, in a GUI-vim: "closing" the last actual-content-window simply leaves me with an empty Vim window, and then "closing" that is ...
0
votes
2answers
25 views

Appending multiple new lines to a buffer (instead of “^M”)

I'm trying to create a buffer for a specific purpose, and for that, I need to add newlines to it to get it to be the same height as my current window. My first idea, using call append("^", repeat("\r",...
2
votes
1answer
41 views

How can I access buffer variables from BufUnload/BufDelete?

vimdoc says: BufUnload Before unloading a buffer. ... NOTE: When this autocommand is executed, the current buffer "%" may be different from the buffer being unloaded "<afile>". Don't change ...
2
votes
2answers
124 views

map <leader>b<number> :b<number><cr>

I am using a convenient macro to list my buffers: map <leader>bb :buffers<cr> I am trying to come up with a way to then switch to the buffer of interest with <leader>b<number> ...
2
votes
2answers
76 views

Is there a way to list recent buffer history?

I just started using buffers in Vim and I couldn't figure out how to list recent closed buffers. Is there a simple way (like :ls) to list those? Are they actually stored by Vim? Maybe I'm misusing ...
1
vote
1answer
27 views

How to close file/buffer/tab after cerain time of inactivity?

Is there a way to close file after certain amount of time of user inactivity? Lets say I have a encrypted file and I want to close it after 10 min. Is it possible in Vim?
2
votes
1answer
116 views

Making terminal buffer unlisted

I'm configuring my scripts to work with terminal in VIM and have a question regarding :h special-buffers. Among mentioned kinds there were the following: unlisted The buffer is not in the buffer ...
1
vote
1answer
70 views

NERDTree is not displayed in buffer list

I'm currently exploring ways to iterate through all buffers in vim and am confused by the behavior of NERDTree. I displayed the NERDTree directory tree and expected that the viewport is bound to ...
2
votes
3answers
48 views

How can I prevent Vim from centering the line under the cursor on `:edit`

Each time I want to save my work while editing a text file, I enter :write to save the file, and :edit to reload the file, with the side effect of resetting the undo/redo buffer. However, an unwanted ...
1
vote
2answers
51 views

Write buffer list to file

I would like to have a file that contains all files that I opened with vim in the past. I know that there is the viminfo file but I want to have just a file with the filenames. For this I would like ...
1
vote
1answer
39 views

Ignore some files when using viminfo+=%

I use in my vimrc the following option: set viminfo+=% This allows vim to open the last edited files if you don't pass any arguments to vim. Is there a way to ignore some files? I want to disable ...
1
vote
2answers
63 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 ...
1
vote
1answer
77 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 ...
1
vote
2answers
62 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
127 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 ...
2
votes
1answer
44 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
48 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
21 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
35 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
133 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
14 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
66 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
51 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
109 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
69 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
129 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
47 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
47 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
43 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
113 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
35 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
52 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
139 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
286 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
62 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
35 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
37 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 ...

1
2 3 4 5 6