Thanks to these guys:
- Gary Bernhardt,
- Drew Neil,
- Tim Pope,
- and the Janus project.
My configuration uses Pathogen and git submodules. (But you don't need to care about any of that.)
Prerequisites: ruby, git.
- Move your existing configuration somewhere else:
mv ~/.vim* ~/.gvim* my_backup - Clone this repo into ".vim":
git clone https://github.com/mislav/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
<CR>- remove highlighting after search<Space>- toggle current fold- vertical split goes right, horizontal split goes below
<C-j/k/h/l>- switch between splits (no need to prepend<C-w>)- cursor keys for movement are disabled!
Q- format lines,cf- search for merge conflicts in buffer:KillWhitespace- strip trailing whitespace
,,- toggle between two recently open buffers<C-p>- fuzzy file search<C-P>- search in directory of current buffer:CtrlP [dir]- search files:CtrlBuffer- search buffers:CtrlPTag- search tags:CtrlPBufTag- search tags in current buffer:CtrlPMixed- search in files, buffers and MRU
Inside the CtrlP prompt:
<C-j/k>- move down/up between file matches<C-n/p>- next/previous string in prompt's history<C-s/v>- open file in new horizontal/vertical split<C-y>- create a new file and its parent directories<C-z>- mark a file to be opened with<C-o><C-o>- open marked files
: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)
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
\\{motion}- comment/uncomment lines that {motion} moves over\\\- comment/uncomment [count] lines{Visual}\\- comment/uncomment the highlighted lines\\u- 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.
In visual mode:
:Tabularize assignment:Tabularize argument_list:Tabularize /=>
-
:Gcommit -
:Gstatus- jump between lines that represent files with
<c-n>,<c-p> -- add/reset file (visual mode too)<Enter>- open current file in the window belowp- rungit add --patchfor current fileC- invoke:Gcommit
- jump between lines that represent files with
-
:[range]Gbrowse! -- copy GitHub URL for code that's currently selected -
:[range]Gblame -
:Gedit feature:%- version of the current file in the "feature" branch -
:Gwrite-add % -
:Gread-checkout % -
:Gremove-rm % -
:Gmove <dest>-mv % <dest>
:Rename[!]:SudoWrite:Remove[!]:Find[!] {args}- runfindand load results into quickfix- when you create a file that starts with a shebang, it gets
chmod +xautomatically on first save!
Quickly open vim runtime files:
:Vedit:Vsplit:Vvsplit:Vtabedit:Vpedit:Vread
Example:
:Vsp s/pd<Tab>