NOTE: this project is no longer supported. The development moved to the Dotvim v2. Beta testers and contributions are welcome.
All the right plugins are in. Nerdtree, CtrlP, you name it.
The focus is on supporting Rails, but there is a lot of generic stuff too, so it will surely serve you well with any language of your choice.
The config is using NeoBundle for easy
upgrading. The list of installed bundles is in the bundles.vim
IMPORTANT:
- Vundle was replaced with Neobundle. See Neobundle upgrade instructions if you have an older Vundle based install.
- vim-powerline was replaced with vim-airline. Please see installation instructions
Some help tips are provided for some of the plugins. please check out the plugin's docs for more info.
Follow @vkushner and @astrails on Twitter to receive announcements of new versions, tips, etc.
#### Contents- Installation
- Neobundle upgrade
- General Configuration
- Local configuration
- Backups
- Persistent Undo
- Macros
- Interesting Plugins
- nerdtree
- nerdtree-tabs
- nerdcommenter
- Command-T
- CtrlP
- AutoComplPop
- taglist.vim
- YankRing.vim
- vim-fugitive
- syntastic
- snipmate
- vim-surround
- vim-align
- ack.vim
- vim-indentobject
- greplace.vim
- vim-airline
- splice.vim
- vim-endwise
- delimitMate
- Gundo
- vim-dispatch
- unite.vim
- vim-gitgutter
- vim-i18n
- switch
- emmet-vim
- editorconfig
- Ruby/Rails Support
- Org mode and support plugins
- Color themes
- Syntax plugins
- "Support" and "minor" plugins
- Misc Bindings
- Russian Translit Layout support
From your homedirectory (on Linux/Mac OSX):
-
git clone https://github.com/astrails/dotvim.git # or git@github.com:astrails/dotvim.git for ssh
-
ln -sfn dotvim .vim
-
ln -sfn dotvim/vimrc .vimrc
-
cd .vim; make install
Note: if you already have
~/.vim
~/.vimrc
REMOVE THEM (you might want to backup them first :) -
create
~/.vimrc.before
or~/.vimrc.after
if you want to have some local/personal settings you don't want to commit into the repo. see "Local Configuration"
Dotvim was updated to use Neobundle instead of Vundle. NeoBundle is mostly similar but supports more ways to install bundles, better install, locked revisions and more.
To upgrade from an older Vundle based setup simply pull the latest version and
run make
.
#### General configurationNote: if you modified your
bundles.vim
you will need to replace all instances ofBundle
withNeoBundle
in it. Until you do your vim might print error messages during startup. ignore them and fix thebundles.vim
, then runmake
.
,
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
- nextquicklist
result (like :Ggrep etc),N
- previousquicklist
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 spacesCtrl
-h
/j
/k
/l
- simplified split panes navigation,d
-:diffupdate
,dp
-:diffput
,dg
-:diffget
%%
- in control mode, i.e. after you typed:
it will expand to the directory name of the currently opened file.
Check out the 'plugins.vim' and 'after/plugin/bindings.vim' files for more...
#### Local configurationFor easy upgrades its preferable not to change the dotvim configuration files. Instead you can add your own local configuration into one of the local override files. There are several override files supported by dotvim.
They are loaded in the following order:
-
base dotvim configuration (global, plugin configurations, bindings, macros)
-
~/.vimrc.bundles
Loads additional bundles inside the
neobundle#begin/end
block. Should contain lines likeNeoBundle 'my-custom/bundle'
-
~/.local-before.vim
[deprecated] -
~/.vimrc.before
Loaded before the plugins
This is where you should pre-set various plugin flags, enable/disable options etc. This is for things you would normally put into your vimrc file.
-
~/.gvimrc.before
[when GUI running] -
vim plugins
-
dotvim bindings and overrides (loaded from
~/.vim/after.vim
) -
.local-after.vim
[deprecated] -
.vimrc.after
Loaded after the plugins
This is where you can override settings set by plugins that have no customization options.
-
.gvimrc.after
[when GUI running]
Backups and swapfiles are disabled. I really hate them both.
You can re-enable backups by adding the following to your ~/.local.vim
:
set backup
and swapfiles by
set swapfile
backup dir is set to ~/.backup/
The directory is created if it doesn't exist.
#### Persistent UndoPersistent undos are enabled by default.
You can disable by adding the following to your ~/.local.vim
:
set noundo
I included a couple of macros that I frequently use in macros.vim which is loaded from after.vim:
@q
(re)format paragraph forward@s
enclose selection with double *. e.g. **foo**.
You really should start writing your own macros. The life will never be the same ;).
I recommend editing your macros in a vim buffer.
To load a macro into a register you can 'yank' it.
For example if you have a line with a macro and cursor is at the beginning of
it "ay$
will load the macro into register a
, so that you will be able to
execute it with @a
.
-
hax0r vim script to give you a tree explorer
Ctrl-P
- open directory browser (Note: this is now handled by nerdtree-tabs (see below)),p
- to find and highlight the currently open file in the tree
-
NERDTree and tabs together in Vim, painlessly
Ctrl-P
- open directory browser
-
Vim plugin for intensely orgasmic commenting
,/
- toggle comment,cc
- add commenting,cu
- Uncomment- check docs for more
-
TextMate Command-T like file finder for vim
Note: This plugin is currently DISABLED. See CtrlP plugin that is used instead
,,
-CommandT
- find file,.
-CommandTFlush
- refresh the file list and then find a file- while at the finder prompt:
Ctrl-Enter
- open file in a new splitCtrl-s
- open file in a new splitCtrl-v
- open file in a new vertical splitCtrl-U
- clear current partial pathEsc
- cancelCtrl-c
- cancel
-
Fuzzy file, buffer, mru, tag, etc finder.
This is the new fuzzy finder used by dotvim. It replaced Command-T that was used before.
The default mapping is still the same:
,,
-CtrlP
- fuzzy find.,.
-CtrlPClearCache
followed byCtrlP
- clears the cache and searches the files (not including MRU and buffers),m
-CtrlPBufTag
- search tags in the current buffer,M
-CtrlPBufTagAll
- search tags in all buffers,l
-CtrlPLine
- fuzzy search lines in all opened buffers,b
-CtrlPBuff
- fuzzy search open buffers,,?<ENTER>
- to quickly open help for CtrlP
This plugin has lots of options, see :h ctrlp
for more.
-
Automatically opens popup menu for completions
Shouldn't require config.
-
Source code browser (supports C/C++, java, perl, python, tcl, sql, php, etc)
,t
- toggle tags window
-
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
-
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. Pressp
to do so on a per hunk basis (--patch). PressC
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
-
-
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 -
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 -
Delete/change/add parentheses/quotes/XML-tags/much more with ease
dsX
- delete surround XcsXY
- change surround X with Ys/S
in visual mode - wrap selectionysMovementX
- surround movement with X
You should REALLY read the docs if you want to use this one
-
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
-
This plugin is a front for ag, A.K.A. the_silver_searcher. Ag can be used as a replacement for 153% of the uses of
ack
. This plugin will allow you to run ag from vim, and shows the results in a split window.:Ag [options] {pattern} [{directory}]
- grep for the pattern in side directory and open result in a QuickFix window:h Ag
- more help about Ag
Installation:
- on OSX:
brew install the_silver_searcher
orport install the_silver_searcher
- on Ubuntu:
apt-get install silversearcher-ag
-
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 ofr
vai
/vii
- select indent block including / excluding the outer linesyai
/yii
- yank ...
-
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.
-
Lean & mean status/tabline for vim that's light as air.
A better replacement for vim-powerline. Optimized for speed; it loads in under a millisecond.
Install fonts for best results.
-
A plugin for resolving conflicts during three-way merges.
Add the following lines to ~/.gitconfig to use
[merge] tool = splice
[mergetool "splice"] cmd = "vim -f $BASE $LOCAL $REMOTE $MERGED -c 'SpliceInit'" 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 -
-q
- exits vim with success; this will indicate to git that merge succeeded -
:h splice
- you should probably read it ;)
-
-
Wisely add "end" in ruby, endfunction/endif/more in vim script, etc
-
auto-completion for quotes, parens, brackets, etc. in insert mode.
-
Homepage is here
Graphs your vim undo tree in a side window.
,u
- toggle undo window:h gundo.txt
- more help
-
Asynchronous build and test dispatcher from Tpope.
This plugin allows to run sync/async builds and other shell commands in background, with progress support.
try
:Dispatch
from inside a Rails rspec file.:h dispatch
for more info. -
Search and display information from arbitrary sources like files, buffers, recently used files or registers.
This plugins is to powerful to present here, read the documentation.
Just to give you the taste of it, try:
:Unite -no-start-insert -auto-preview colorscheme
Then try to navigate up and down and see what happens ;)
-
Vim Git Gutter (top) A Vim plugin which shows a git diff in the 'gutter' (sign column). It shows whether each line has been added, modified, and where lines have been removed.
In the screenshot above you can see:
- Line 15 has been modified.
- Lines 21-24 are new.
- A line or lines were removed between lines 25 and 26.
Commands:
:GitGutterDisable
:GitGutterEnable
:GitGutterToggle
:GitGutterSignsEnable
:GitGutterSignsDisable
:GitGutterSignsToggle
:GitGutterLineHighlightsEnable
:GitGutterLineHighlightsDisable
:GitGutterLineHighlightsToggle
Bindings:
]c
- jump to next hunk[c
- jump to previous hunk,hs
- stage hunk,hr
- revert hunk
There are quite some customization options. see help.
-
Extracts i18n strings from source files into .yml file.
,z
- extract selected string
-
A plugin to switch segments of text with predefined replacements
it will switch
"foo"
to'foo'
to:foo
. or{:foo => bar}
to{foo: bar}
, etc. See:h switch
for more. -
emmet.io like html/css workflow plugin.
-
.editorconfig file support.
-
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 ;)
-
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
-
TBD
-
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/endvir
- select insides of a ruby block around the cursor not including begin/enddar
- 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/endvararir
- select insides of the ruby block that is around the ruby block that is around the cursor. not including begin/end- ...
-
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)
-
Toggle ruby blocks style, e.g
{}
todo .. end
,B
- toggle block style
NOTE: thre is an unfortunate interaction with delimitMate, the opening brase gets completed. i.e. you get
{} ... }
-
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.
-
Lightweight Rspec runner for Vim.
Commands are self explanatory:
:call RunCurrentSpecFile()
:call RunNearestSpec()
:call RunLastSpec()
Bindings:
,r
-RunNearestSpec
Vim now has support for Emacs' Org mode provided by the VimOrganizer plugin.
Below you will also find a couple of plugins that support it, but can be also used intependently.
-
Calendar support w/o calling external programs.
- Commands:
:Calendar
- open calendar:Calendar 2012 8
- open calendar for 2012-08:CalendarH
- open horizontal calendar
- Bindings:
,cal
-:Calendar
,caL
-:CalendarH
- Commands:
-
A Narrow Region Plugin (similar to Emacs)
Allows to open selected text in a separate buffer for editing preserving the rest of the file around it.
- Commands
[range]:NR
- open selection or range in a buffer. write the buffer when done:h NrrwRgn
- read the help ;)
- Commands
-
Universal Text Linking plugin allow to open urls from text files.
:h utl_usr
to read the help.Bindings:
,o
- types:Utl
. you still need to press enter too
pen url. This way it allows to type other commands if needed.
-
VimOrganizer is partly a clone of Emacs' Org-mode, and partly a front end to Org-mode itself. Do Org in Vim.
Some bindings:
tab
- cycle visibility of single headline/subtree.,1
- show level 1 only,2
- show level 1 only- ...
- In normal mode
Shift-Enter
- cycle TODO stateEnter
- add item of same level
- insert mode
Shift-Enter
- add item of same level
- Both modes
Ctrl-Enter
- add item of lover levelShift-Ctrl-Enter
- add item of higher level
,dd
- add DEADLINE,ds
- add SCHEDULED,dc
- add CLOSED,dt
- add a timestamp
Datetime prompt works mostly like the one in emacs org mode. See docs here
Its too big to give much userful information here. open any
.org
file to start using it. read the help::h VimOrganizer
You can find cheat sheet here
Working with TODO help is here
Org mode site is [here](http://orgmode.org/]
-
precision colorscheme for the vim text editor
-
A colorscheme strangely reminiscent of Vibrant Ink for a certain OS X editor
-
syntax suupport (extracted from tmux-1.1)
-
Syntax Highlighting for Puppet
-
synntax highlighting file for JSON
-
syntax, indent, etc. for Cucumber
-
HAML syntax etc.
-
syntax for Markdown
-
syntax for Coffee script
-
syntax for Jade
-
Slim syntax support.
-
stylus
TBD
-
Golang syntax support
-
Syntax for Docker build files.
-
Syntax for LESS.
-
Syntax for mustache and handlebars templates.
-
Clojure syntax support by the following plugins:
vim-clojure-static vim-fireplace rainbow_parentheses
rainbow_parentheses can be useful to other languages as well ;)
-
Rust support.
using files from rust repository
-
Support for user-defined text objects
-
Use the repeat command "." with supported plugins
-
Smart Space key for Vim
press SPACE to repeat last motion command
-
create gists on github
:Gist
- gist the buffer:'<,'>Gist
- gist selection:Gist -p
- private gist- :h Gist.vim
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.
]p
paste with autoindent.ga
print ascii value of character under the cursorg#
like "#", but without using "<" and ">"g<
display previous command outputzt
scroll cursor line to topzz
scroll cursor line to centerzb
scroll cursor line to bottomCTRL-W x
exchange current window with n-th window (or next if no count given)gv
reselect last selectiongt
next tabgT
prev tabci
change inside delimitersdi
delete inside delimiters@@
execute last macro"xyy
copy line intox
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.
There is ~/.vim/bindings-ru-translit.vim file.
OSX has a nice russian translit keyboard layout which I use when I need to write any russian text. The problem is that once I go to the normal mode nothing works. This is an attempt to make vim at least partially useful when the kerboard is in russioan translit mode and not in the default US mode. The idea is to remap the russian characters to the english characters that correspond to the same keyboard key. And a couple of userful multy-key combinations.
Similar can be done for other keyboard layouts, your pull requests are welcome ;).
To use this feature: just include the file from your ~/.local.vim:
source ~/.vim/bindings-ru-translit.vim
My attempt to make vim look like iWriter ;) You can read about the details on our blog.
In short, just do :so ~/.vim/writer.vim
when you are going to do some plain
text writing.
© 2012 Vitaly Kushner