Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

keel fmt

Auto-format a Keel file with consistent style.

keel fmt <file.keel>

What it does

  • 2-space indentation
  • Consistent spacing around operators and @attribute values
  • One declaration per section with blank line separators
  • Single-line when arms for simple expressions
  • Writes the formatted output back to the file

Example

Before:

use std/io
use std/schedule

agent Bot{@role "helper"
state{count:int=0}
@on_start{schedule.every(1.day, () => {io.notify("hello")
self.count=self.count+1})}}
run(Bot)

After keel fmt:

use std/io
use std/schedule

agent Bot {
  @tools [io]
  @role "helper"

  state {
    count: int = 0
  }

  @on_start {
    schedule.every(1.day, () => {
      io.notify("hello")
      self.count = self.count + 1
    })
  }
}

run(Bot)