Search code examples
emacsspacemacs

In Spacemacs, how do I insert a newline, without entering insert mode?


In Vim, you can bind Enter key to insert a newline without entering insert mode. how can you do this in Spacemacs.

Or how to remap keys in general in Spacemacs?


Solution

  • You can use:

    (define-key evil-normal-state-map (kbd "RET") 'spacemacs/evil-insert-line-below)
    

    to insert a line below and stay at the same position, or

    (define-key evil-normal-state-map (kbd "RET")
      (lambda ()
        (interactive)
        (call-interactively 'spacemacs/evil-insert-line-below)
        (evil-next-line)))
    

    to insert a line below and go to the new line.