7

Cut out the middle man. If you want to edit a file in a split, use :split file.txt. It is the very nature of using <C-W>n that creates these new buffers. It's like using the :new command, which is wasteful if you plan to immediately edit some other file. If you like the visual confirmation of seeing the new window before editing the file, you could ...


5

Your function returns nothing, but you call it expecting the buffer number. This should work: function! ScratchBuffer() vnew setlocal nobuflisted buftype=nofile bufhidden=wipe noswapfile return bufnr('%') endfunction


4

I'm not aware that you can create a hidden unnamed buffer. But you can create a hidden (even unlisted) buffer with some fancy name and use that. In VimScript: let g:myscratch = bufnr("my-fancy-name", 1) call setbufvar(g:myscratch, "&buftype", "nofile") The first line returns the buffer number for the buffer named "my-fancy-name". If the buffer does ...


3

The 'hidden' setting The 'hidden'/'nohidden' setting tells Vim what to do about buffers that are "abandoned". 'hidden' means an abandoned buffer becomes hidden (similar :hide). 'nohidden' (the default) means the buffer is unloaded (:bunload). Both :bunload and :hide do not remove a buffer from the buffer list. Therefore 'hidden' setting will not affect ...


2

You want to add the following line to your vimrc: set hidden From :h 'hidden': 'hidden' 'hid' boolean (default off) global {not in Vi} When off a buffer is unloaded when it is abandoned. When on a buffer becomes hidden when it is abandoned. This option allows you to change of buffer even if the modifications were not ...


2

As of 7.4.1802, Vim is supposed to quickfix lines up to 4096 bytes long instead of truncating them.


1

Netrw already includes code that attempts to reuse buffers but, as you have discovered, this code currently appears not to handle tree listings and ends up creating many buffers. So the first thing to try is to make sure you are using the latest version of netrw. It looks like the code has changed as recently as July 2019, so it's possible this is something ...


Only top voted, non community-wiki answers of a minimum length are eligible