From 23f4bfa7c68c25dc1c1dda52b58f14971b9e064b Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Tue, 25 Sep 2018 08:21:18 -0500 Subject: [PATCH] Add Format The Current File Within Vim as a reason til --- README.md | 3 ++- reason/format-the-current-file-within-vim.md | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 reason/format-the-current-file-within-vim.md diff --git a/README.md b/README.md index 125e716..e31438f 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ smart people at [Hashrocket](http://hashrocket.com/). For a steady stream of TILs from a variety of rocketeers, checkout [til.hashrocket.com](https://til.hashrocket.com/). -_702 TILs and counting..._ +_703 TILs and counting..._ --- @@ -510,6 +510,7 @@ _702 TILs and counting..._ - [Defining Variants With Constructor Arguments](reason/defining-variants-with-constructor-arguments.md) - [Dynamically Create A Printf String Format](reason/dynamically-create-a-printf-string-format.md) - [Exhaustive Pattern Matching Of List Variants](reason/exhaustive-pattern-matching-of-list-variants.md) +- [Format The Current File Within Vim](reason/format-the-current-file-within-vim.md) - [Generate Starter Reason Projects](reason/generate-starter-reason-projects.md) - [Helping The Compiler Help Us With Variants](reason/helping-the-compiler-help-us-with-variants.md) - [Inline Component Styles With Reason React](reason/inline-component-styles-with-reason-react.md) diff --git a/reason/format-the-current-file-within-vim.md b/reason/format-the-current-file-within-vim.md new file mode 100644 index 0000000..b76c4a4 --- /dev/null +++ b/reason/format-the-current-file-within-vim.md @@ -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.