mirror of
https://github.com/jbranchaud/til
synced 2026-01-03 15:18:01 +00:00
Add Format The Current File Within Vim as a reason til
This commit is contained in:
19
reason/format-the-current-file-within-vim.md
Normal file
19
reason/format-the-current-file-within-vim.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# Format The Current File Within Vim
|
||||
|
||||
I'm editing a `.re` file within Vim. I haven't yet wired up `refmt` to
|
||||
something like [ALE](https://github.com/w0rp/ale) for automatic formatting
|
||||
on save. By the time I'm done with my changes, indentation is a mess.
|
||||
|
||||
I can still take advantage of `refmt` to clean up my file.
|
||||
|
||||
```
|
||||
:!refmt --in-place %
|
||||
```
|
||||
|
||||
Running that command in Vim will cause the current file to be formatted.
|
||||
|
||||
How does it work?
|
||||
|
||||
It shells-out to `refmt` which does all the heavy lifting. The `--in-place`
|
||||
flag means that the target file will be re-written by the formatted result.
|
||||
The `%` is a handy Vim shorthand for the path and name of the current file.
|
||||
Reference in New Issue
Block a user