>_VIM-AWK — AWK IN VIM AND NEOVIM
Load it with pathogen, get full AWK support in Vim / Neovim. awkrs is a pattern / action engine written in Rust with a POSIX / gawk / mawk-style union CLI. vim-awk registers the awk filetype for *.awk files and awk / awkrs shebangs, highlights with a standalone AWK grammar (POSIX core plus the gawk / mawk extensions awkrs accepts), indents with a brace-aware indenter, wires :make / :AwkRun through the awkrs binary, registers awkrs -L invalid as an ALE linter, and registers awkrs --lsp for vim-lsp and coc.nvim (plus awkrs --dap guidance for nvim-dap).
Install
The awkrs binary must be on $PATH for running, linting and LSP. Then drop the plugin into your runtimepath:
# pathogen
cd ~/.vim/bundle
git clone https://github.com/MenkeTechnologies/vim-awk
# then, inside vim: :Helptags
# vim-plug (add to ~/.vimrc / init.vim)
Plug 'MenkeTechnologies/vim-awk'
# native packages (Vim 8+ / Neovim)
git clone https://github.com/MenkeTechnologies/vim-awk \
~/.vim/pack/plugins/start/vim-awk
Open any .awk file and it lights up — no further configuration. Help: :help vim-awk.
What you get
Filetype detection
Every *.awk file becomes filetype=awk. Extensionless scripts with a #!/usr/bin/env awkrs (or awk / gawk / mawk) shebang are detected too.
Syntax highlighting
A standalone AWK grammar — patterns, control flow, statements, built-in variables, built-in functions, field references, regex literals, strings, and operators — POSIX core plus the gawk / mawk extensions awkrs accepts.
Indentation
A standalone brace-aware indenter — indents after a line that opens a block / paren / bracket, dedents lines that start with a closing delimiter.
Run & lint
:compiler awkrs wires :make to awkrs -L invalid into the quickfix list; :AwkRun executes the buffer via awkrs -f %. ALE runs the same lint inline.
Language server & debugger
Registers awkrs --lsp for vim-lsp (filetype awk) — diagnostics, hover, completion; coc.nvim + nvim-dap (awkrs --dap) snippets in the README. Each is invoked with only its flag (no appended --stdio), and the wiring is guarded so the plugin still loads cleanly if the binary is absent.
Zero config
No settings required. Opt-outs: g:vim_awk_no_ale, g:vim_awk_no_lsp, and g:vim_awk_no_maps to skip an integration or the run mapping.
Token categories
The grammar classifies tokens into the same categories the AWK language defines — POSIX awk plus the gawk / mawk extensions awkrs accepts in its union CLI:
| Group | Tokens (sample) |
|---|---|
| Patterns | BEGIN END BEGINFILE ENDFILE · /regex/ · expression patterns |
| Control flow | if else while for do break continue next nextfile exit return delete in |
| Statements | print printf getline |
| Function definition | function func |
| Built-in variables | NR NF FS OFS ORS RS FILENAME FNR RSTART RLENGTH SUBSEP ARGC ARGV ENVIRON CONVFMT OFMT |
| String functions | length substr index split sub gsub match sprintf tolower toupper |
| Arithmetic functions | sin cos atan2 exp log sqrt int rand srand |
| I/O functions | system close fflush |
| Field references | $0 $1 $NF $(expr) |
ERE regex literals (/.../), double-quoted strings with escapes, the ~ / !~ match operators, numbers, and the full operator set are handled too. Everything links to standard highlight groups, so every colorscheme covers it without bespoke tuning.
Layout
vim-awk/ ├── ftdetect/awk.vim # *.awk + awk / awkrs shebang -> filetype=awk ├── syntax/awk.vim # standalone AWK grammar (POSIX + gawk / mawk) ├── scripts/gen_syntax.sh # stamps syntax/awk.vim with the awkrs version ├── ftplugin/awk.vim # commentstring '# %s', :compiler awkrs, :AwkRun ├── compiler/awkrs.vim # :make via awkrs -L invalid -> quickfix ├── indent/awk.vim # standalone brace-aware indenter ├── plugin/awk.vim # ALE linter + vim-lsp + coc + nvim-dap wiring └── doc/awk.txt # :help vim-awk
Standard Vim runtime layout, so pathogen / vim-plug / native packages add it to runtimepath with no special handling. Licensed MIT.
Compatibility
| Editor / plugin | Status |
|---|---|
| Vim 8+ | Filetype, syntax, indent, ftplugin, compiler |
| Neovim | Same runtime files |
| ALE | awkrs -L invalid linter |
| vim-lsp | awkrs --lsp language server |
| coc.nvim | languageserver config in README |
| nvim-dap | awkrs --dap debug adapter config in README |