0% found this document useful (0 votes)
2 views

CSLC Helpdocs Vim

The document provides a comprehensive guide to Vim commands, detailing various modes, editing commands, navigation shortcuts, and file management options. It includes specific commands for inserting, deleting, copying, and searching text, as well as moving around the document and saving or quitting files. Additionally, it offers comments and examples for better understanding of each command.

Uploaded by

crazynull76
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

CSLC Helpdocs Vim

The document provides a comprehensive guide to Vim commands, detailing various modes, editing commands, navigation shortcuts, and file management options. It includes specific commands for inserting, deleting, copying, and searching text, as well as moving around the document and saving or quitting files. Additionally, it offers comments and examples for better understanding of each command.

Uploaded by

crazynull76
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Vim Commands

+*Must be in Command Mode to perform the following commands.


General
# Command Description Comments
i Enter insert mode Press ESC to exit Insert Mode
[Insert Key] Enter insert mode Press ESC to exit Insert Mode
r Enter replace mode Press ESC to exit Replace Mode
*​NOTE​: Pressing ​Insert ​twice also
enters replace mode
v Enter visual mode Press ESC to exit Visual Mode
[Escape Key] Enter command mode If the are in another mode, ESC will
take you into Command Mode
# dd Delete line Ex) ​2dd ​- Deletes 2 lines
# dl Delete letter
# x Delete letter
[Delete Key] Delete letter
# dw Delete word
dG Delete everything until Press ​gg​ ​or ​1G​ before you do this
end of file command to delete everything from
beginning to end
# yy Yank (copy) line Ex) ​3yy ​- Copies 3 lines
p Paste Always pastes below the green cursor
% Jumps to matching To access the % symbol, press Shift +
bracket 5
# u Undo Ex) ​4u -​ undoes the last 4 changes
Ctrl-r Redo
/[word] Searches for a ​[word] Press ​n ​to increment search
:%s/[search]/[replace]/g Searches all instances Ex) ​:%s/Hello/World/g​ - Searches
of ​[search]​ and for all instances of “Hello” and replaces
replaces them with it with “World”
[replace]
:[x],[y]s/[search]/[replace]/g Change each Ex) ​:5,12s/Hello/World/g​ - Same
[search]​ to as above, but only replaces from line 5
[replace]​ from line to line 12 (inclusive)
[x]​ to line ​[y]
1G=G Formats/Indents code The “​G​” ​must​ be capitalized
gg=G Same as “​1G=G​”
# = (Optional) Any number can precede the command

This workforce product was funded by a grant awarded by the U.S. Department of Labor’s
Employment and Training Administration. The product was created by the grantee and
does not necessarily reflect the official position of the U.S. Department of Labor. The U.S.
Department of Labor makes no guarantees, warranties, or assurances of any kind, express
or implied, with respect to such information, including any information on linked sites and
including, but not limited to accuracy of the information or its completeness, timeliness,
usefulness, adequacy, continued availability, or ownership.
Vim Commands

Moving Around in Vim


Command Description Comments
Home Jumps to beginning of line Windows only
End Jumps to end of line Windows only
0 Jumps to beginning of line Windows and Mac
$ Jumps to end of line Windows and Mac
^ Jumps to the first non-blank character of a Windows and Mac
line
Page Up/Page Down Jumps a page up/down Windows only
Ctrl-F Jumps a page down (forward) Windows and Mac
Ctrl-B Jumps a page up (backward) Windows and Mac
gg Jumps to top of file
1G Jumps to top of file 23G​ jumps to 23rd line in file
G Jumps to bottom of file

Saving and Quitting


Command Description Comments
:w Saves the file (writes)
:q Quits the file if the file is saved Will not let you quit if you’ve made
changes to the file
:q! Quits without saving
:wq Saves and quits the file simultaneously
:x Shortened version of ​:wq

Other Vim Commands


Command Description Comments
:set nu Display line numbers
:set nu! Removes line numbers
:set mouse=a Enables mouse To copy/paste text, hold down SHIFT
while selecting text and to paste.
:set paste Enables formatted pasting in Insert mode Only use this when you need it. Disable it
when you are done pasting the text you
want into vim.
:set nopaste Disables formatted pasting in Insert mode
:[line_number] Jumps to a ​[line_number] Ex) ​:23​ - jumps to line 23

This workforce product was funded by a grant awarded by the U.S. Department of Labor’s
Employment and Training Administration. The product was created by the grantee and
does not necessarily reflect the official position of the U.S. Department of Labor. The U.S.
Department of Labor makes no guarantees, warranties, or assurances of any kind, express
or implied, with respect to such information, including any information on linked sites and
including, but not limited to accuracy of the information or its completeness, timeliness,
usefulness, adequacy, continued availability, or ownership.

You might also like