Emacs 插入 EOF 用于"<<<"



在使用 emacs 编辑 bash shell 脚本 (#!/bin/sh( 时,每当我尝试输入"<<<"时,在第三个括号中,它会将"EOF"直接放在括号后面,并在行尾放置两个回车符,然后再次写"EOF",如下所示:

   resiline=$(grep -w -n "$searchstring" input/*)
   resifile=$(cut -d : -f 1 <<<EOF $resiline)
EOF

为什么要这样做,我如何防止它这样做?

它这样做是因为启用了sh-electric-here-document-mode。 要以交互方式禁用它,只需执行 M-x sh-electric-here-document-mode .

在 Emacs 24 中,默认情况下sh-mode启用此次要模式,但您可以使用sh-mode-hook再次禁用它。

在 Emacs 25 中,sh-mode-hook默认包含sh-electric-here-document-mode(而不是sh-mode直接调用它(,因此您可以通过以下方式删除它:
M-x customize-option RET sh-mode-hook RET

最新更新