Prettier AWK Plugin
April 17, 2026 ยท View on GitHub
An opinionated formatter for AWK language built as a plugin for Prettier with help of web-tree-sitter and tree-sitter-awk.
How to install and use
Globally
In Prettier 3, plugins are no longer automatically found if they are installed globally. So although this method works the convenience is gone.
npm install --global prettier prettier-plugin-awk
Then run:
prettier --plugin=$(npm root -g)/prettier-plugin-awk/out/index.js --write /path/to/your/awesome_script.awk
Alternatively you might create config file named .prettierrc in current dir and skip --plugin option.
{
"plugins": [
"/home/awk-developer/npm/lib/node_modules/prettier-plugin-awk/out/index.js"
]
}
Per project
First you need to init new node project with:
npm init -y
Then add development dependencies:
npm add --save-dev prettier prettier-plugin-awk
Then run with:
npx prettier --plugin=prettier-plugin-awk --write ./awesome_script.awk
Or you can add .prettierrc config file and skip --plugin option:
{
"plugins": [
"prettier-plugin-awk"
]
}
You can then create pre-commit hook with something like husky or incorporate such check as CI step.
Ignoring Code
To ignore node in a syntax tree prepend it with # prettier-ignore comment like this:
# prettier-ignore
BEGIN{x=12}
Configuring
Although most of the options are unsupported or make no sense in regard to AWK you can still configure tab or print width.
To do so create .prettierrc in your project directory with following content:
{
"printWidth": 80,
"tabWidth": 4
}