DD ViEditorCheatSheet
DD ViEditorCheatSheet
3 modes of vi
command mode you can navigate the file and use the commands shown on this page insert mode you can type into the file, and with vim you can still move around the file last-line mode you can issue complicated commands on the last line of the editor
deleting
x 10x dd 6dd d0 d$ delete current character delete 10 characters delete current line delete six lines delete to beginning of line delete to end of line
searching
/foo ?foo n search forward for foo search backwards for foo repeat last search
saving, exiting
:w :wq write contents to disk write contents and quit write contents and quit quit quit and dont save changes
ZZ :q :q!
editing
i o O a A u insert open a new line (below) open a new line (above) append append at end of line undo repeat last command
miscellaneous
:!ls :r foo :10,20d run ls command from editor read file foo into this file delete lines 10-20
more miscellaneous
:1,$s/foo/bar/g from the first line to the last line change all ocurrences of foo to bar first[Ctrl][p] vi auto-complete; turns first into firstName, assuming you have a variable in the file named firstName
devdaily.com/unix