Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Format Ruby code in Vim

Just moving over to Vim at the moment. In TextMate I could format code by hitting Cmd-Alt-[. How do I achieve the same in Vim?


See the answer below for the command. I found I also needed the following in my .vimrc so that Vim knew how to autoindent Ruby.

if has("autocmd")   filetype indent on endif 
like image 931
opsb Avatar asked Sep 24 '10 09:09

opsb


1 Answers

Vimcasts has a useful screencast on this subject that you may be interested in

gg=G  gg => go to start of file =  => apply autoformatting G  => ... to the end of file 
like image 180
Codebeef Avatar answered Sep 21 '22 18:09

Codebeef