vim-ruby-fmt


Ⅰ. 插件描述

autocorrect ruby in vim

Ⅱ. 基本信息

创建日期:  2014-04-15
使用用户:  1
Github星:  4
插件作者:  Zack Hubert

Ⅲ. 安装方法

使用Vundle管理器安装

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

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

使用NeoBundle管理器安装

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

使用VimPlug管理器安装

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

使用Pathogen管理器安装

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

Ⅳ. 文档说明

vim-ruby-fmt

Using the wonderful Rubocop gem, this adds gofmt-like stylewise autocorrections on save to Vim.

Why?

If your team has adopted a style guide and/or started using something like HoundCI, you are probably used to having your pull requests annotated with style violations.

If you have used GoFmt, then you know how liberating it is to not have to worry about these things as your editor of choice automatically fixes all those things for you.

That's what this does for Vim and Ruby.

Installation

I use Vundle so it is as easy as adding to my vundles.vim:

Bundle 'zhubert/vim-ruby-fmt'

and running :BundleInstall from within Vim.

Finally, within your .vimrc add the following for autocorrect on save (experimental, double check things!):

" should already have the first line, adding the second
filetype plugin indent on
autocmd FileType ruby autocmd BufWritePost <buffer> Fmt

If you want to be safer, I'd recommend binding the Fmt call to a map, like so:

nmap ff :Fmt<CR>

Experimental

This can mess up your code!

There is also an annoying flicker from the redraw, which when I have more time I can figure out.

添加新评论