0% found this document useful (0 votes)
240 views1 page

Mac OS X:: VI Keyboard Shortcut Cheat Sheet: Navigation Shortcuts Editing Exiting (Command Mode)

This document provides a cheat sheet of keyboard shortcuts for navigating, editing, selecting text, inserting text, searching/replacing, and multi-file editing in the vi text editor on Mac OS X. It includes shortcuts for moving the cursor, jumping to locations in the text, replacing and deleting text, entering and exiting insert mode, selecting text in visual mode, and searching/replacing text within files. The cheat sheet is intended to help users learn the essential vi commands for common text editing tasks.

Uploaded by

IT Support
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
240 views1 page

Mac OS X:: VI Keyboard Shortcut Cheat Sheet: Navigation Shortcuts Editing Exiting (Command Mode)

This document provides a cheat sheet of keyboard shortcuts for navigating, editing, selecting text, inserting text, searching/replacing, and multi-file editing in the vi text editor on Mac OS X. It includes shortcuts for moving the cursor, jumping to locations in the text, replacing and deleting text, entering and exiting insert mode, selecting text in visual mode, and searching/replacing text within files. The cheat sheet is intended to help users learn the essential vi commands for common text editing tasks.

Uploaded by

IT Support
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Mac OS X :: VI Keyboard Shortcut Cheat Sheet http://trevorsullivan.

net

Navigation Shortcuts Editing Exiting (Command Mode)


These commands help you navigate text in vi. These commands help you edit text. These commands help you save your file and exit vi.

h Move cursor left one position r Replace a single character :w Write / save file, without exiting
j Move cursor down one line J Join current line to next line :wq Write / save file, and exit vi
k Move cursor up one line cc Replace entire line :q Quit (error if there are pending changes)
l Move cursor right one position cw Replace text from cursor to end of word :q! Force quit, discarding changes
w Jump to beginning of next word c$ Replace text from cursor to end of line
(punctuation) s Delete character under cursor, insert text Search / Replace
W Jump to beginning of next word (spaces) S Delete current line, insert text These vi commands help with searching for, and replacing
e Jump to end of next word (punctuation) u Undo last action text inside your plain text files.
E Jump to end of next word (spaces) - Redo last action
0 Jump to start of line /pattern Search for a regex pattern (forward)
$ Jump to end of line (similar to regex) Select Text Visual Mode ?pattern Search for a regex pattern (backward)
#G Go To specified line number These commands help you select text in what’s called n Find next search result
% Jump between parentheses or braces “Visual Mode.” There are several different visual modes N Find previous search result
though, so make sure you understand them all. :%s/old/new/g Replace all old with new (with prompt)
Note: Navigation shortcuts can be prefixed with a number, :%s/old/new/gc Replace all old with new (no prompts)
to repeat. For example: 5w will jump five (5) words ahead. v Enter Visual Mode, from Command Mode
21G will jump to line #21. This doesn’t work with the 0 V Enter Visual Mode (line-wise) Multi-file Editing
shortcut, for obvious reasons. Ctrl+v Enter Visual Block mode (select text grid) These commands help navigating multiple files in vi.
y Yank (copy) selected text
Insert Mode o Jump to opposing end of marked text :e filename Re-open the current file
These commands help you insert text in vi. O Jump to opposing corner (Visual Block Mode) :bnext (:bn) Move to next buffer
aw Mark the current word :bprev (:bp) Move to previous buffer
i Invoke Insert mode at cursor’s location ab Select (…) block, including parentheses :bd Delete the current buffer (close file)
I Insert at the beginning of the current line aB Select {…} block, including curly braces :sp filename Open file in new window
a Append text after the cursor’s location ib Select (…) block, excluding parentheses Ctrl+ws Split windows
A Append text at the end of the current line iB Select {…} block, excluding curly braces
o Append new / empty line after current line
O Append new / empty line before current line
Esc Exit Insert Mode, enter Command Mode

http://trevorsullivan.net Twitter: @pcgeek86


Source: http://www.worldtimzone.com/res/vi.html

You might also like