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
199 views

How to clear all contents of a file

To clear a file I find myself doing something like: 1G 1000cc (or some large number) Is there a simpler way to do this for clearing a file? On a normal text editor I normally would do Cmd-A and then ...
1
vote
1answer
912 views

Automatically call matchadd() in every new window without producing duplicate entries

I started off with the following line in my vimrc: call matchadd(...) This applies a highlight to the current window. However, if I split a new window, that window will not have the highlight ...
1
vote
2answers
290 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 I ...
1
vote
1answer
996 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 ...
1
vote
1answer
237 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 ...
1
vote
1answer
49 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 ...
1
vote
1answer
34 views

Reading external file data at the end of the buffer

If I am in the middle of the buffer and want to append external file data to the current buffer. So far I move to end of the file with G and reading the data :r file so it is doing the work ...... Is ...
1
vote
1answer
32 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 ...
1
vote
2answers
474 views

How to set read only for only one buffer

I'm using vim with some plugins, such as Nerdtree, YCM, to build an coding environment. Now I want to achieve this: When I execute the command vim, a file containing some ASCII image, will be loaded ...
1
vote
1answer
299 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 ...
1
vote
2answers
414 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 ...
1
vote
2answers
53 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 ...
1
vote
1answer
73 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. ...
1
vote
1answer
114 views

How to get neighboring buffer numbers

Lets pretend I have a Vim session with buffers that look like this: +-------------+--------------+ | | | | | | | | | | ...
1
vote
1answer
168 views

MiniBufExpl: List buffers by window

Is there anyway to get MiniBufExpl to only list the buffers that belongs to the active window?
1
vote
1answer
272 views

navigating multiple files - arguments and buffers

I've been learning vi (as an autodidact) for some weeks. Actually I'm not yet sure about if I'm using vi or vim (does the command vi open vim if vim is installed?). Now I'm trying to edite multiple ...
1
vote
1answer
44 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 ...
1
vote
2answers
59 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 ...
1
vote
1answer
19 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. ...
1
vote
1answer
68 views

How to recursively open all files except ones in hidden directories from within vim?

In my python project root folder, there are multiple directories, some of which contain hidden sub-directories specifying python virtual environments. I want to open all my python files recursively ...
1
vote
1answer
114 views

Pipe :Ag output to a new buffer

I'd like to search for a regex using Ag. This results in more than 1000 findings. I'd like to save these findings in a buffer to be able to go through them slowly
1
vote
2answers
75 views

How to properly catch errors when running scripts on buffers?

I am trying to write a function to lint buffers in neovim. It seems that the usual recommendation for achieving such a thing is to run the command over the entire range (ie %!lint). This is however, ...
1
vote
1answer
170 views

open file in an hidden buffer

I want to open a file invisibly such that I can operate using normal (programmatic) commands on it. How can it be achieved? Preferably, it should be hidden from the beginning. Thanks
1
vote
1answer
334 views

Get current buffer (content) size in vim script

I'm using nvim v0.4.3 and am trying to apply some of the tricks + alpha (e.g. disabling substitution preview) to make editing large files faster. I want to do that even to unnamed buffers (i.e. ...
1
vote
1answer
107 views

How to make autowrite apply to :make but not to :buffer?

I have set autowrite so that :make automatically saved the file before running the build command. But now I'm increasingly using :buffer to switch between buffers, and have now noticed that it ...
1
vote
2answers
46 views

Close buffer in the other instance

When a file is being opened neovim warns that swap file already exists, at which point you can't safely open a file without first closing it in the other instance. I frequently have many projects ...
1
vote
1answer
39 views

How to open a new window and edit it in an automated fashion?

Consider the following function function! Exp() call feedkeys(":new ~/.vimrc\<CR>") call search('F') endfunction My expectation from Exp() was that if I call Exp() then 1) I see my ...
1
vote
2answers
261 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
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. ...
1
vote
1answer
387 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?
1
vote
1answer
415 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 ...
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 ...
1
vote
1answer
166 views

How do I delete/unset a buffer local option (such as autoread)?

In a new buffer, the expression &l:autoread evaluates to the value -1, indicating that the local option autoread has not yet been set with :setl autoread or :setl noautoread. When I set the local ...
1
vote
1answer
57 views

Why does g+ sometimes skip a leaf of the undo tree?

I'm trying to understand how to move in the undo tree with the following default mappings: u, <C-R>, g- and g+ Here's my understanding of things, which is probably wrong or incomplete. Each ...
1
vote
2answers
36 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 ...
1
vote
1answer
32 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, ...
1
vote
1answer
73 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 ...
1
vote
1answer
62 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 ...
1
vote
1answer
31 views

Forcing integrated terminal to scroll down after relayed command

I have a plugin which integrates a terminal that I can send commands through using a custom command I made. The only issue I'm having is that sometimes after the terminal gets clogged, it tends not to ...
1
vote
1answer
43 views

Copy lines and execute in terminal window

Edit a python file with vim adddf.py, and type vert term and python3, there are two windows in vim. cat adddf.py def add_df(df,number): import re new_df = pd.DataFrame() nrow = df.shape[0] ...
1
vote
1answer
121 views

W11: File has changed since editing started

When a file is changed (e.g. by checking out another git branch), and i reload it with :bufdo e, I get the message W11: Warning: File "foo.bar" has changed since editing started See ":...
1
vote
1answer
120 views

Periodic W11 "File has changed" warnings when reading file

I'm on Archlinux with vim 8.2.2380. Since running updates yesterday, I'm getting W11 warnings periodically just by having a file open in a buffer which has changed on the FS (e.g. when opening log ...
1
vote
1answer
41 views

Buffer opened when compiling succeeds

I am writing a vim plugin for the fortran filetype. In an autoload script, I have done: " File Name: autoload/makes.vim let s:Compiler = get(g:, "fortran_compiler", "gfortran"...
1
vote
1answer
445 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
407 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 ...
1
vote
1answer
30 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?
1
vote
1answer
112 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
1answer
459 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:...
1
vote
1answer
261 views

Last buffer order

I usually open files one in a single vim application. Occasionally, I open multiple files at once to fix some mistakes in batch, for example, after static analyzer. If I was edited files in the ...
1
vote
1answer
501 views

VIM: bufnr("%") not matching number from :buffers for NERDTree buffers

I am using NERDTree to open files. If I am on a file path in vim and I hit gf this works fine for files. For folders, gf opens a new NERDTree buffer in this folder which is fine. I can then choose a ...

1
4
5
6 7 8