(defun aj-toggle-fold ()
"Toggle fold all lines larger than indentation on current line"
(interactive)
(let ((col 1))
(save-excursion
(back-to-indentation)
(setq col (+ 1 (current-column)))
(set-selective-display
(if selective-display nil (or col 1))))))
(global-set-key [(M C i)] 'aj-toggle-fold)
I've made a function highlight-indentation for this purpose, code is on github.
When invoking highlight-indentation without a prefix argument the current indentation level is naively guessed from major mode (python, ruby and languages based on cc-mode). Only works for space indentations. Customize highlight-indent-face to change appearance of indentation lines.
Examples (ruby, python):
I also frequently use this snippet that folds all code on an indentation level greater than the current line. It's a great way of getting a quick overview of the outline.
(defun aj-toggle-fold ()
"Toggle fold all lines larger than indentation on current line"
(interactive)
(let ((col 1))
(save-excursion
(back-to-indentation)
(setq col (+ 1 (current-column)))
(set-selective-display
(if selective-display nil (or col 1))))))
(global-set-key [(M C i)] 'aj-toggle-fold)
to my knowledge nobody has implemented indentation guides for Emacs so far. The closest thing you can get are visualization of TABs with the whitespace package, see Show tabs with a different character (Emacs).
发布评论
评论(4)
为此,我创建了一个函数
highlight-indentation
,代码位于 github 上。当调用没有前缀参数的
highlight-indentation
时,当前的缩进级别是从主要模式(python、ruby 和基于 cc-mode 的语言)天真地猜测出来的。仅适用于空格缩进。自定义highlight-indent-face
以更改缩进线的外观。示例(红宝石、Python):
我还经常使用此代码片段,将所有代码折叠到比当前行更大的缩进级别上。这是快速概览大纲的好方法。
I've made a function
highlight-indentation
for this purpose, code is on github.When invoking
highlight-indentation
without a prefix argument the current indentation level is naively guessed from major mode (python, ruby and languages based on cc-mode). Only works for space indentations. Customizehighlight-indent-face
to change appearance of indentation lines.Examples (ruby, python):
I also frequently use this snippet that folds all code on an indentation level greater than the current line. It's a great way of getting a quick overview of the outline.
现在有一种名为 highlight-indent-guides 的模式,它似乎工作得很好。
There now is a mode called highlight-indent-guides which seems to work quite well.
据我所知,到目前为止还没有人为 Emacs 实现缩进指南。您可以获得的最接近的是带有空白包的选项卡可视化,请参阅 显示选项卡使用不同的字符(Emacs)。
to my knowledge nobody has implemented indentation guides for Emacs so far. The closest thing you can get are visualization of TABs with the whitespace package, see Show tabs with a different character (Emacs).
假设您可以根据您的需要弯曲 ColumnMarker 但它会突出显示一列
不给你一个像素。
我缩进了 8 个空格,所以我从来没有考虑过;P
Suppose you could bend ColumnMarker to your needs but it will highlight a column
not givin you a single pixel.
I indent with 8 spaces so i have never thought about it ;P