我在编程模式下工作,例如javascript-mode
,通常需要向下推一些行以进行格式化。
我发现在光标点后插入换行符C-o
方便。但是,向下推的线会失去缩进。
我发现插入换行符RET
方便。向下推的线很好地缩进了。但是,插入的换行符位于当前光标点之后。(编辑:(我发现通过在光标后面插入换行符来保持光标位置很方便,因为有时我仍然需要修改当前行。
可能是这样的:
(defun open-line-and-indent ()
"Like `newline-and-indent', but do not move the point."
(interactive)
(save-excursion
(newline-and-indent)))
(global-set-key (kbd "C-o") #'open-line-and-indent)
;; (define-key javascript-mode-map (kbd "C-o") #'open-line-and-indent)