0% found this document useful (0 votes)
43 views1 page

DD ViEditorCheatSheet

The document summarizes vi editor commands. It is organized into sections on the 3 modes of vi, deleting text, searching, saving and exiting, navigation up and down, editing, miscellaneous commands, cutting and pasting, and navigation left and right. The vi editor has command mode to navigate and run commands, insert mode to add text, and last-line mode for complex commands. Common commands include deleting characters, lines, searching, saving, navigating by line and screen, editing by inserting, opening and appending lines, undoing, and cutting and pasting text.

Uploaded by

renjuzac
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views1 page

DD ViEditorCheatSheet

The document summarizes vi editor commands. It is organized into sections on the 3 modes of vi, deleting text, searching, saving and exiting, navigation up and down, editing, miscellaneous commands, cutting and pasting, and navigation left and right. The vi editor has command mode to navigate and run commands, insert mode to add text, and last-line mode for complex commands. Common commands include deleting characters, lines, searching, saving, navigating by line and screen, editing by inserting, opening and appending lines, undoing, and cutting and pasting text.

Uploaded by

renjuzac
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

vi editor commands

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

navigation up, down


[Up] move up one line move up 5 lines move down 1 line move down 6 lines go to line 1 go to line 15 go to last line go to top of screen (high) go to middle of screen go to bottom of screen (low) 5[Up]

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

[Down] 6[Down] 1G 15G G H M L

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

cutting and pasting


yy 5yy dd 6dd p yank (copy) yank 5 lines delete current line delete six lines paste (below current line) (lower-case p) P paste (above current line) (capital P)

navigation left, right


w 7w b 0 $ go to next word move over 7 words back one word go to beginning of line go to end of line

devdaily.com/unix

You might also like