7 votes
Accepted

How to detect the buffer number of new buffer

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 ...
user avatar
  • 9,330
7 votes
Accepted

"set hidden" leaves many *empty* buffers. Can I automatically get rid of them?

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 ...
user avatar
  • 7,210
6 votes
Accepted

Creating a hidden buffer

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-...
user avatar
  • 8,635
4 votes
Accepted

Buffers that are neither active nor hidden

You'll find more details under :h active-buffer and the sections that follow... *active-buffer* active: The buffer is displayed in a window. If there is a file for this ...
user avatar
  • 18.4k
4 votes
Accepted

Buffers are left even when `nohidden` is set

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 ...
user avatar
3 votes
Accepted

vim :make :cwindow, I need error length character limit larger than 1000

As of 7.4.1802, Vim is supposed to quickfix lines up to 4096 bytes long instead of truncating them.
user avatar
  • 10.4k
3 votes

Move to window if specified buffer is opened

With vim only There's a few options to make navigation between files less tedious in vanilla vim. First, you need set switchbuf=useopen in your vimrc (:h 'switchbuf') to reuse a split (if it exists, ...
user avatar
  • 2,550
3 votes
Accepted

Buffer scope variable not exists when run autocmd BufUnload

As you can see in :help BufUnload: NOTE: When this autocommand is executed, the current buffer % may be different from the buffer being unloaded <afile>. So you should use getbufvar() to ...
user avatar
  • 26.2k
3 votes
Accepted

open several files into same buffer

The :read command reads a file into the current buffer; although it only works for one file. You'll need to add a new command which calls :read in a loop: command! -nargs=+ -complete=file Read ...
user avatar
2 votes
Accepted

Command to load buffer but not make it current

You want bufload() and maybe bufadd(). Usage example: call bufadd('someName')->bufload() The patch 8.1.1610 is required.
user avatar
  • 5,517
2 votes
Accepted

Move to window if specified buffer is opened

Use :h :wincmd to manipulate window in script, it follow the same rule as :h CTRL-W . e.g. If you want to jump to window 3, you can do it by 3<c-w><c-w> in normal mode, or :3wincmd w in ...
user avatar
  • 5,908
2 votes
Accepted

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

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 ...
user avatar
  • 46.5k
2 votes
Accepted

Make vim remember the fileformat of a buffer (round 2)

You can add an autocmd to have Vim execute :e ++ff=dos every time this particular file is read or reloaded. Assuming the path to the file, after resolving symbolic links, is ~/VendorApp/DataCamp/...
user avatar
  • 26.2k
1 vote

Buffer scope variable not exists when run autocmd BufUnload

The current buffer and file is behind <afile>, not %
user avatar
  • 16.2k
1 vote

How to show the name of a help buffer in the tabline of the airline?

:help opens an unlisted buffer (:help unlisted-buffer) You can make the buffer listed (shown in :buffers) with the command :setlocal buflisted Now you will find the buffer in the list that :buffers ...
user avatar
  • 1,195
1 vote

Everytime I call :Explore netrw creates a new unlisted buffer

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 ...
user avatar
  • 28k
1 vote

Hide terminal buffer from buffer list

This seems to get me what I want. I think neoterm relies on the terminal buffer being in the buffer list. I just made my buffer tab cycle key mapping check to see if the new buffer that was cycled to ...
user avatar

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