新建一行

開啓新的一行ide

在emacs中能夠用C-j來新建一行可是必須先執行C-e引動到句子末尾才行,可是寫程序時很是不方便。因此咱們作了下面更改,能夠不移動到句末,在句子中間就新建一行。
;;從新定義C-j快捷鍵
(defun my-new-line-and-indent (arg)
  (interactive "^p")
  (or arg (setq arg 1))
  (let (done)
    (while (not done)
      (let ((newpos
         (save-excursion
           (let ((goal-column 0)
             (line-move-visual nil))
         (and (line-move arg t)
              (not (bobp))
              (progn
            (while (and (not (bobp)) (invisible-p (1- (point))))
              (goto-char (previous-single-char-property-change
                                      (point) 'invisible)))
            (backward-char 1)))
         (point)))))
    (goto-char newpos)
    (if (and (> (point) newpos)
         (eq (preceding-char) ?\n))
        (backward-char 1)
      (if (and (> (point) newpos) (not (eobp))
           (not (eq (following-char) ?\n)))
          ;; If we skipped something intangible and now we're not
          ;; really at eol, keep going.
          (setq arg 1)
        (setq done t))))))
  (newline-and-indent))

(global-set-key (kbd "C-j") 'my-new-line-and-indent)ip

相關文章
相關標籤/搜索