是否有一个Emacs命令将"填充"具有特定字符到指定列的行?基本上相当于this question,除了使用Emacs而不是Vim。
举个例子,假设我开始输入如下所示的行:
/* -- Includes
/* -- Procedure Prototypes
/* -- Procedures
我喜欢一个命令,无论光标当前在哪个列上,都会用破折号自动填充行的其余部分(直到我可以指定的列)。
/* -- Includes -----------------------------------------------------
/* -- Procedure Prototypes -----------------------------------------
/* -- Procedures ---------------------------------------------------
谢谢。很抱歉,如果已经提出这个问题,我就无法找到与Google有关的任何内容。
答案 0 :(得分:2)
这里应该有用的东西:
(defun fill-to-end ()
(interactive)
(save-excursion
(end-of-line)
(while (< (current-column) 80)
(insert-char ?-))))
它将-
个字符附加到当前行的末尾,直到它到达第80列。如果要指定字符,则应将其更改为
(defun fill-to-end (char)
(interactive "cFill Character:")
(save-excursion
(end-of-line)
(while (< (current-column) 80)
(insert-char char))))
答案 1 :(得分:1)
(defun char-fill-to-col (char column &optional start end)
"Fill region with CHAR, up to COLUMN."
(interactive "cFill with char: \nnto column: \nr")
(let ((endm (copy-marker end)))
(save-excursion
(goto-char start)
(while (and (not (eobp)) (< (point) endm))
(end-of-line)
(when (< (current-column) column)
(insert (make-string (- column (current-column)) char)))
(forward-line 1)))))
(defun dash-fill-to-col (column &optional start end)
"Fill region with dashes, up to COLUMN."
(interactive "nFill with dashes up to column: \nr")
(char-fill-to-col ?- column start end))