1

With Evil mode, :bn shows the next buffer, and :bp shows the previous buffer. I wish to define a custom keybinding where <Space>n shows the next buffer, and <Space>p shows the previous buffer.

In Vim, this can be accomplished using:

nnoremap <leader>n :bnext<cr>
nnoremap <leader>p :bprevious<cr>

where <leader> is Space.

How can I define these keybindings for Evil mode?

2

I have something like this in my config, inspired by spacemacs:

(use-package evil
  :init
  (use-package evil-leader
    :commands (evil-leader-mode global-evil-leader-mode)
    :demand
    :config
    (evil-leader/set-leader "SPC")
    (global-evil-leader-mode t))
  :config
  (evil-mode 1))

(evil-leader/set-key
  "bn" 'next-buffer
  "bp" 'previous-buffer)

this requires to type SPC b n or SPC b p, which I recommend becasue it makes more room for other bindings,

but you can remove the bs in the last two lines there, if you prefer the shorter binding.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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