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
:q Quit
:wq Write and Quit
:q! Quit without saving
ZZ Write and quit
ZQ Quit without saving
h Move cursor LEFT
j Move cursor DOWN
k Move cursor UP
l Move cursor RIGHT
gg Move to START of buffer
G Move to END of buffer
ngg OR nG Move to n line (n represents a digit)
w Move to the start of the next word
e Move to the END of the word
b Move to the BEGINNING of the word
$ Move to the END of the line
g Move to the BEGINNING of the line
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)
u undo
ctrl + R redo
:ls List current buffers
:bn Next buffer
:bp Previous Buffer
:bd Close Buffer
:tabnew create new tab
:tabn move to NEXT tab
:tabp move to PREVIOUS tab
:tabfir goto FIRST tab
:tablas goto LAST tab
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
]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.
zo OPEN code fold under cursor
zc CLOSE code fold under cursor
zR OPEN ALL code folds
zM CLOSE ALL code folds
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
:w|bd write (save) buffer and then close the buffer
:set tw=80 Sets text width to 80 characters
gg Goto first line
gqG Format file till you reach the last line
Install phpDoc.vim
ctrl+p Insert phpDoc block