Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 797
shangsunset Avatar asked Jan 28 '16 02:01

shangsunset


3 Answers

In Spacemacs, it is also possible to insert a new line while remaining in normal state with the wildly useful command spacemacs/evil-insert-line-below.

It is bound to SPC i j in Vim mode and M-m i j in Emacs mode.

Preceding that command with a numerical argument will insert more than one new line, e.g. 4 SPC i j will insert four new lines.

like image 108
Jason Avatar answered Sep 30 '22 23:09

Jason


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.

like image 32
StreakyCobra Avatar answered Oct 01 '22 00:10

StreakyCobra


I usually use ]SPC to append a new line below. It is equivalent to SPCij.

Also you can add one line above by [SPC.

like image 42
LanternD Avatar answered Sep 30 '22 23:09

LanternD