vim-rubybeautifier


Ⅰ. 插件描述

rubybeautifier

Ⅱ. 基本信息

创建日期:  2010-08-01
使用用户:  1
Github星:  3
插件作者:  Subba Rao Pasupuleti

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'subbarao/vim-rubybeautifier'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'subbarao/vim-rubybeautifier'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'subbarao/vim-rubybeautifier'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/subbarao/vim-rubybeautifier

Ⅳ. 文档说明

" -----------------------------------------------------------------------------  
" |                               Ruby Code Formatter                         |
" -----------------------------------------------------------------------------  
fun BenIndent()
  let oldLine=line('.')
  " our text (whole file) is passed via STDIN (%) to script name, and the output is
  " placed in current buffer (STDOUT)
  if g:IndentStyle == "C"
    %!indent --gnu-style --no-tabs --indent-level 8 --case-indentation 0 --brace-indent 0 --comment-delimiters-on-blank-lines --start-left-side-of-comments --format-all-comments --format-first-column-comments
  elseif g:IndentStyle == "perl"
    %!perltidy -gnu
  elseif g:IndentStyle == "html"
    %!tidy -quiet -utf8 -indent -clean -asxhtml
  elseif g:IndentStyle == "php"
    %!tidy -quiet -utf8 -indent -clean
  elseif g:IndentStyle == "ruby"
    %!~/.vim/autoload/ruby/rubybeautifier.rb
  endif
  exe ':' . oldLine
endfun
map -- :call BenIndent()<CR>

augroup ruby
  if !exists("autocommands_ruby_loaded")
    let autocommands_ruby_loaded = 1
    au BufReadPre .rb,.rake,Rakefile,.autotest set sw=3 sts=3 nu | let IndentStyle = "ruby"
    au BufNewFile *.rb 0r ~/.vim/skeleton/skeleton.rb | let IndentStyle = "ruby"
  endif
augroup END

添加新评论