vi text editor
Colon-Mode-r
<filename> Reads a file and inserts it the line below current position
Search-Mode-/<string>
EX:/Password; Enter N to find the previous occurrence.
Movement Mode space bar
Moves forward a character at a time
Search-Mode-?Password
- Searches backwards from the current position.
Colon-Mode-q!
Abort all changes and exit
Modes of vi Insert
Allows you to actually insert new text
Modes of vi Change
Allows you to change existing text, delete lines, change a word, change a character, undo changes
Modes of vi Colon
Allows you to execute global edit commands, read/write to a file, exit vi and many more options
Modes of vi Search
Allows you to search for text and change the text
Modes of vi Movement
Allows you to use arrow keys or other control commands to move around within existing text
Insert Mode a
Append characters AFTER cursor position
Insert Mode A
Append characters at END of current line
Change-Mode-cw
Change the word at the current position up to the first space. Press ESC after new entry
when typing characters into vi, what should be considered?
Commands in "vi" are case sensitive
Change-Mode-#dd
Delete a number of lines, starting with current line. Example: 3dd will delete 3 lines
Change-Mode-x
Delete character at current position
Change-Mode-D
Delete from cursor to end of the line
Change-Mode-#x
Delete several characters starting at current position. Example: 3x deletes 3 characters
Change-Mode-dd
Delete the current line
Change-Mode-dw
Delete the current word
Movement Mode ENTER key
Drops down a line at a time
Colon-Mode-!<command>
Executes a shell command. Example: !ls will list files in the current directory
Colon-Mode-ESC
Exit from COLON MODE. It doesn't hurt if you press ESC more than once
Insert Mode ESC key
Exit insert mode
Movement Mode ^B
Goes backwards a screen at a time
Movement Mode ^F
Goes forward a screen at a time
Insert Mode i
Insert characters BEFORE cursor position
Insert Mode l
Insert characters at BEGINNING of current line (Capital i)
Change-Mode-J
Join the line below to the end of the current line
Movement Mode #G
Jumps to a specific line number. Example: 3G jumps to line 3
Movement Mode $
Jumps to end of current line
Movement Mode G
Jumps to the end of the file
Movement Mode backspace key
Moves backwards a character at a time
Insert Mode O
Open a new line ABOVE current line
Insert Mode o
Open a new line BELOW current line
Colon-Mode-1,$s/thisvalue/withthis/
Performs global substitution starting at line 1 to end of file. The "$" sign represents end of
Change-Mode-R
Replace characters starting at cursor position until ESC
Change-Mode-rx
Replace current character with the letter "x"
Change-Mode-U
Restore the current line
Colon-Mode-:
Start COLON MODE. You will jump to the last line on the screen where Colon-Mode-a colon will display and await your next command
Modes of vi Oh Yeah
Special and misc. commands
Change-Mode-u
Undo last command
Colon-Mode-#,#w<filename>
Write a range of lines of from current file to another file. Example: 10,20w myfile will write lines 10 to 20 to a file called "myfile"
Colon-Mode-w<filename>
Write the current file to another file name
Colon-Mode-x
Write the file and exit
Colon-Mode-w
Write the file saving current changes, but does not exit vi
How to Start?
vi <filename> Example: vi myfile