VIM Cheat sheet - xthouxand/itc-136 GitHub Wiki
Command mode:
:
:wq - write and quit
:wq! - write and quit no matter what. (! forces the command)
:w - writes the file
:q! - quits without writing
:[line number] - takes you to specific line number
:split [filename] - work on multiple files at the same time
:hide - close the file your cursor is on in split mode
:only - makes you only see the window your cursor is on in split mode
Line:
$ - goes to the end of a line
0 - goes to the start of a line
dd - deletes line the cursor is on
File:
gg - go to top of file
G - go to bottom of file (or type :$)
u - undo
shif-u - undo
CTRL-W-W - move between windows
NOTES FOR 5/18/2017
How do i get to command mode:
:
:wq (write and quit)
Particular line number :34
Line: go to end of line $ go to start of line 0
File: Go to top of file gg Go to bottom of file :$
delete line: dd
undo: u
working on multuple files at once: plit filename
*to move between windows ctl-w-w or ctl-w ctl-w
:hide gets rid of window (you'll be prompted to save changes before....)
Search /whatyou' researchingfor (press n to go to the next match)
Modes: i for insert mode (so i can type things) escape to get back to command mode
writing and exiting :wq! write and quit no matter what. (! forces the command) :w writes the file without quiting :wq writes and quites but if there is an error it will stop :q! quits without writing the file.
Search and replace (the most obtuse of cim commands)
Example :%s/1/one/g
: (colon) puts us into command mode %s tells us to search and replace through the entire file 1 is the thing that we are searching for one is the thing we are replacing /1 with /g means to do it globally.
- this command will turn 111 into oneoneone ot 102 into one02