I want to edit a big, hairy YAML file in Emacs. File structure is implied by indentation: If line A is indented ten spaces, then A starts a section that includes every following line that is indented by more than ten spaces. This is a fairly common convention that is used well beyond YAML.
What I really want is an emacs mode that has definitions that respect this structure. For example:
- I would like
forward-sexp
to skip past a sexp, where a sexp is implied by the indentation rather than by matching pairs of brackets. Similarly, I'd like there to be other navigation commands to move to the line after the end of the current section, to the next sibling section to the current one, and so forth. - I'd like there to be a command to collapse the current section, or all but the current section, similar to the way outline-mode can collapse the current outline section, but with sections defined by indentation.
- I'd like the mode line to display something useful about the section I'm in, as implied by indentation.
- I'd like there to be an option to automatically highlight all the lines that are ancestors of the current line.
- Other things I haven't thought of.
I have looked at yaml-mode
, but it doesn't do anything useful. Several people have suggested I try Python mode, but it doesn't work very well for this purpose.
A generic indented-lines mode seems like the sort of thing someone would have written a long time ago, but if it exists, I can't find it. Or maybe there's some way to hack outline-mode
to work the way I want?
Thanks for any suggestions.
my-yaml-next-sibling
.