简体   繁体   English

vim ruby​​插件缩进

[英]vim ruby plugin indentation

I have recently set up vim-ruby plugin and expected it to work out of the box as the docs are saying, however not even the basic ruby indentation is working for me. 我最近设置了vim-ruby插件,并希望它能像文档所说的那样开箱即用,但是即使是基本的ruby缩进也不适合我。 I've a pretty simple vimrc file: 我有一个非常简单的vimrc文件:

set nocompatible           " turn vi into vim
filetype off               " required by vundle
" VUNDLE SETUP
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()          " required
" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'

" Track the engine.
Plugin 'SirVer/ultisnips'
" " Snippets are separated from the engine. Add this if you want them:
Plugin 'honza/vim-snippets'

" go-vim plugin by fatih
Plugin 'fatih/vim-go'

" vim-ruby plugin for ruby shit
Plugin 'vim-ruby/vim-ruby'

" vim-fugitive plugin for git
Plugin 'tpope/vim-fugitive'

" enabled vim-neatstatus line
Plugin 'maciakl/vim-neatstatus'

call vundle#end()            " required
filetype plugin indent on    " enable file detection

syntax on        " Always turn the syntax on
set expandtab    " Turn tab into spaces
set number       " Turn on numbering of lines
set showmatch    " Show matching brackets.
set matchtime=5  " Bracket blinking.
set noshowmode   " Shows vim mode

" set status line
set laststatus=2 " Always show status line.

" Match and search
set hlsearch    " highlight search
set ignorecase  " Do case in sensitive matching with
set smartcase   " be sensitive when there's a capital letter
set incsearch   " Search incrementally

" color scheme
set background=dark
colorscheme molokai
set t_Co=256

let mapleader = ","
let g:mapleader = ","

" remap hjkl
noremap ' l
noremap ; k
noremap l j
noremap k h
nnoremap . ;

" Fast saving
nmap <leader>w :w!<cr>
" Fast quitting
nmap <leader>q :q<cr>
" Fast save and quit
nmap <leader>ww :wq<cr>

" toggle the paste
map <leader>p :set paste!<CR>
" toggles search highlighting
nmap <silent> <leader>n :set hlsearch!<CR>

" Turn off auto-commenting
au FileType * setlocal formatoptions-=cro

" Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
let g:UltiSnipsExpandTrigger="<c-k>"
let g:UltiSnipsJumpForwardTrigger="<c-j>"
let g:UltiSnipsJumpBackwardTrigger="<s-c-k>"

Nothing crazy. 没什么疯狂的。 However, whenever editing ruby file (.rb, Rakefile etc., the indentation is always 8 spaces and I've no clue why. 但是,每当编辑ruby文件(.rb,Rakefile等)时,缩进总是8个空格,我不知道为什么。

Even the simple if clause turns into this: 甚至简单的if子句也变成了这样:

if foo == "bar"
    puts "foobar"
end

vim-ruby does a pretty awesome job detecting ruby files like Rakefile etc., but after spending several hours investigating indentation I gave up and open this issue. vim-ruby在检测Rakefile等红宝石文件方面做得非常出色,但是花了几个小时研究缩进后,我放弃并打开了这个问题。

My vim version: 我的vim版本:

$ vim --version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Oct 22 2014 11:49:13)
MacOS X (unix) version
Included patches: 1-430
Compiled by Homebrew

尝试将autocmd FileType ruby set shiftwidth=2.vimrc

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM