Skip to content

Commit 1ab0842

Browse files
committed
document how to use stdin in nvim
1 parent dfdbf01 commit 1ab0842

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,21 @@ vim.api.nvim_exec([[
143143
]], false)
144144
```
145145

146-
You should also be able to configure it with input from stdin and output to stdout using the `--stdin` flag,
147-
but I'm too much of a nvim noob to figure out how to configure it.
146+
### Nvim with --stdin
147+
148+
You can also use stdin/stdout mode for nvim. This is an example of `init.lua`.
149+
150+
```lua
151+
-- Create an augroup for tcsort
152+
local tcsort_group = vim.api.nvim_create_augroup("tcsort", { clear = true })
153+
154+
-- Create an autocmd for BufWritePre event
155+
vim.api.nvim_create_autocmd("BufWritePre", {
156+
group = tcsort_group,
157+
pattern = "*.templ",
158+
command = "silent! %!tcsort --stdin",
159+
})
160+
```
148161

149162
## Contributing
150163

0 commit comments

Comments
 (0)