Home
Oh Shit, Vim or Vi
vi is the de facto standard Unix editor, you find it in every NIX derived OS.
Thats why you should learn a handfull of commands, you can the show off your Vi skills
The first thing you need to learn is how to exit
- just quit: :q
- just quit and not save: :q! or ZQ (shift-Z-Q)
- quit and save any changes: ZZ (shift-Z-Z)
Next up is editing
- insert: i then escape to exit insert mode
- append: a then escape to exit insert mode then escape to exit insert mode
- append at the end of the line: A (shift-A)
- Begin a new line below the cursor: o then escape to exit insert mode
- Begin a new line above the cursor: O (shift-O) then escape to exit insert mode
Now you can exit and edit a file, what if you want to delete stuff?
- Delete characters: x
- Delete lines: dd
- Delete the characters under the cursor until the end of the line: D (shift-D)
Great, you can exit and edit and even delete. SO what else would bew cool to do?
How about copy a line and past it else where?
- yank a line: yy
- move to destination line
- paste after cursor p or P to paste before the cursor
SO you made a change and you need to undo it, or you made a change and want to repeat it. We have you covered!
- undo is just u
- you can redo a change with CTRL-R
- repeat the last change with .
Thats most of the cool stuff I know, the last 2 things are searching
- searching can be started with / then type out what your looking for.
- repeat your search with n
- you can also search up the file with ?
And the very last thing is substituting, this is find and replace
- :s%/find/replace/g this is look for find and replace it with replace everywhere
- :%s!file path!new path!g you can use any delimiter, that helps with changing a path