Created
September 21, 2019 18:04
-
-
Save denvaar/a1a0b3d8259c714fbdfd867e5bd204bc to your computer and use it in GitHub Desktop.
Run mix format on file save in vim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function FormatElixirCode() | |
let l:winview = winsaveview() | |
silent %!mix format - | |
call winrestview(l:winview) | |
:endfunction | |
autocmd BufWritePre *.ex,*.eex :call FormatElixirCode() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note - You probably don't want to use this because if it finds any syntax errors, the entire file is replaced with the error message, which can cause you to loose what you're working on if you're not careful. Need to display error message in a separate window instead.