Fix indentation of region

Is there a way to fix the indentation of multiline selections in Kakoune? In Emacs, hitting tab while a region is selected does this, and it looks like Vim has =. If this isn’t built into Kakoune, is there a command line utility or Kakoune plugin that does this?

The definition of “fix” depends on what kind of file you’re editing. Plain text is pretty simple, so you can just set up a mapping to pipe things through fmt. For source code, you’ll probably need a specialised tool, but if the language you’re working with has a Language Server, and that language server supports the standard auto-format command, and you’re using kak-lsp to integrate the language server with Kakoune, there’s a :lsp-formatting command you can use—the docs even have a snippet showing how to make it auto-format every time you save the buffer.

In Vim, there’s cindent feature, that indents any block of text as it is C code, which is boun to ==. If some (not-full) region of text will be passed to something like clang-format with pipe it will be broken, because clang-format doesn’t accept incremental formatting and will fail if syntax tree is not full. Vim formatter was simple, but doesn’t had this kind of “problem”. Emacs has a nice feature, Tab keypress inserts correct indentation no matter what. I would appreciate this behavior.

@Screwtapello @andreyorst Thanks for the suggestions. I’ll play around with it and see what I like