-
Notifications
You must be signed in to change notification settings - Fork 722
Format
format.kak
is a script bundle with Kakoune that offers the formatting of selection or the full buffer.
The exact details of how the formatting is done, is handle on case by case depending of the language. It relies on a specific tool that must be specified via the formatcmd
option.
The benefit is that it can apply more clever rules than simple ones like "when <ret>
is pressed after a {
it should indent the new opened line". So the user can focus on just raw typing, execute the :format
command and let the magic happens. This command can also be run automatically on buffer-save via hooks.
As an example, one popular tool in the web community is prettier
There are few things to consider: - if possible, the formatting rules should be in sync with the ones used by EditorConfig - a linter should focus only on errors and warnings, so rules about formatting should be disabled - some LSP servers provide a format command but it’s often not very configurable
- Normal mode commands
- Avoid the escape key
- Implementing user mode (Leader key)
- Kakoune explain
- Kakoune TV