2011-12-16 92 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