Ⅰ. 插件描述
An attempt at The Ultimate Vim Configuration™ with focus on Rails development. DEPRECATED, SEE https://github.com/vitaly/dotvim2Ⅱ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'astrails/dotvim-you-belong-with-me'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'astrails/dotvim-you-belong-with-me'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'astrails/dotvim-you-belong-with-me'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/astrails/dotvim
Ⅳ. 文档说明
## Dotvim
NOTE: this project is no longer supported. The development moved to the
Dotvim v2. Beta testers and
contributions are welcome.
An attempt at The Ultimate Vim Configuration™ ;)
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
- The list of installed bundles is in the
bundles.vim
IMPORTANT:
- Vundle was replaced with
Neobundle. See [Neobundleupgrade instructions](#upgrade_neobundle) 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
- Syntax plugins
- "Support" and "minor" plugins
- Misc Bindings
- Russian Translit Layout support
Installation
From your homedirectory (on Linux/Mac OSX):
git clone https://github.com/astrails/dotvim.git # or git@github.com:astrails/dotvim.git for sshln -sfn dotvim .vimln -sfn dotvim/vimrc .vimrccd .vim; make install
Note: if you already have
~/.vim~/.vimrcREMOVE THEM (you might want to backup them first :)
- create
~/.vimrc.beforeor~/.vimrc.afterif you want to have some
local/personal settings you don't want to commit into the repo. see "Local Configuration"
IMPORTANT
- always add a
colorschemeto your~/.vimrc.afterfile. Even if you
use the defaults scheme addcolorscheme default. Othewise you will get ahighlighting error
"E411: highlight group not found: Normal"during vim
startup.
- vim-airline requires some extra glyphs to work properly. Check
the official documentation on [font >installation](https://github.com/bling/vim-airline#integrating-with-powerline-fonts)
and follow the instructions. If you do not, then strange symbols will be
displayed instead (can be fixed by configuring it to use regular fonts. see
help)
Neobundle Upgrade
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.
Note: if you modified your
bundles.vimyou will need to replace all
instances ofBundlewithNeoBundlein it. Until you do your vim might
print error messages during startup. ignore them and fix thebundles.vim,
then runmake.
General configuration
, is used as mapleaderbackslash is used as localleader
,emapped to:e **/. essentially you do,efoo<tab>to get a list of all files starting with foo,s- toggle invisible characters display,n- nextquicklistresult (like :Ggrep etc),N- previousquicklistresult (like :Ggrep etc)Ctrl-E- switch between 2 last buffers (its just a:b#<cr>:)Ctrl-Nto cancel current search highlighing,fglobal 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 configuration
For 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
- 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 like NeoBundle '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
- 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
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 Undo
Persistent undos are enabled by default.
You can disable by adding the following to your ~/.local.vim:
set noundo
Macros
I included a couple of macros that I frequently use in macros.vim which
is loaded from after.vim:
@q(re)format paragraph forward@senclose 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.
"Interesting" Plugins:
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 filewhile 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.,.-CtrlPClearCachefollowed 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.
- AutoComplPop (top)
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
,yto show the yankring,[/,]- to cycle the just-pasted text though the yankring.:h yankring.txtand:h yankring-tutorialfor more
A Git wrapper so awesome, it should be illegal
:GstatusBring up the output of git-status in the preview
- Press
-to stage or unstage the file on the - Press
pto do so on a per hunk basis
- Press
(--patch). Press
Cto invoke :Gcommit.- Press
:Gcommit [args]A wrapper around git-commit.
:Ggrep [args]:grep with git-grep as 'grepprg'.
,gshortcut to run :Ggrep
//global git search for the word under the cursor for for selection (in visual mode)
:GblameRun 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 (top)
syntax checking plugin
it will display the number of syntax errors in the current file in the vim's status line.
use
:Errorsto display a window detailing the errors - snipmate (top)
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/Sin 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 ofack. 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_searcherorport 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
iinstead ofrvai/vii- select indent block including / excluding the outer linesyai/yii- yank ...
Replace a pattern across multiple files interactively
Use
:Gsearchto search for a pattern. Edit the result buffer to your
liking, then:Greplaceto 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-airline (top)
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 = trueBindings:
-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 ;)
- vim-endwise (top)
Wisely add "end" in ruby, endfunction/endif/more in vim script, etc
- delimitMate (top)
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
- vim-dispatch (top)
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
:Dispatchfrom inside a Rails rspec file.:h dispatchfor more
info. - unite.vim (top)
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 colorschemeThen 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},- See
:h switchfor more.
- See
- Switch (top)
emmet.io like html/css workflow plugin.
- editorconfig-vim (top)
.editorconfig file support.
Ruby/Rails 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 railsfor much more info ;)
Lightweight support for Ruby's Bundler
gfwhen standing over a gem name in a Gemfile will go to gem's directory:Bopen NAMEdoes bundle open NAME - opens gem NAME's lib diretory in the current window.:Bundle- runs bundler
- vim-rake (top)
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
Org mode and support plugins
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
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 ;)
Universal Text Linking plugin allow to open urls from text files.
:h utl_usrto read the help.Bindings:
,o- types:Utl. you still need to press enter toopen 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
.orgfile to start using it. read the help::h VimOrganizerYou can find cheat sheet here
Working with TODO help is here
Org mode site is [here](http://orgmode.org/]
Color themes
- vim-colors-solarized (top)
precision colorscheme for the vim text editor
- vim-vividchalk (top)
A colorscheme strangely reminiscent of Vibrant Ink for a certain OS X editor
Syntax plugins
- vim-tmux
syntax suupport (extracted from tmux-1.1)
- Puppet-Syntax-Highlighting
Syntax Highlighting for Puppet
- JSON.vim
synntax highlighting file for JSON
- vim-cucumber
syntax, indent, etc. for Cucumber
- vim-haml
HAML syntax etc.
- vim-markdown
syntax for Markdown
- vim-coffee-script
syntax for Coffee script
- jade.vim
syntax for Jade
- vim-slim
Slim syntax support.
- stylus
TBD
- vim-gocode
Golang syntax support
- Dockerfile.vim
Syntax for Docker build files.
- vim-less
Syntax for LESS.
- vim-mustache-handlebars
Syntax for mustache and
handlebars templates. - Clojure syntax support by the following plugins:
vim-clojure-static
vim-fireplace
rainbow_parenthesesrainbow_parentheses can be useful to other languages as well ;)
- Rust support.
using files from rust repository
"Support" and "minor" plugins
- vim-textobj-user
Support for user-defined text objects
- vim-repeat
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
Misc Bindings
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.
]ppaste with autoindent.gaprint ascii value of character under the cursorg#like "#", but without using "<" and ">"g<display previous command outputztscroll cursor line to topzzscroll cursor line to centerzbscroll cursor line to bottomCTRL-W xexchange current window with n-th window (or next if no count given)gvreselect last selectiongtnext tabgTprev tabcichange inside delimitersdidelete inside delimiters@@execute last macro"xyycopy line intoxregister (replace x with any other)<C-R>xwhile in insert mote will paste content of register x (replace x with any other)"xppaste from register x:regDisplay the contents of all numbered and named registers.
Russian Translit Layout support
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
writer.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.
Copyright
© 2012 Vitaly Kushner