randomfox: (Default)
[personal profile] randomfox
The following macro deletes all the buffers.


" Check if buffer is in the :ls list. In VIM6, buffers can exist
" without being loaded or listed.
function! Buf_loaded(bufidx)
    if version >= 600
	return bufloaded(a:bufidx)
    else
	return bufexists(a:bufidx)
    endif
endfunction

" Remove all buffers.
function! Del_all_buf()
    let bufidx = 1
    while bufidx <= bufnr("$")
	if Buf_loaded(bufidx)
	    execute 'bd' bufidx
	endif
	let bufidx = bufidx + 1
    endw
endfunction

" F12 d removes all buffers.
nmap <F12>d :call Del_all_buf()<cr>
vmap <F12>d <esc>:call Del_all_buf()<cr>
imap <F12>d <esc>:call Del_all_buf()<cr>

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

Profile

randomfox: (Default)
randomfox

November 2012

S M T W T F S
    123
45678910
11121314151617
18192021222324
25262728 2930 

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jun. 13th, 2026 09:15 pm
Powered by Dreamwidth Studios