2011-12-16 57 views

回答

2

vimfiles包括Ruby代码智能缩进和很多其他有用的东西

红宝石代码自动格式化,如

class Foo 
    def bar 
    if xxx 
     blah 
    else 
     blahblah 
    end 
    barfoo 
    barfoo 
    end 
end 
+0

什么工作对我来说是安装`VIM-pathogen`
https://github.com /tpope/vim-pathogen.git – user815693 2011-12-18 21:37:10

21

尝试使用smartindent而不是cindent(它遵循类似C的缩进行为),并打开文件类型特定的缩进。

您还可能需要关闭vi的兼容性。

尝试增加这个给你的.vimrc:

" Turn off vi compatibility 
set nocompatible 

set smartindent 
set autoindent 

" load indent file for the current filetype 
filetype indent on 
+0

我得到缩进但基于文件类型是错误的?对于红宝石文件,我得到巨大的标签缩进,而我应该只得到2个空格? – 2015-10-06 19:19:38

0

这为我工作。

" Ruby indentation from http://ubuntuforums.org/showthread.php?t=290462 
if has ("autocmd") 
    filetype indent on 
endif 
0

在我而言这是我的固定压痕问题(如跳跃随机的地方):

set smartindent 
set noautoindent 
filetype indent off