.
repeat last commandD
delete from cursor position to end of lineC
change to end of line (i.e. delete and open cursor)d0
delete from cursor to begining of liney0
yank/copy from cursor to end of liney$
yank/copy from cursor to begining of linep
pasteP
paste before cursorA
open insert at end of lineI
open insert at begining of lineo
add line below and open insertO
add line above and open insertgq<motion>
break the lines that moves over into 80 character lines, e.g.:gqq
break the current line into 80 char linesgqG
break all lines from current cursor position to end of file
<n>G
go to line n/<string>
search down for string/regex?<string>
search up for string/regexn
while in search mode, go to next matchN
while in search mode, go to previous match
+
hop to first non-whitespace character on the next line-
hop to fir non-whitespace character on the previous lineJ
delete all space between end of current line and start of non-whitespace after it^
jump to first non-space on line$
jump to end of line0
jump to start of linef<c>
jumps to next character, where<c>
is any character<n>f<c>
jumpts to nth character, where<c>
is any character,<c>
jump to previous character, where<c>
is any characterr<c>
replace currently selected character with<c>
, where<c>
is any characterx
delete currently selected characterCTRL + C
to exit insert modejk
to exit insert mode (presupposes my dotfiles, specifically this)]]
jump to next class/module definition[[
jump to previous class/module definition]m
jump to the start of the next method definition[m
jump to the start of the previous method definition]M
jump to the end of the next method defintion[M
jump to the end of the previous method defintion%
jump between the start and end of a block of code, works fordef . . . end
,(. . .)
,[ . . . ]
, etc (requires matchit.vim to be enabled)L
go to bottom of visible pageH
go to top of visible pageM
go to middle of visible pagez.
put the cursor in the middle of the pageCTRL + U
scroll up one half pageCTRL + D
scroll down one half page<space> + ct
index ctags for current directory, presupposes thoughtbot dotfilesgcc
comment/uncomment current line, presupposes tComment}
jump to end of paragraph{
jump to begining of paragraphcst<tag><new-tag>
changes the surrounding HTML tag specified to the new tag specified, presupposes vim-surrounddst<tag>
deletes the surrounding HTML tag, presupposes vim-surroundcit
change inside tag, can be used for any grouping symbol, e.g.[
,{
,(
,"
, etc, presupposes vim-surroundcat
change around tag, presupposes vim-surround<space>rs
run spec that the cursor is on, presupposes vim-rspec and my dotfiles<space>rl
run last spec that was run, presupposes vim-rspec and my dotfiles<space>rt
run spec file from top, presupposes vim-rspec and my dotfiles
<CTRL + w>
delete previous word<CTRL + h>
delete previous letter The following presuppose my dotfiles:<CTRL + u>
undo inserted text<CTRL + r>
redo inserted text<CTRL + k>
delete to end of line<CTRL + d>
delete to begining of line<CTRL + a>
jump to start of line<CTRL + e>
jump to end of line
:!<shell script>
executes shell script from within vim:Ag <string>
uses silver searcher to search through subdirectories forstring
<CTRL + R><">
pastes yanked text into command line:<some command> a
apply command to all open windows, e.g.:qa!
to force quit all windows%
path to current file:jumps
list all of the jumps you've made between files:%s/<string>/<string2>/gc
global replace of string 1 for string 2 with confirmation: <CTRL + p>
go back through command history: <CTRL + n>
go forward through command history:Explore
open directory navigator within path of current file:saveas <path>
saves a copy of the current file in the path specified:help <command>
gives documentation for the
NOTE: Most of these work for v
(select), d
(delete), =
(auto-indent), and c
(change) commands
vaw
select around word (with spaces around it)viw
select inner word (no spaces around it)vim
select inside method (requires vim-ruby)vam
select around method (requires vim-ruby)V
select whole linev0
select from cursor position to start of linev$
select from cursor position to end of line<select something> backspace
deletes (presupposes thoughtbot dotfiles)vt<character>
select to charactervap
select a paragraph, i.e. all of the code until a newlinevas
select a sentencevit
select inside tags, e.g.<a>
,<p>
vat
select around tags, e.g.<a>
,<p>
vi<char>
select inside character, where is a character used for grouping, e.g.(
,[
,"
,'
, etcv/<search string>
select until search stringCTRL + v
select column (only works for select)U
make selected text uppercase (only works for select)u
make selected text lowercase (only works for select)<CTRL-v>jjjIhey_guys
insert 'hey_guys' at the cusor position three lines down, SO post
space space
go to last open file (presupposes thoughtbot dotfiles)CTRL + ]
go to method definition (presupposes you have C-tabs installed and set up)g]
show list of ctags matchesCTRL + o
go back to previous file; even open files from the last vim sessionCTRL + i
go to next file in stack<n> + <CTRL + i/o>
jump n places in stack of files forward/backwardCTRL + p
find file in directory using fuzzy matching on file pathCTRL + j/k
to navigate among resultsCTRL + d
to switch between matching on file name and file path name
>>
indent to the right==
indent line to the appropriate amount<n>==
indent n lines the appropriate amount
CTRL + w + s
horizontal splitCTRL + w + q
close windowCTRL + w + v
vertical splitCTRL + <h,j,k,l>
move between windows in direction<CTRL + w> >
resize vertical split to move it over to the right, can be prefixed with a number to do it multiple times<CTRL + w> <
resize vertical split to move it over to the left<CTRL + w> +/-
resize horizontal split