Last active
August 7, 2020 13:37
-
-
Save mallond/02975c3b0b96a75ca2f5 to your computer and use it in GitHub Desktop.
VI Cheat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Navigation Keys - These are used in command mode: | |
$ Move to end of line | |
^ Move to beginning of line | |
Save and Quit Commands - These are used in lastline mode: | |
:w Write buffer (Save changes and continue working in vi Editor) | |
:w new_filename Write buffer to new filename (continue working in vi) | |
:wq Write buffer (save changes) and quit vi | |
:q! Quit without saving changes | |
:wq! Write buffer (save changes) and quit vi | |
(The ! will override Read only permissions but only if you are the owner of the file.) | |
Basic Text Deletion Commands - These are used in command mode: | |
x Delete character at the cursor | |
dw Delete word (or part of word to right of cursor) | |
3dw Delete three words | |
dd Delete line containing the cursor | |
3dd Delete three lines | |
Undo and Change Commands - These are used in command mode: | |
r Replace character at cursor with one other character | |
u Undo previous command | |
Copy and Paste Text - These are used in command mode: | |
yy Yank a copy of this line and place in the clipboard | |
yy 3 Yank a copy of next 3 lines and place them in the clipboard | |
yw Yank a copy of this word and place in the clipboard | |
yw 3 Yank a copy of next 3 words and place them in the clipboard | |
p Put (paste) yanked or deleted line below current line | |
P (upper case) Put (paste) yanked or deleted line above current line | |
Basic Search Commands- These are used in lastline mode: | |
G (upper case) Go to last line of file | |
H (upper case) Go to top line of file | |
:21 Go to line 21 | |
/string Search forward for this string of text | |
?string Search backward for this string of text | |
n Find next occurrence of this string of text | |
Session Customizing Commands | |
:set nu Show line numbers | |
:set nonu Hide line numbers | |
:set showmode Display current mode of operation | |
:set noshowmode Turn off mode display | |
:set Display all vi variables set | |
:set all Display all possible vi variables and their current |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment