– HELP INFO –
:help tutor – launches vim tutor
:help – opens help window (ZZ to exit out)
Ctrl+] – jumps to tag
Ctrl+T – pops tag off the stack (goes back)
–MOTIONS–
w – until start of next word seperated by punctuation
W – until start of next word seperated by space
e – end of current word
$ – end of line
i – inside used with di> to delete contents between angle brackets, parentheses, etc.
a – like “i”, but includes brackets too
b – goes back one word, punctuation delimited
B – goes back one word, space delimited
– MISC –
esc – exits out of insert mode
:q! – exit without saving changes
#<command> – executes that command # times
q<char> – records a macro
@<char> – executes macro
q – stops recording macro
ma – marks current position as “a”
`a – recalls the marked position called “a”
:ab string substitution (abbreviation)
:una string – delete key mapping
:map – key map for command mode (unsure)
:map! – key map for insert mode (unsure)
:mapclear – clears all keymappings
Ctrl-g – displays status line
. – repeats the last delete or change command (df> for example)
:set all – shows all options
Shift-V -> move cursor -> zf – marks section for folding
zc – close fold
Space – open fold
:split – create horizontal split
:vsplit – create vertical split
Ctrl-w-<Direction> – move between buffers where direction=hjkl
:!<command> – executes external command
:copen – open compiler error buffer
:cclose – close error buffer
:set makecmd=”commandToCompile”
v – highlights by character
V – highlights by line
:make – runs make
:copen – gives list of errors in new buffer
:cclose – closes error buffer
– FILE –
:w – write changes to file
:q! – quit without saving
:wq – write changes and quit
:w>>filename – appends contents of buffer to filename
ZZ – exits and saves file
ZQ – quit without saving
:e – open file
:edit – opens new file
:enew – creates new file
:r <somethingExternal> – retrieves something, file, or command such as !ls
v<highlight>:w – writes highlighted text to file
– MOVING –
hjkl – move around
[[ - go to next function
]] – go to previous function
b – moves backward one word
w – moves forward one word
e – moves cursor to end of word
$ – move to end of line
#$ – moves to end of line # lines down
^ – moves to first non-blank character of the line
0 – moves to before the first non-blank char on the line
G – go to end of file
gg – go to top of file
#G – go to cursor on line #, if no #, it goes to EOF
Ctrl-u – scrolls up half a screen
Ctrl-d – scrolls down half a screen
Ctrl-f – scrolls forward one full screen
Ctrl-b – scrolls backward one full screen
% – goto matching parentheses
+ – move to first non-whitespace char in next line
– - move to first non-whitespace char in previous line
zt, zb, zz – move screen around cursor
H,M,L – Moves cursor to highest, middle, lowest area of screen
– EDITING –
i – insert before selected character
a – appends after selected character
A – appends at end of line
O – opens up a new line above cursor
o – opens up a new line below cursor
x – deletes character under cursor
X – deletes character to left of cursor
dd – deletes an entire line
d<motion> – delete (dw deletes a word, d3w deletes 3 words)
D – also d$, deletes to end of line
r – replace mode, types over char, for a single character only
R – replace mode, types over chars, for multiple characters
c<motion> – deletes then places user into insert mode
cc – just like dd, but puts user into insert mode
C – same as c$
u – undo
U – undo edits to entire line
Ctrl+R – redo
~ – changes a character’s case
gU – makes all character’s uppercase
d – cut (delete)
y – copy (operates identically to ‘d’)
p – pastes content after cursor
P – pastes content before cursor
>> – shifts line to right
<< – shifts line to left
3>> – shifts 3 lines to the right
>aB – moves block to left
<aB – moves block to right
J – join lines with a space
di( or yi( or ci” – yanks, changes, deletes all text between (, “, [, etc.
– STRING FILE SEARCHING –
/<string> – search forward for string
n – go forward to next found string
N – go backwards to previous found string
?<string> – search for string going backwards
Ctrl-I – goes forward to where cursor was
Ctrl-O – goes backwards to where cursor was
– SINGLE LINE SEARCHING –
t<char> – search til, like f, but stops one char before char
T<char> – search til, like F, but stops one char before char
f<char> – forward search line until <char> is reached
F<char> – backward search line until <char> is reached
, – repeat the last f,t,F, or T in opposite direction
– SEARCH & REPLACE –
:s/old/new – substitutes “old” for “new” for first occurrence
:s/old/new/g – substitutes “old” for “new” on current line
:#,#s/old/new/g – substitutes “old” for “new” between line numbers # & #
:%s/old/new/g – substitutes “old” for “new” in entire file
:%s/old/new/gc – substitutes “old” for “new” in entire file with prompt
* – searches forward for the next occurrence of the word under the cursor
# – searches backward for the previous occurrence of the word under the cursor
– Settings –
:set ic – ignore case when searching
:set noignorecase – turns off ignore case