Vim Indepth Flashcards
Commands to Open Vim
enter ‘vim’ without an argument or option in the command line to open the welcome screen. From here, enter ‘vim [file name] to open the file. If a file by that name does not exist, it will create it.
If you just enter ‘vim [file name]’ from the Bash command line, it will immediately open the file, skipping the welcome screen. Again, if the file doesn’t exist, Vim will create it.
Vim vertical split screen command
ctrl + w + v
Vim horizontal split screen command
ctrl + w + s
Insert Mode
Enables users to insert text by typing into the system
Execute Mode
Enables users to execute commands within the editor
Command Mode
Enables users to perform different editing actions using single keystrokes
Visual Mode
Enables users to highlight or select text for copying and deleting
Vim, Enter Insert Mode from the Command Mode
i - insert text to the left of the cursor
A - add text at the end of a line
I - insert text at the beginning of a line
o - insert text on a new line below the cursor
O - insert text on a new line above the cursor
Vim, Enter Visual Mode from the Command Mode
v - enable selection, one character at a time
V - enable selection, one line at a time
Vim, Enter Execute Mode from the Command Mode
:
Vim, Return to Command Mode
Esc
:w [file name]
(Vim execute mode supported command)
save the open file with the file name if saved for the first time
:q
(Vim execute mode supported command)
quit if there have been no changes since the last save
:q!
(Vim execute mode supported command)
quit without saving changes
:qa
(Vim execute mode supported command)
quit multiple file/quit all
:wq
(Vim execute mode supported command)
save the file and quit
:e!
(Vim execute mode supported command)
revert to the last saved version of the file without quiting or closing the file
:! [any Linux command]
(Vim execute mode supported command)
execute the command and display both the command and any output from the command
:help
(Vim execute mode supported command)
open Vim’s built-in help documentation
Vim motions
Used inside Command Mode, Motions move the cursor anywhere within a document
h
(Vim Motion key)
move one character to the left
(can also use the left arrow key)
Used inside Command Mode
j
(Vim Motion key)
move down one line
(can also use the down arrow key)
Used inside Command Mode
k
(Vim Motion key)
move up one line
(can also use the up arrow key)
Used inside Command Mode
l
(Vim Motion key)
move right one character
(can also use the right arrow key)
Used inside Command Mode
(Vim Motion key)
move to the beginning of the current line
Used inside Command Mode
$
(Vim Motion key)
move to the end of the current line
Used inside Command Mode
w
(Vim Motion key)
move to the next word
Used inside Command Mode
b
(Vim Motion key)
move to the previous word
Used inside Command Mode
Shift + L
(Vim Motion key)
move to the bottom of the screen
Used inside Command Mode
Shift + H
(Vim Motion key)
move to the first line of the screen
Used inside Command Mode
[#] Shift + G
(Vim Motion key)
move to the line #
Used inside Command Mode
gg
(Vim Motion key)
move to the first line of the file
(can also use the home key)
Used inside Command Mode
Shift + G
(Vim Motion key)
move to the last line of the file
(can also use the end key)
Used inside Command Mode
/[text string]
(Vim Motion key)
search (forward?) through the document for the specified text
Used inside Command Mode
?[text string]
(Vim Motion key)
search backward through the document for the specified text
Used inside Command Mode
u
(Vim Motion key)
undo the latest change
Used inside Command Mode
ZZ (capitals)
(Vim Motion key)
save the file and quit Vim
Used inside Command Mode