Skip to content

Instantly share code, notes, and snippets.

Last active Jul 7, 2021
What would you like to do?
" Use |:RubocopAutocorrect[!]| to autocorrect the current file using Rubocop.
" Note that this will save the file before running the autocorrects. If ! is
" given, it will use unsafe autocorrects.
augroup ruby
autocmd FileType ruby command! -bang RubocopAutocorrect silent! call RubyRubocopAutocorrect(expand('<bang>') == '!')<CR>
augroup END
function! RubyRubocopAutocorrect(unsafe) abort
let flag = a:unsafe ? '-A' : '-a'
write | call system('rubocop ' . flag . ' ' . expand('%:p')) | edit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment