How to display indentation guides in Emacs? [closed]
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)
There now is a mode called highlight-indent-guides which seems to work quite well.
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).