【问题标题】:How to insert new line (after cursor point) with indentation?如何使用缩进插入新行(在光标点之后)?
【发布时间】:2018-05-01 15:12:26
【问题描述】:

我在javascript-mode等编程模式下工作,通常需要将一些行向下推以进行格式化。

我发现C-o 在光标点后插入换行符很方便。然而,下推的线失去了它的缩进。

我发现RET 方便插入换行符。向下推的行很好地缩进。但是,插入的换行符出现在当前光标点之后。 (编辑:)我发现通过在其后插入换行符来保持光标位置很方便,因为有时我仍然需要修改当前行。

【问题讨论】:

    标签: emacs


    【解决方案1】:

    大概是这样的:

    (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)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-17
      • 2015-08-05
      • 1970-01-01
      • 1970-01-01
      • 2015-01-16
      相关资源
      最近更新 更多