vim-rails-bundle


Ⅰ. 插件描述

Ruby on Rails development environment inside Vim.

Ⅱ. 基本信息

创建日期:  2013-02-23
使用用户:  1
Github星:  37
插件作者:  Samuel Molnár

Ⅲ. 安装方法

使用Vundle管理器安装

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

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

使用NeoBundle管理器安装

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

使用VimPlug管理器安装

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

使用Pathogen管理器安装

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

Ⅳ. 文档说明

# Ruby on Rails Bundle for Vim

Vim as a Ruby on Rails IDE with all the cool plugins and nifty configuration.
Follow the simple installation guide and hack in no time!

Note: We replaced old submodule architecture for bundles with neat Vundle, so
there's no need to install submodules with Git anymore. We also ditched Vim Powerline in favor
of Vim Airline. If you have any problems with fonts and rendering of statusline, please, refer to the documentation of Vim Airline first.

Screenshot

Video

Installation

Requirements

  • Vim/Gvim
  • Ruby, Rails, Bundler (rvm ftw!)
  • Git

There are some core stuff that other plugin use. In order to make them work, you need to have
these packages installed:

To satisfy requirements, run (Ubuntu only):

sudo apt-get install vim vim-gtk git curl ack-grep clang xclip

For other distros or package managers, refer to package management documentation.

Setup

Clone the repository:

git clone git://github.com/smolnar/vim-rails-bundle.git .vim-rails-bundle
cd .vim-rails-bundle

# For Vundle
git submodule init
git submodule update

Install necessary gems:

bundle install

Install plugins by Vundle

vim +PluginInstall +qall

Choose what you want to install:

  • rake bundle:config symlinks .vim and .vimrc to your $HOME or other path if specified in config.yml and install Vundle bundles automatically.
  • rake bundle:gtk symlinks .gtkrc-2.0-vim in your $HOME or or other path if specified in config.yml. In order to autoload this file, it appends
    include "...../.gtkrc-2.0-vim" to your .gtkrc-2.0.
  • rake bundle:desktop symlinks gvim_for_rails.desktop file in /usr/share/applications and gvim_for_rails script in /usr/bin. Note, that sudo is required.

Now, run vim, gvim_for_rails or open Gvim for Rails and start hackin'!

If something isn't woking for you, create an issue.

Configuration

Keyboard

This bundle is shipped with some default keyboard mappings defined in .vimrc. Fell free to change them. I try to use as many comments as possible, but if you're not confident what the options does, refer to exhaustive vim documantation.

If you like trailing characters (▸,¬,❯,❮), you can easy set it up by uncommenting the following lines:

set list
set listchars...

in .vimrc.

Leader is a key defined in let mapleader=.... Bundle uses , as Leader by default.
Note, that when pressing any Leader combo, you don't need to press all buttons at once, it's a sequence.

KeysAction
SpaceOpen all folds.
CTRL + aGo Home (at the beginning of a line. Emacs-like helper.)
CTRL + eGo to End (at the end of a line. Emacs-like helper.)
CTRL + sSave current file. (Works in Gvim out of the box. For terminal, set mapping of Ctrl - s.)
Leader + qQuit current buffer (If there is only one tab or buffer, it quits the vim as well!)
CTRL + ALT + qQuit current buffer or file (It does not quit the window, but creates empty buffer instead).
CTRL + ALT + wWrite and quit.
Leader + SpaceGet rid of all search highlights.
Leader + s + hToggle highlight of search results.
Leader + vSplit window vertically and switch to it.
Leader + hSplit window horizontally and switch to it.
Leader + tRun ctags silently.
Leader + pPaste from clipboard.
Leader + yCopy to clipboard.
Leader + aRun Ack search. (Search in current dir (CWD) for specified parrtern.)
Leader + =Format whole file.
CTRL + n or CTRL + tOpen new tab.
CTRL + ALT + nOpen new tab with the content of current text file.
ALT + LeftPrevious tab.
ALT + RightNext tab.
ALT + nMove to n-th tab, where n is from 0..9.
Leader + uUppercase all letters of current word.
Leader + lLowercase all letters of current word.
Leader + w + uUppercase first letter of current word.
Leader + w + lLowercases first letter of current word.
Leader + c + dChange directory to the directory containing the file in the buffer.
Leader + g + wSwap two words.
Plugins
F3 or Leader + fStart CtrlP search. (Kinda like CommandT in Textmate)
F4Start CtrlP search in open buffers.
F2Start CtrlP search dirs only.
Leader + e + vCtrlP search in app/views.
Leader + e + cCtrlP search in app/controllers.
Leader + e + mCtrlP search in app/models.
Leader + g + uToggle Gundo undo list.
Leader + g + sShow git status by Fugitive plugin.
Leader + g + cCommit changes by Fugitive plugin.a
Leader + g + dSee diff of current file by Fugitive plugin.
F1Toggle NERDTree.
F6 or Leader + r + aRails command.
F7 or Leader + r+ gRails generate command.
F8 or Leader + r + rRake command.
F9 or Leader + r + iInitializers. (Empty argument leads to config/routes.rb)
Leader + r + oGo straight to config/routes.rb
F10 or Leader + r + mChoose from app/models.
F11 or Leader + r + vChoose from app/views.
F12 or Leader + r + cChoose from app/controllers.
GUI
CTRL + oDialog for open file.
CTRL + ALT + sSave as dialog.
CTRL + ALT + fChoose font dialog.
alt + nchoose n-th tab, where n is from 0..9.
Navigation in NERDTree
c + dChange directory to hovered dir.
Shift + iShow hidden files.
Shift + uGo up in directory structure.
Shift + cGo to hovered directory.
mModify hovered file/dir.
sSplit hovered file/dir vertically.
tOpen file in new tab.

UI

Gvim uses gtk fixes in .gtkrc-2.0-vim to set colors of gtk backround and tabs. Adjust these values as you like.
Default theme is Monokai colorscheme port from Textmate. If you want Monaco font (Textmate Monospaced font), follow this guide and then
change font in .vimrc like this

set guifont=Monaco\ for\ Powerline\ 9

If you are not interested in relative numbering in Insert mode, comment out these lines in .vimrc

autocmd InsertEnter * :set relativenumber
autocmd InsertLeave * :set number

Code snippets

This bundle uses Snipmate Snippets, so check out the Ruby and Rails snippets definitions to speed up your coding.

Contribution

Vim configuration files are mainly based on my dotfiles, kremso's dotfiles and keyboard mappings in Janus: Vim distribution.

If you know about some cool plugin that we've missed, send us a pull request.

Follow the common rules:

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

This code is free to use under the terms of the MIT license.

Copyright (c) 2013 Samuel Molnár

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

添加新评论