Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby Code Autoindentation in Vim

I have copied a Ruby example into Vim, but it turns out that this messed up the indentation. I tried to make Vim apply the Ruby specific indentation. To do that I uncommented the following lines in the global vimrc file:

if has ("autocmd")
  filetype plugin indent on
endif

And pressed gg=G in Vim. Now it changes some of the indentation, but it still has some errors:

  • Class definitions don't get indented.
  • Comments don't get indented and remain at the start of the lines.
like image 389
FlyingFoX Avatar asked Jun 04 '11 13:06

FlyingFoX


1 Answers

Before paste from outer source, use this command

:set paste

then enter to insert mode and paste.

like image 66
intellidiot Avatar answered Nov 09 '22 11:11

intellidiot