Skip to content

Instantly share code, notes, and snippets.

@denvaar
Created September 21, 2019 18:04
Show Gist options
  • Save denvaar/a1a0b3d8259c714fbdfd867e5bd204bc to your computer and use it in GitHub Desktop.
Save denvaar/a1a0b3d8259c714fbdfd867e5bd204bc to your computer and use it in GitHub Desktop.
Run mix format on file save in vim
function FormatElixirCode()
let l:winview = winsaveview()
silent %!mix format -
call winrestview(l:winview)
:endfunction
autocmd BufWritePre *.ex,*.eex :call FormatElixirCode()
@denvaar
Copy link
Author

denvaar commented Sep 23, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment