r - Emacs ESS 在 %>% 后缩进
问题描述
对于 R 代码,我当前的 emacs ESS 样式是 C++,这会导致
worst <- flights_sml %>%
group_by(year, month, day)
即继续在 . 之后缩进 4 个空格%>%
。我希望它是2个空格。
我怎样才能做到这一点?
解决方案
你想要什么并不完全清楚。如果在连续语句中只需要 2 个空格,例如管道之后的那些,则以下应该有效
(setq ess-offset-continued '(straight 2))
因此,缩进仍将默认为 C++ 样式中设置的 4 个空格,例如。结果看起来像
worst <- flights_sml %>%
group_by(year, month, day)
f <- function(x) {
x
}
否则,如果你总是想要 2 个空间偏移
(setq ess-indent-offset 2)
您可以在模式挂钩中自定义这些变量,例如。
(defun my-R-hook ()
(setq-local ess-style 'C++)
(setq-local ess-offset-continued '(straight 2)))
ess-offset-continued
有关详细信息,请参阅文档ess-style-alist
。
推荐阅读
- powershell - 基于 CSV 值的名称文件
- search - 如何在 Notepad++ 中的搜索中排除文件夹列表
- javascript - 更改嵌套数组的状态时,Redux UI 不会更新
- jenkins - Jenkins无需等待即可获得下游作业的URL
- node.js - 我对 multer 和 nodejs 'EINVAL:无效参数'有错误
- javascript - .Css 文件未设置 React 组件的样式
- python - Python,创建多个文件
- php - 获取每个日期 PHP 的 start_time 和 end_time 的总小时数?
- excel - 如何使用 VBA 根据相邻单元格值将范围向下移动一行?
- sql - 打印表中给定列中的重复值,次数与它们出现的次数一样多。SQL