当我意识到我需要(编辑)上面一行的变量定义(或类似的东西)时,我经常发现自己在一条线上打字.我想要的是
从一行的任何位置按C-return,让光标移动到上面新插入的空白行,并有正确的缩进(或至少与原始行相同).
能够抽出任何文字......
和Cu C空间回到原来的位置
我已经设法做到了#1,但是我的emacs-fu还不够强大,无法完成剩下的工作.
这是我谦虚的解决方案:
(defun my-insert-before-line () (interactive) (save-excursion (beginning-of-line) ; I've changed the order of (yank) and (indent-according-to-mode) ; in order to handle the case when yanked line comes with its own indent (yank)(indent-according-to-mode) ; could be as well changed to simple (newline) it's metter of taste ; and of usage (newline-and-indent)))
希望能帮助到你.