Writings

Table of Discussed Commands

ModeCommandOutcome
Any<Escape>Enter Command mode
CommandiEnter Insert mode
Any<Arrow Keys>Move the cursor in the direction pointed
by the arrow key
Any<Page Up/Down>Move the cursor one page up or down
Any<Home/End>Move the cursor to start or end of a line
CommandwMove forward one word
CommandbMove back one word
Command)Move forward one sentence
Command(Move back one sentence
Command}Move forward one paragraph
Command{Move back one paragraph
Commandx[movement]Move movement x times
Ex. 15} moves us 15 paragraphs forward
Commandc[movement]“Change” - Deletes everything within the next
movement away and enters insert mode
Ex. c3w deletes the next 3 words and
enters insert mode
Commandd[movement]Delete movement and add them to the
buffer (described in section 5)
Ex. d4) deletes 4 sentences
Commandxd[movement]Equivalent to dxmovement
CommanduUndo previous changes
(i.e. move back through undo history)
Command<Ctrl>-rRedo previously undone changes
(i.e. move forward through undo history)
Command0Equivalent to <Home>
Command$Equivalent to <End>
CommandxxDelete x characters and add them to
the buffer (described in section 5)
Ex. 5x deletes 5 characters
Commandx~Changes the case of the next x letters,
non-letters (whitespace, numbers, etc.)
Ex. 15~ reverses the case of the next
15 letters
Commandr[key]Replace the character under the cursor with [key]
CommandREnter Replace mode
Command<Insert>Enter Insert mode
Insert<Insert>Enter Replace mode
CommandAAppend - Move cursor to end of current line and
enter Insert mode
CommandoOpen - Create a new line under the current line,
move the cursor to it, and enter Insert mode
CommandOOpen - Create a new line above the current line,
move the cursor to it, and enter Insert mode
CommandxddDelete x lines and place them in the buffer
Similar to “cut”
Ex. 5dd deletes the next 5 lines
CommandxccDelete x lines and enter Insert mode
Ex. 2cc deletes the next 2 lines and enters
Insert mode
CommandpPlace whatever is in the buffer (“clipboard”)
after the cursor. If the buffer contains a line or
more, place the contents of the buffer on the line
following the current line.
CommandPPlace whatever is in the buffer (“clipboard”)
before the cursor. If the buffer contains a line or
more, place the contents of the buffer on the line
above the current line.
Commandy[movement]Yank movement (add it to the buffer)
Similar to “copy”
Ex. y4w yanks 4 words
CommandxyyYanks x (places them in the buffer)
Similar to “copy”
Ex. 5yy yanks the next 5 lines
Execute:xJump to line x
Execute:w [filename]Write (“save”) curent editing session to
filename. If no filename is specified,
write to the document associated with this
session (the last file written to, opened from, etc.)
Execute:qQuit the current editing session.
ViM will not quit if you have not saved.
Execute:wq [filename]Write (“save”) curent editing session to
filename and then quit. If no
filename is specified, write to the
document associated with this session (the
last file written to, opened from, etc.)
Execute:e [filename]Edit - Open filename using the current
editing window. This closes the current file.
Execute:[command]! [arguments]Force - Perform the command regardless
of any rammifications
Ex. :q! Quits the session whether or not the
file has been saved.
Execute:[command]a [arguments]All - Perform the command to all open
windows
Execute:split [filename]Opens a new editing session in a new “window”
to edit filename. If filename is
blank, open the current document.
Command<Ctrl>-w <Ctrl>-wMove cursor to next window (vertically)
Execute:help [keystroke]Shows help for given keystroke in new
window. If no topic is given, show
generic help screen.
Execute:help :[command]Shows help for given command in new
window. If no topic is given, show
generic help screen.
Execute:help [topic]Shows help for given topic in new
window. If no topic is given, show
generic help screen.
Command/[searchTerm]Searches forward for regular expressions that
match searchTerm and places cursor on
the next match
Command?[searchTerm]Searches backward for regular expressions that
match searchTerm and places cursor on
the next match
Command*Searches forward for the word that is currently
under the cursor
CommandnPlace cursor on next match for the most recent
search
CommandNPlace cursor on previous match for the most
recent search
Execute:set ignorecaseIn all searches/regular expressions, be case
insensitive
Execute:set noignorecaseIn all searches/regular expressions, be case
sensitive (Default)
Execute:s/oldWord/newWord/gReplace all oldWords with the newWord
on this line
Execute:%s/oldWord/newWord/gReplace all oldWords with the newWord
in this file
Execute:%s/oldWord/newWord/gcReplace all oldWords with the newWord
in this file, asking for confirmation on each entry
Execute:set optionSet the boolean option, option to true
Ex. :set ignorecase
Execute:set nooptionSet the boolean option, option to false
Ex. :set noignorecase
Execute:set option=[Value]Set the option, option, to [Value]
Ex. :set wm=5
Execute:set ignorecaseIgnores case while searching
Execute:set mouse=[Value]Allows the mouse to be an input in Value
is “a”, or nothing if Value is “”
Ex. :set mouse=a
Execute:set wm=[Value]Set the word margin (the character position
from the right at which point ViM wraps
words) to Value
Ex. :set wm=5
Execute:set bg=[Value]Tell ViM the terminal’s background color
so that it may highlight appropriately
Ex. :set bg=dark
Execute:set bs=[Value]Tell ViM how to deal with backspaces.
Value can be either a comma separated
list or a numeric value (see help pages)
Ex. :set backspace=2
Execute:set ww=[Value]Informs ViM which characters wrap around a
newline. See the help pages for specifics
Ex. :set ww=b,s,<,>,[,]
Execute:set autoindentIf this option is set, whenever you press
[Enter] or open a new line, the indentation
of the previous line is used for the new line
Execute:set sts=[Value]Tabs will be treated as Value spaces
Ex. :set sts=4
Execute:set sw=[Value]Shifts (“>>”) will be treated as
Value spaces
Ex. :set sw=4
Execute:set expandtabExpands each tab press into as ‘sts’ spaces
Ex. :set noexpandtab
Execute:syntax [on/off]Turns syntax highlighting on or off
Ex. :syntax on
Execute:set syntax=[Value]Tells ViM which syntax to highlight
Ex. :set syntax=php
Execute:set numberTurns line numbering on
Execute:set smartindentTells ViM to use “smart indenting” which
includes indenting after certain characters
(like ‘{’). See help page for more
Execute:set cindentTells ViM to use “c indenting” which includes
the indentation in ‘smartindent’ as well as
after certain c keywords and structures. See
the help page for more
Cmd-Bang:![Command]Execute the external Command
Ex. :!ls -a lists all files in the current directory
Cmd-Bang:!gcc progName.c -g -WallUses the external gcc to compile progName.c
Ex. :!gcc calc1.c -g -Wall
Cmd-Bang:!./progNameRuns the file, progName, which is in the
current directory
Ex. :!./a.out runs the output of gcc
Cmd-Bang%Used as a placeholder for the current file’s name
Ex. :!echo % prints the file name
Commandx>>Shift the next x lines ‘sw’ characters right
Commandx<<Shift the next x lines ‘sw’ characters left
Command%Move to the matching paren/brace
Commandzf[Movement]Make a new fold of the next Movement lines
Ex. zf} creates a fold of the next paragraph
CommandzcCloses the fold that the cursor is in
CommandzoOpens the fold that the cursor is on
Insert<Ctrl-v>[Key]Insert the leteral Key character
Ex. <Ctrl-v><Tab> inserts a tab character
© C.M. Lubinski 2008-2021