Indentation (Feature request)


I am pretty sure that this question has been asked here before but none of the existing response answers my question.
It would be nice to have indent-region, indent-buffer commands like in emacs, with the same usage principle. Is it possible? Why not?
It would be nice to have a plugin that indents the entire buffer according to astyle for example or google style
Starting to learn kakoune, I do not see any guide for indentation, sure there is this one here, but it still missing explanations, and start directly by introducing hooks? Why? kakoune can not indent without hooks?
Finally I use tab for autocomplete, and use smarttab to indent, but this is manually and far from making this easy like in emacs.
What do you think?
Best regards,
Happy new year.

I’m not familiar with Emacs or the indent-region or indent-buffer commands, but Kakoune does ship with a formatting plugin. Set the formatcmd option to the name of a program that takes text on stdin and writes formatted text to stdout, and then you can use the :format-buffer and :format-selections commands to pipe the buffer through the formatter. You don’t need a special plugin to format the buffer in a particular style, you just need a tool that implements it, like gofmt or rustfmt or clang-tidy.

However, people often want their buffers formatted interactively - rather than typing whatever and having everything automatically reformatted when they run :format, they want their editor to automatically and intelligently choose an indentation level for each new line, whether it’s created by hitting Enter in insert mode, or o in normal mode, or whatever. In Kakoune, “do something when the user presses a key” means using a hook — either the InsertKey hook or the NormalKey hook (or both).