Skip to content

Instantly share code, notes, and snippets.

@kurrik
Created May 10, 2014 01:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kurrik/934f06673dcf34ee9ae7 to your computer and use it in GitHub Desktop.
Save kurrik/934f06673dcf34ee9ae7 to your computer and use it in GitHub Desktop.
Set up :Fmt command to autoformat JavaScript files in Vim
" JavaScript formatting.
" Install https://github.com/rdio/jsfmt - npm install -g jsfmt
function! Jsformat()
let regel=line(".")
%!jsfmt --format=true
call cursor(regel, 1)
endfunction
autocmd BufRead,BufNewFile *.js setfiletype javascript
autocmd Filetype javascript command! Fmt call Jsformat()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment