2011-12-16 19 views

risposta

2

vimfiles include codice Ruby intelligente rientro e un sacco di altre cose utili

rubino il codice viene formattato automaticamente come

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

Quello che ha funzionato per me stava installando 'vim-pathogen'
https://github.com /tpope/vim-pathogen.git – user815693

21

Provare a utilizzare smartindent anziché cindent (che segue il comportamento del rientro simile a C) e attivare il rientro specifico del tipo di file.

Probabilmente avrete anche bisogno di disattivare la compatibilità di vi.

Prova ad aggiungere questo a voi Vimrc:

" Turn off vi compatibility 
set nocompatible 

set smartindent 
set autoindent 

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

Ottengo indentazione ma è errato in base al tipo di file? Per i file di ruby ​​ottengo un'indentazione di tabulazione enorme, mentre dovrei ottenere solo 2 spazi? –

+1

E per disabilitare 'set nosmartindent',' set noautoindent', 'retetype indent off' – Dorian

0

questo ha funzionato per me.

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

Nel mio caso questo è ciò che risolto i miei problemi di rientro (ad esempio salti in luoghi casuali):

set smartindent 
set noautoindent 
filetype indent off