Skip to content
Frank LENORMAND edited this page May 29, 2020 · 25 revisions

Formatting

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

Other commands

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

AsciiDoc

C

C++

Clojure

CoffeeScript

CSS

D

Elixir

Elm

Fish

Go

HAML

HTML

Handlebars

Haskell

INI

Java

JavaScript

JSON

Julia

Latex

Lua

LISP

Makefile

Markdown

MoonScript

Nim

Ocaml

Perl

PHP

Python

Pony

Pug

Ragel

Ruby

Rust

SASS

Scala

Shell

Swift

TUP

YAML

Zig

Clone this wiki locally