enz*_*tib 11 bash emacs autocomplete
使用 emacs 编辑 bash 脚本文件并尝试输入 时<<<,在第二个<emacs 处插入此处文档的模板,如下例所示:
<<EOF
EOF
Run Code Online (Sandbox Code Playgroud)
这不是所需的输出,因为我会输入文字<<<.
目前我求助于输入< < <,然后删除空格,但我更喜欢被允许直接输入。
小智 12
实际上不需要 Tom 的自定义my-disable-here-document函数重新绑定键。可以通过以下方式启用和禁用此功能sh-electric-here-document-mode:
(add-hook 'sh-mode-hook
(lambda ()
(sh-electric-here-document-mode -1)))
Run Code Online (Sandbox Code Playgroud)
(也可以通过 为活动缓冲区切换M-x sh-electric-here-document-mode。)
在 bash 模式下绑定<到self-insert-command,然后它只会插入字符。
默认情况下,它绑定到sh-maybe-here-documentbash 模式下,并且该函数执行自动插入。
这里有一种回弹键的方法:
(add-hook 'sh-set-shell-hook 'my-disable-here-document)
(defun my-disable-here-document ()
(local-set-key "<" 'self-insert-command))
Run Code Online (Sandbox Code Playgroud)