I am trying to create a mapping that will close the current buffer and replaced by the previous buffer.

I tried this

noremap <silent><Leader>bd :<C-6><Bar>bd #<CR>

But will just delete the previous buffer instead closing the current buffer and showing the previous one.

It look like the <C-6> is not working.

1 Answer 1


<C-6> is a normal mapping (I guess you want to switch to alternate buffer).

But the way you call it is incorrect -- calling it as an ex-command. Normal mode commands in vimscript should be called with :normal! sequenceofkeypresses. For <C-6> it would be :normal ^^ where ^^ is generated by pressing <C-v><C-6>. Even more, with normal you would have issues using <bar> and would have to wrap it into :exe "normal ..." as described in :h :normal.

Having said this, it would be way easier to use b# command to do the same...

nnoremap <silent><Leader>bd :b#<Bar>bd#<CR>

:b# is short for :buffer # -- switch to alternate buffer.

And to answer your direct question you can map it like this:

nnoremap <silent><leader>bd <C-6>:bd #<CR>


  1. nnoremap is used instead of noremap -- map only for normal mode. I doubt you want this mapping to work in insert/select/visual modes. If you do, then you have to change it per mode (they should be slightly different)
  2. <C-6> is executed in the same normal mode, so no normal ex command is needed
  • Thank you so much, I adapted your implementation and works perfectly.
    – zer09
    Aug 14, 2021 at 6:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.