Emacs 相当于 Vim 的 Foldmethod = indent

发布于 2024-07-10 06:04:45 字数 231 浏览 14 评论 0原文

问题: Emacs 是否有与 Vim 的 折叠功能等效的规范Foldmethod=缩进

我对可以与任何 Emacs 主要模式和任何文件一起工作的东西特别感兴趣。 Emacs 搜索尚未找到明确的答案。

Question: Does Emacs have a canonical equivalent of Vim's Folding with Foldmethod=indent?

I am particularly interested in something that can work alongside any Emacs major mode and any file. The Emacs searches have not turned up a definitive answer.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

心意如水 2024-07-17 06:04:45

好像可以,不过我自己不使用折叠,所以没有尝试过。 毫不奇怪,Python 人员都非常关注这个功能。 请参阅以下内容:

Seems like it can, though I don't use folding myself, so I've not tried it. Not surprisingly, the Python folks are all about this feature. See the following:

唠甜嗑 2024-07-17 06:04:45

也许选择性显示? 我将 以下函数 绑定到[f2]

;; http://emacs.wordpress.com/2007/01/16/quick-and-dirty-code-folding/
(defun jao-toggle-selective-display (column)
  (interactive "P")
  (set-selective-display
   (if selective-display nil (or column 1))))

不过,这是相当简单的,你真的希望它对 Pythony 缩进敏感......

更新:我昨晚盯着这个,意识到我厌倦了 Cu 进入我的专栏是(加1)......所以我将其编码:

(defun toggle-selective-display-column ()
  "set selective display fold everything greater than the current column, or toggle off if active"
  (interactive)
  (set-selective-display
   (if selective-display nil (or (+ (current-column) 1) 1))))

进一步的阐述应该结合这两个功能。

另请参阅:如何在 emacs 中实现代码折叠效果

maybe selective-display? I have the following function bound to [f2]

;; http://emacs.wordpress.com/2007/01/16/quick-and-dirty-code-folding/
(defun jao-toggle-selective-display (column)
  (interactive "P")
  (set-selective-display
   (if selective-display nil (or column 1))))

That's pretty bare-bones, though, and you'd really want it to be Pythony-indentation sensitive....

UPDATE: I was staring at this last night, and realized that I was tired of C-u entering the column I was on (plus 1).... so I coded it up:

(defun toggle-selective-display-column ()
  "set selective display fold everything greater than the current column, or toggle off if active"
  (interactive)
  (set-selective-display
   (if selective-display nil (or (+ (current-column) 1) 1))))

Further elaboration should combine the two functions.

See also: How to achieve code folding effects in emacs

北笙凉宸 2024-07-17 06:04:45

我尝试了 Joe Casadonte 和 Michael Paulukonis 的所有建议,但没有一个比 vim 的效果更好。 因此,目前对OP问题的更准确答案可能是否定的。

I tried all of the suggestions by Joe Casadonte and Michael Paulukonis, but none works as nicely as the vim's one. So it seems that the more accurate answer to the OP's question may be NO at the moment.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文