Skip to content

Latest commit

 

History

History
417 lines (259 loc) · 13.3 KB

README.markdown

File metadata and controls

417 lines (259 loc) · 13.3 KB

This is a complete Vim configuration that I'm using everywhere

The config is using Vundle for easy upgrading.

Some help tips are provided for some of the plugins. please check out the plugin's docs for more info.

Installation

From your homedirectory (on Linux/Mac OSX):

  • git clone git://github.com/astrails/dotvim.git
  • ln -sfn dotvim .vim
  • ln -sfn dotvim/vimrc .vimrc
  • cd .vim; make install
  • create ~/.vim_local if you want to have some local/personal settings you don't want to commit into the repo

Note: if you already have ~/.vim ~/.vimrc REMOVE THEM (you might want to backup them first :)

General configuration

, is used as mapleader backslash is used as localleader

  • ,e mapped to :e **/. essentially you do ,efoo<tab> to get a list of all files starting with foo
  • ,s - toggle invisible characters display
  • ,n - next quicklist result (like :Ggrep etc)
  • ,N - previous quicklist result (like :Ggrep etc)
  • Ctrl-E - switch between 2 last buffers (its just a :b#<cr> :)
  • Ctrl-N to cancel current search highlighing
  • ,f global Ggrep for word under the cursor or for selection
  • +, - - easily inc/decrement integers
  • ,W - remove trailing spaces
  • Ctrl-g/h/j/k - simplified split panes navigation

Check out the 'plugins.vim' and 'after/plugin/bindings.vim' files for more...

"Interesting" Plugins:

  • nerdtree

    hax0r vim script to give you a tree explorer

    • Ctrl-P - open directory browser
    • ,p - to find and highlight the currently open file in the tree
  • nerdcommenter

    Vim plugin for intensely orgasmic commenting

    • ,/ - toggle comment
    • ,cc - add commenting
    • ,cu - Uncomment
    • check docs for more
  • Command-T

    TextMate Command-T like file finder for vim

    • ,, - find file
    • ,. - refresh the file list and then find a file
    • while at the finder prompt:
      • Ctrl-Enter - open file in a new split
      • Ctrl-s - open file in a new split
      • Ctrl-v - open file in a new vertical split
      • Ctrl-U - clear current partial path
      • Esc - cancel
      • Ctrl-c - cancel
  • AutoComplPop

    Automatically opens popup menu for completions

    Shouldn't require config.

  • taglist.vim

    Source code browser (supports C/C++, java, perl, python, tcl, sql, php, etc)

    • ,t - toggle tags window
  • YankRing.vim

    Maintains a history of previous yanks, changes and deletes

    • ,y to show the yankring
    • ,[/,] - to cycle the just-pasted text though the yankring.
    • :h yankring.txt and :h yankring-tutorial for more
  • vim-fugitive

    A Git wrapper so awesome, it should be illegal

    • :Gstatus

      Bring up the output of git-status in the preview window. Press - to stage or unstage the file on the cursor line. Press p to do so on a per hunk basis (--patch). Press C to invoke :Gcommit.

    • :Gcommit [args]

      A wrapper around git-commit.

    • :Ggrep [args]

      :grep with git-grep as 'grepprg'.

    • ,g

      shortcut to run :Ggrep

    • //

      global git search for the word under the cursor for for selection (in visual mode)

    • :Gblame

      Run git-blame on the file and open the results in a scroll bound vertical split. Press enter on a line to reblame the file as it was in that commit.

    Much more in the plugin's doc

  • syntastic

    syntax checking plugin

    it will display the number of syntax errors in the current file in the vim's status line.

    use :Errors to display a window detailing the errors

  • snipmate

    TextMate-style snippets for Vim

    write a snipped text and press TAB to expand it.

    To see the list of available snippets type Ctrl-R <Tab> in the insert mode

  • vim-surround

    Delete/change/add parentheses/quotes/XML-tags/much more with ease

    • dsX - delete surround X
    • csXY - change surround X with Y
    • s/S in visual mode - wrap selection
    • ysMovementX - surround movement with X

    You should REALLY read the docs if you want to use this one

  • vim-align

    Align and AlignMaps lets you align statements on their equal signs, make comment boxes, align comments, align declarations, etc.

    • ,t= - align on =
    • ,tsp - align on whitespace
    • ,t, - align on commas
    • ,t| - align on vertical bars
    • ,acom - align comments (C/C++)
    • :AlignSEPARATORS - align on separators
    • :h align - see help for more options
  • ack.vim

    This plugin is a front for the Perl module App::Ack. Ack can be used as a replacement for 99% of the uses of grep.

    • :Ack [options] {pattern} [{directory}] - grep for the pattern in side directory and open result in a QuickFix window
    • :Ack --ruby ... - search only ruby files.
    • :h Ack - more help about Ack
  • vim-indentobject

    A text object for manipulating blocks based on their indentation

    This is good for Python, YAML, HAML etc.

    Usage is similar to textobj-rubyblock, just with i instead of r

    • vai / vii - select indent block including / excluding the outer lines
    • ...
  • greplace.vim

    Replace a pattern across multiple files interactively

    Use :Gsearch to search for a pattern. Edit the result buffer to your liking, then :Greplace to incorporate your edits into the source files

    • :Gsearch - Search for a given pattern in the specified group of files and display the matches in the replace buffer.
    • :Gbuffersearch - Search for a given pattern in all the buffers in the Vim buffer list.
    • :Greplace - Incorporate the modifications from the replace buffer into the corresponding files.
  • vim-powerline

    TBD

  • threesome.vim

    A plugin for resolving conflicts during three-way merges.

    Add the following lines to ~/.gitconfig to use

    [merge] tool = threesome

    [mergetool "threesome"] cmd = "mvim -f $BASE $LOCAL $REMOTE $MERGED -c 'ThreesomeInit'" trustExitCode = true

    Bindings:

    • \g - switch to grid view

    • \l - switch to loupe view

    • \c - switch to compare view

    • \p - switch to path view

    • \o - select the original file

    • \1 - select file one

    • \2 - select file two

    • \r - select the results file

    • \n - next unresolved conflict

    • \N - prev unresolved conflict

    • \<space> - cycle layout

    • \s - toggle scrolllocking

    • \d - cycle diff combinations

    • \D - turn off all diffs

    • \CC - exits vim with error code (like :cquit). this will indicate to git that merge resolution failed

    • :h threesome - you should probably read it ;)

  • vim-endwise

    Wisely add "end" in ruby, endfunction/endif/more in vim script, etc

  • delimitMate

    auto-completion for quotes, parens, brackets, etc. in insert mode.

Ruby/Rails support:

  • vim-rails

    Ruby on Rails: easy file navigation, enhanced syntax highlighting, and more

    • :AV - open "alternate" file in a new vertical split
    • :AS - open "alternate" file in a new horizontal split
    • :RV - open "related" file in a new vertical split
    • :RS - open "related" file in a new horizontal split
    • :Rextract - extract partial (select text for extraction first)
    • :Rinvert - takes a self.up migration and writes a self.down.
    • gf - remapped to take context into account. recognizes models associations, partials etc.
    • :h rails for much more info ;)
  • vim-bundler

    Lightweight support for Ruby's Bundler

    • gf when standing over a gem name in a Gemfile will go to gem's directory
    • :Bopen NAME does bundle open NAME - opens gem NAME's lib diretory in the current window.
    • :Bundle - runs bundler
  • vim-rake

    TBD

  • vim-textobj-rubyblock

    A custom text object for selecting ruby blocks.

    In other words it teaches vim to understand what is ruby block, just like vim already understands what is word, paragraph, sentence etc.

    It works with begin/end, if/else/end etc.

    • var - select ruby block around the cursor including begin/end
    • vir - select insides of a ruby block around the cursor not including begin/end
    • dar - delete ruby block around the cursor
    • etc...

    Some 'trickier' usage patterns.

    • varar - select the ruby block that is around the ruby block that is around the cursor. including begin/end
    • vararir - select insides of the ruby block that is around the ruby block that is around the cursor. not including begin/end
    • ...
  • vim-ruby-refactoring

    Refactoring tool for Ruby in vim!

    • ,rap :RAddParameter - Add Parameter(s) to a method
    • ,rcpc :RConvertPostConditional - Convert Post Conditional
    • ,rel :RExtractLet - Extract to Let (Rspec)
    • ,rec :RExtractConstant - Extract Constant (visual selection)
    • ,relv :RExtractLocalVariable - Extract Local Variable (visual selection)
    • ,rit :RInlineTemp - Inline Temp. replace temp parameter by direct function call
    • ,rrlv :RRenameLocalVariable - Rename Local Variable (visual selection/variable under the cursor
    • ,rriv :RRenameInstanceVariable - Rename Instance Variable (visual selection)
    • ,rem :RExtractMethod - Extract Method (visual selection)
  • apidock.vim

    Vim plugin that searches http://apidock.com Ruby, Rails, and RSpec docs from within Vim.

    • RR - Search the Rails docs for the word under the cursor.
    • RB - Search the Ruby docs for the word under the cursor.
    • RS - Search the RSpec docs for the word under the cursor.

Color themes

Syntax plugins

"Support" and "minor" plugins

  • vim-textobj-user

    Support for user-defined text objects

  • vim-repeat

    Use the repeat command "." with supported plugins

  • vim-space

    Smart Space key for Vim

    press SPACE to repeat last motion command

Misc

The following is a list of commands and key bindings that I personally find interesting stored for easy refreshing my memory of them. there is no much 'system' to it, just randomly chosen bits of vim goodness.

  • ga print ascii value of character under the cursor
  • g# like "#", but without using "<" and ">"
  • g< display previous command output
  • zt scroll cursor line to top
  • zz scroll cursor line to center
  • zb scroll cursor line to bottom
  • CTRL-W x exchange current window with n-th window (or next if no count given)
  • gv reselect last selection
  • gt next tab
  • gT prev tab
  • ci change inside delimiters
  • di delete inside delimiters
  • @@ execute last macro
  • "xyy copy line into x register (replace x with any other)
  • <C-R>x while in insert mote will paste content of register x (replace x with any other)
  • "xp paste from register x
  • :reg Display the contents of all numbered and named registers.

Currently disabled