See Mislav's Vim configuration for inspiration.
Prerequisites: ruby, git.
- Move your existing configuration somewhere else:
mv ~/.vim* ~/.gvim* my_backup - Clone this repo into ".vim":
git clone https://github.com/rpond-pa/vimfiles ~/.vim - Go into ".vim" and run "rake":
cd ~/.vim && rake
This will install "/.vimrc" and "/.gvimrc" symlinks that point to
files inside the ".vim" directory.
-
2 spaces, no tabs
-
incremental, case-insensitive search
-
vertical split goes right, horizontal split goes below
-
cursor keys for movement are disabled!
-
<CR>- remove highlighting after search -
<C-j/k/h/l>- switch between splits (no need to prepend<C-w>) -
Q- format lines -
:KillWhitespace- strip trailing whitespace
,f- fuzzy file search,F- fuzzy file search within the current directory,b- fuzzy search your current buffers
Within the Command-T prompt:
<C-j/k>- move down/up between file matches<C-n/p>- move down/up between file matches<C-s/v>- open file in new horizontal/vertical split<C-c>- close the window
Command-T is build using Ruby and requires you to build vim with Ruby support.
Using rbenv, I needed to rebuild vim and the Command-T plugin using the same version of Ruby.
See this excellent post for more information.
Getting Command-T to work with brew, rbenv, and vim is not for the faint of heart.
Here is what I had to do to get it to work:
- Install system wide ruby using rbenv
- Reinstall vim using brew: brew install vim --override-system-vi --with-ruby
- Rebuild command-t using the system rbenv ruby.
:Ack -w foo_bar:Ack!- search, but don't jump to first match:AckFromSearch:AckAdd- append to existing quickfix list
In the quickfix window:
o- open filego- preview file, i.e. keep focus in quickfix windowt(T) - open in a new tab (silently)h(H) - open in horizontal split (silently)v(gv) - open in vertical split (silently)
In the normal buffer:
:cn[ext]/:cN/:cp[revious]- jump to the next/previous match]q/[q- same as above, with Unimpaired:ccl- close the quickfix window:col[der]/:cnew[er]- show results of previous/next search
cs"'- change string from double to single quotesds(- delete surrounding parenthesesysiW]- surround current WORD with square bracketsysst- surround current line in a HTML tagysip<c-t>- nest current paragraph in a HTML tag
Visual mode: S. Insert mode: <c-s>.
Surround + rails.vim:
-→<% -%>=→<%= %>#→<%# %>e- nest block and appendendkeywordE- likee, but prompt for text to prepend before block
gc{motion}- comment/uncomment lines that {motion} moves overgcc- comment/uncomment [count] lines{Visual}gc- comment/uncomment the highlighted linesgcu- uncomment the current and adjacent commented lines
Motions:
]m/[m- next / previous method]M/[M- end of method definition]]/[[- next / previous class/module][/[]- end of class/module
Text objects:
am- a methodim- inner methodaM- a classiM- inner class
:[range]CoffeeCompile [vert]- compile JavaScript into new buffer:CoffeeCompile watch [vert]- open auto-updating JavaScript buffer:[range]CoffeeLint(needscoffeelint):[range]CoffeeRun- run the resulting JavaScript
% alternates between matching HTML tags, class/control flow statements and
matching end in Ruby, and more. Also works in visual mode.
Uses the vim numbers plugin to provide relative and absolute line numbers.
See the numbers github project for more information.
-
:Gcommit -
:Gstatus- jump between lines that represent files with
<c-n>,<c-p> -- add/reset file (also in visual mode)<Enter>- open current file in the window belowo/S-:Gsplit/:Gvsplitp- add/reset current file with--patchD-:Gdiffc[v]c-:Gcommit [--verbose]ca/cA---append/ reuse message
- jump between lines that represent files with
-
:[range]Gbrowse! -- copy GitHub URL for code that's currently selected -
:[range]Gblameq/gq- close blame and return to blamed window / work tree version<CR>- q, then open commito/O- open commit in horizontal split / new tab-- reblame at commitP- reblame at parent commit
-
:Gedit feature:%- version of the current file in the "feature" branch -
:Gwrite-add % -
:Gread-checkout %(also the bailout command after browsing git objects) -
:Gremove-rm % -
:Gmove <dest>-mv % <dest> -
:Glog- load past versions of current file into the quickfix list -
:Glog --- load all commits into the quickfix list -
:Glog -- %- load only commits that touch the current file -
:Glog --grep={text} --- only commits that have "text" in the message -
:Glog -S{text} --- only commits that have "text" in the diff -
:Ggrep {pattern} [branch]
In git objects:
<Enter>- jump to revision under cursoro/S/O- jump to revision in a new split / vertical split / tab
In vimdiff view:
[c/]c- previous/next changeset:dp/:do-:diffput/:diffget- stage/checkout hunk:Gwrite/:Gread- stage/checkout file:do //2/:do //3- resolve conflict using the version from target/merge branch:diffu[pdate]- refresh diff highlighting:on[ly],<C-w>o- close windows other than the current one