ssjr / vimfiles

Awesome vimfiles for Ruby/Rails development

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Great vimfiles for Ruby/Rails development

Support for Rails, Git, RVM, Sparkup, Haml, Slim, Sass, Less, CoffeeScript, Markdown Rdoc, and Jade with nice colour schemes.

Requirements

Vim 7.3 or better Tested on MacOS

Quick Install

curl https://raw.github.com/josemarluedke/vimfiles/master/install.sh -o - | sh

Usage

Basic Mappings

The leader is mapped to \

In Normal mode (Esc)

\] - File browser (NerdTree)

\f - Find in Files (Command-t)

\a - Search in files (Silver Searcher)

\Space - Remove search highlighting

Command + / (with gui) and \/ (without gui) - Toggle comments (NERD Commenter)

\m - Jump to model

\v - Jump to view

\gm - Find in app/models

\gc - Find in app/controller

\gv - Find in app/views

\ga - Find in app/assets

\gr - Open routes in split

\gg - Open Gemfile in split

Command + [ or Command + ] - Textmate-like indentation

\l - Open tag list (Tagbar)

<C-h> <C-j> <C-k> <C-l> - Switching between windows

In Insert mode (i)

<tab> - auto complete or expand snippet

See .vimrc for more.

Plugins

Lots of stuff - get to know this plugin!

:Rmodel - jump to model

:Rview - jump to view

:help rails

CoffeeScript support

:CoffeeCompile watch show compiled js in split

Sparkup (ctrl+e)

Expand CSS selectors div.event in to markup <div class='event'></div>

http://net.tutsplus.com/articles/general/quick-tip-even-quicker-markup-with-sparkup/

Git integration

Lots of stuff

:Gstatus and press - to stage file

http://vimcasts.org/episodes/fugitive-vim---a-complement-to-command-line-git/

:help fugitive

Use:

:%Subvert/facilit{y,ies}/building{,s}/g

Instead:

:%s/facilities/buildings/g
:%s/Facilities/Buildings/g
:%s/FACILITIES/BUILDINGS/g

Coercion

Want to turn fooBar into foo_bar? Press crs (coerce to snake_case). MixedCase (crm), camelCase (crc), snake_case (crs), and UPPER_CASE (cru) are all just 3 keystrokes away.

Rename the current file

:rename[!] {newname}

Insert a dummy text of a certain length

:Loremipsum[!] [WORD	COUNT] [PARAGRAPH_TEMPLATE] [PREFIX POSTFIX]

Run your Ruby tests! Supports RSpec, Test::Unit/MiniTest, and Cucumber. For more information, check out the documentation or :help vroom

With bufexplorer, you can quickly and easily switch between buffers by using the one of the default public interfaces:

'\be' (normal open)  or
'\bs' (force horizontal split open)  or
'\bv' (force vertical split open)

Format your javascript souce code.

:BufOnly without an argument will unload all buffers but the current one.

:BufOnly with an argument will close all buffers but the supplied buffer name/number.

Add RVM integration

CtrlP (\f)

Find files in your project with minimal keypresses

For example conadus would find controllers/admin/users

/f path_or_filename

/gf path_or_filename - restrict to files in current directory

Snipmate (TAB)

Snippets, press TAB to expand

Examples (in a Ruby file):

def<tab>

.each<tab>

.eado<tab>

ife<tab>

Gist (:Gist)

Gist current file/selection

Requires setting GITHUB_TOKEN and GITHUB_USER Env's

Align stuff

 \a= :Tabularize /=
 \a: :Tabularize /:
 \a:: :Tabularize /:\zs
 \a, :Tabularize /,
 \<Bar> :Tabularize /<Bar>

http://vimcasts.org/episodes/aligning-text-with-tabular-vim/

Neerd Commenter (Command + / or \/)

Comment/Uncomment stuff out

Ack (\a)

Search project for text (aka find in files)

\a word

\a "some words"

Ag (:Ag)

Alternative of Ack, using 'the_silver_searcher' on homebrew.

Project file browser

\] opens file browser

o / x open and close files/folders

m menu to move/delete/copy files/folders

? Help

I use nerdtree for creating or moving files, but find command-t quicker for opening files.

Surround (ys/cs/ds)

Allows adding/removing/changing of surroundings

I would highly recommend getting to know this plugin, it is very useful. Especially when you grok text objects.

Characters

ysiw) - surround inner word with ()

ysiw( - surround inner word with ( )

In the above example iw can be replaced with any text object or motion.

If you find yourself manually adding surroundings, stop and work out the correct text object or motion.

cs"' - change surrounding from " to '

ds - delete surrounding

Tags

yss<p> - surround line in <p> tags

cst<div> - change surround tag to <div>

A colour scheme, both light and dark version

:set background=dark

:set background=light

Tagbar (/l)

Lists method names, provide auto complete

Run ctags -R or \rt in project root to generate tags

Powerline is a utility plugin which allows you to create better-looking, more functional vim statuslines.

See instructions for install the fontpatcher here.

Syntax checking

When a file is saved the syntax is automatically checked and any errors reported.

Plugin manager and part of the reason why my vimfiles as so compact

Run Rspec specs from Vim

\t run the full spec file

\s run the spec file under the cursor

\l rerun the previous spec command

This version of vim-rspec uses iTerm as default terminal. The original version uses the Terminal app.

True Sublime Text style multiple selections for Vim

Installation

Note: If you are using RVM make sure you use system ruby before installation.

rvm use system

Note: If you already have Vim installed ensure it has support for Ruby:

vim --version | grep ruby

You should see +ruby, if you see -ruby you need to reinstall Vim with Ruby support

Install Vim (if not already installed)

MacOS: MacVim / Vim

brew install macvim --override-system-vim --enable-clipboard

Add /usr/local/bin before /usr/bin in your $PATH so you use the version of vim installed by Homebrew, not the one that comes with MacOS.

By installing Vim in this way MacVim and regular Vim are exactly the same.

Ubuntu: gVim / Vim

Server

apt-get install vim-nox

Desktop

apt-get install vim-gnome

GNU/Linux from source

If you have an old GNU/Linux distro which does not have Vim 7.3 or better in its repos then install from source.

The configure options below leave out any GUI related features as I have only compiled Vim on a server.

Vim source is in a hg (Mercurial) repository so you need to install the hg client first, e.g. sudo apt-get install mercurial.

hg clone https://vim.googlecode.com/hg/ vim
cd vim/vim73
./configure
./configure --with-features=huge --enable-cscope --enable-pythoninterp --enable-rubyinterp --enable-perlinterp --enable-multibyte
make
sudo make install

This installs Vim to /usr/local/bin, check this is in your $PATH before /usr/bin which may contain an older system version of Vim.

If you get an error no terminal library found install libncurses5-dev.

Install these vimfiles

Note: You will already have a ~/.vim folder, either delete or move it.

mv ~/.vim ~/.vim.old
git clone https://github.com/josemarluedke/vimfiles ~/.vim
cd ~/.vim
rake install
ln -s ~/.vim/vimrc ~/.vimrc

or run:

curl https://raw.github.com/josemarluedke/vimfiles/master/install.sh -o - | sh

To update to the latest vimfiles

cd ~/.vim
rake update

Install Dependacies

MacOS

brew install ack
brew install ctags

Alternative to Ack

brew install the_silver_searcher

More info here.

Note: MacOS comes with the BSD version of ctags which is not compatible.

Ubuntu

sudo apt-get install exuberant-ctags
sudo apt-get install ack-grep
sudo ln -s /usr/bin/ack-grep /usr/local/bin/ack

Screens

Solarized Solarized MacVim

Molokai Molokai MacVim

Molokai with transparency Molokai MacVim

Thanks for inspiration

About

Awesome vimfiles for Ruby/Rails development


Languages

Language:Vim Script 92.2%Language:Ruby 4.6%Language:Shell 3.2%