mirror of
https://github.com/jbranchaud/til
synced 2026-01-03 23:28:02 +00:00
Add Bypass On-Save Tooling When Writing File as a Vim TIL
This commit is contained in:
@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
|
|||||||
|
|
||||||
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
|
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
|
||||||
|
|
||||||
_1632 TILs and counting..._
|
_1633 TILs and counting..._
|
||||||
|
|
||||||
See some of the other learning resources I work on:
|
See some of the other learning resources I work on:
|
||||||
- [Ruby Operator Lookup](https://www.visualmode.dev/ruby-operators)
|
- [Ruby Operator Lookup](https://www.visualmode.dev/ruby-operators)
|
||||||
@@ -1700,6 +1700,7 @@ If you've learned something here, support my efforts writing daily TILs by
|
|||||||
- [Breaking The Undo Sequence](vim/breaking-the-undo-sequence.md)
|
- [Breaking The Undo Sequence](vim/breaking-the-undo-sequence.md)
|
||||||
- [Buffer Time Travel](vim/buffer-time-travel.md)
|
- [Buffer Time Travel](vim/buffer-time-travel.md)
|
||||||
- [Build And Install A Go Program](vim/build-and-install-a-go-program.md)
|
- [Build And Install A Go Program](vim/build-and-install-a-go-program.md)
|
||||||
|
- [Bypass On-Save Tooling When Writing File](vim/bypass-on-save-tooling-when-writing-file.md)
|
||||||
- [Case-Aware Substitution With vim-abolish](vim/case-aware-substitution-with-vim-abolish.md)
|
- [Case-Aware Substitution With vim-abolish](vim/case-aware-substitution-with-vim-abolish.md)
|
||||||
- [Case-Insensitive Substitution](vim/case-insensitive-substitution.md)
|
- [Case-Insensitive Substitution](vim/case-insensitive-substitution.md)
|
||||||
- [Center The Cursor](vim/center-the-cursor.md)
|
- [Center The Cursor](vim/center-the-cursor.md)
|
||||||
|
|||||||
30
vim/bypass-on-save-tooling-when-writing-file.md
Normal file
30
vim/bypass-on-save-tooling-when-writing-file.md
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
# Bypass On-Save Tooling When Writing File
|
||||||
|
|
||||||
|
Every once in a while I run into an issue where my code formatters or linters
|
||||||
|
are misconfigured for a project. I try to save a file and it applies formatting
|
||||||
|
that I don't want. Or in an extreme case, the error ouput of the tool is what
|
||||||
|
overwrites the file.
|
||||||
|
|
||||||
|
I need to troubleshoot my dev tooling eventually, but I don't want to get
|
||||||
|
sidetracked at the moment. I just want to save the file. What can I do?
|
||||||
|
|
||||||
|
Tools like linters and code formatters are typically hooked up to Vim via
|
||||||
|
autocommands on certain actions like `FileWrite*` or `BufWrite*`. We can
|
||||||
|
execute a Vim command like writing a file (`w`) while disregarding autocommands
|
||||||
|
like so:
|
||||||
|
|
||||||
|
```vim
|
||||||
|
:noautocmd w
|
||||||
|
```
|
||||||
|
|
||||||
|
or, write and quit:
|
||||||
|
|
||||||
|
```vim
|
||||||
|
:noautocmd wq
|
||||||
|
```
|
||||||
|
|
||||||
|
This disables all autocommands for this one command. The file gets saved and
|
||||||
|
the misconfigured formatters and linters don't clobber the changes you
|
||||||
|
intended.
|
||||||
|
|
||||||
|
See `:h noautocmd` for more details.
|
||||||
Reference in New Issue
Block a user