我在编程模式下工作,比如javascript-mode,出于格式化的目的,我通常需要向下推入一些行。
我发现C-o在光标点后插入换行符很方便。但是,按下的行将失去其缩进。
我发现RET插入换行符很方便。压下的线条缩进得很好。但是,插入的新行位于当前光标点之后。(EDIT:)我发现通过在光标后面插入换行符来保持光标位置比较方便,因为有时我仍然需要修改当前行。
发布于 2017-11-21 03:00:15
可能是这样的:
(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)https://stackoverflow.com/questions/47357478
复制相似问题