Reputation: 5353
When I use VIM and buffers, to see the list of all the buffers, I always have to type :ls
to see all the buffers.
Is there a way to have the buffers always be displayed at the bottom of vim?
Edit: So basically let's say I have 2 files open in vimand if I type in :ls it will display something like
1 #h "IModuleTest.php" line 422
3 %a "~/.vimrc" line 1
Instead of typing that to see all my files open, I want to see them all the time so I can switch between them faster instead of seeing the buffer list first..
Upvotes: 10
Views: 9485
Reputation: 895
Lua function to list buffer names within statusline with active one hightlighted:
vim.cmd('hi ActiveBuffer term=underline cterm=underline ctermfg=none ctermbg=none')
function set_status(args)
local buffs = {}
local no_list_buffs = {['']=true, ['[Command Line]']=true}
for _,v in pairs(vim.fn.getbufinfo({buflisted=1})) do
local fname = vim.fn.fnamemodify(v.name, ":t")
if(not no_list_buffs[fname]) then
if(v.bufnr == args.buf) then
fname = '%#ActiveBuffer#'..fname..'%*'
end
table.insert(buffs, fname)
end
end
vim.o.statusline = '%F%m %y%='..'<'..table.concat(buffs, ',')..'>'..' %c,%l/%L %P'
end
To invoke use autocmd:
vim.api.nvim_create_autocmd({'BufEnter'},
{
group = vim.api.nvim_create_augroup('BufStatusLine', {}),
callback = set_status
})
Upvotes: 0
Reputation: 939
I like this plugin "vim-bufferline"
First good thing is that it shows up on the empty, unused space of command line, once it finds that the command line is inactive/idle for ~3seconds. And it disappears once we press : (start of a command).
Then it shows on command-line a list of all the buffers open in the Vim and also highlights the active buffer on which the cursor is.
Upvotes: 4
Reputation: 172510
There are plugins that do that; for example, minibufexpl.vim.
Actually, this need sounds strange. Do you know that commands like :buffer
also take a filename, and auto-complete it, too?! GVIM has a Buffers menu by default. And many users have plugins like CtrlP, FuzzyFinder, or Unite to quickly locate buffers and files.
Upvotes: 2