command
description
vim + file.ext
Open file at last line
vim +42 file.ext
Open file at line 42
vim +/^include_path
Open the file at the line that starts with include_path
command
description
:q
Quit
:wq
Write and Quit
:q!
Quit without saving
ZZ
Write and quit
ZQ
Quit without saving
command
description
b
Move to the BEGINNING of the word
e
Move to the END of the word
ge
Move to the END of the PREVIOUS word
gg
Move to START of buffer
G
Move to END of buffer
h
Move cursor LEFT
j
Move cursor DOWN
k
Move cursor UP
l
Move cursor RIGHT
n gg OR n G
Move to n line (n represents a digit)
w
Move to the start of the next word
ctrl+b
Move BACK one page
ctrl+f
Move FORWARD one page
command
description
a
append after the cursor
A
append at end of line
i
Insert before cursor
I
Insert before line
o
Create new line below and start editing
O
Create new line above and start editing
gi
Place cursor where you were last editing (Useful for when you exit Insert mode and then need to go back where you once were)
command
description
u
undo
ctrl + R
redo
command
description
:ls
List current buffers
:bn
Next buffer
:bp
Previous Buffer
:bd
Close Buffer
command
description
:tabnew
create new tab
:tabn
move to NEXT tab
:tabp
move to PREVIOUS tab
:tabfir
goto FIRST tab
:tablas
goto LAST tab
command
description
ctrl + w s
Split window horizontally
ctrl + w v
Split window vertically
ctrl + w q
Close current window, if last window then exit vim
ctrl + w c
Close current window, will not exit vim
ctrl + w o
Make window the only window on the screen
" ~/.vimrc
" Enable spell checking
set spell
command
description
]s
Move to next misspelled word
[s
Move to previous misspelled word
z=
Show list of possible replacements words
Press q
then press another key that you want to assign it to. Example: qq
Enter commands
Press q
when finished
To run the macro, press @
and then the key that it is assigned to. Example @q
NOTE: Can be ran multiple times. Enter the number of times you want it to run then the macro. Example 10@q
will run the macro 10 times.
command
description
zo
OPEN code fold under cursor
zc
CLOSE code fold under cursor
zO
OPEN ALL code folds under cursor
zC
CLOSE ALL code folds under cursor
zr
Reduces all code folds by one level in buffer
zR
Reduces all code folds in buffer (ie: Open all code folds)
command
description
ma
Create mark a in file
'a
Jump to mark a
d'a
Delete line mark a
:marks
List marks
:delmarks a
Deletes mark a
:delmarks!
Deletes all marks
command
description
ctrl + x ctrl + o
Autocomplete current word
ctrl + x ctrl + n
word completion next
ctrl + x ctrl + p
word completion previous
ctrl + x ctrl + f
Complete filename
ctrl + x ctrl + l
Whole line completion
" ~/.vimrc
autocmd FileType python set omnifunc = pythoncomplete#Complete
autocmd FileType javascript set omnifunc = javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc = htmlcomplete#CompleteTags
autocmd FileType css set omnifunc = csscomplete#CompleteCSS
autocmd FileType xml set omnifunc = xmlcomplete#CompleteTags
autocmd FileType php set omnifunc = phpcomplete#CompletePHP
autocmd FileType c set omnifunc = ccomplete#Complete
Reformat mixed indent files
" Goto first line in file
gg
" Enter visual line mode
shift+ v
" Goto the last line of the file
shift+ g
" Filter lines
=
:set tw=80 Sets text width to 80 characters
gg Goto first line
gqG Format file till you reach the last line
Remove trailing whitespace on the ends of every line