You are on page 1of 1

GoSquared

Modes & Controls


Command Mode ESC (commands preceded by :) Insertion Mode
vi < lename> vi -r < lename> vi + n < lename> vi + < lename> vi +/str < lename>

VI Help Sheet

Inserting Text
i a I A o O r R :r < le> p P C Insert before cursor Append after cursor Insert before line Append after line Add new line after current line Add new line before current line Overwrite one character Overwrite many characters Reads le and inserts it after this line Put after the position or line Put before the position or line Rewrite the whole line

Other
u Undo last change

Entered on insertion or change Starting VI (command line)


Edit lename Edit last version of lename after crash Edit lename at line n Edit lename at end of le Edit lename at rst occurance of str

J
Join lines nJ Join next n lines . Repeat last command U Undo all changes to line :N Open split screen v Visual mode ctrl + c Escape insert mode

In insertion mode the following should be preceded by ESC:

:w :x :q :q!

Save Save & Exit Exit if no changes made Exit & discard any changes

Cursor Navigation
h or j or k or l or w W b B e E ( ) { } 0 $ 1G G :n f<char> F<char> H M L % gg Cursor left Cursor down Cursor up Cursor right Next word Next blank delimited word Start of word Start of blank delimited word End of word End of blank delimited word Back a sentence Forward a sentence Back a paragraph Forward a paragraph Beginning of line End of the line Start of le End of le nth line of le Forward to char Back to char Top of screen Middle of screen Bottom of screen Matching bracket Start of document

Deleting Text
x X D dd or :d ndw ndb ndd :x,yd :r < le> :r < le> Delete character to right of cursor Delete character to left of cursor Delete the rest of line Delete current line Deletes the next n words Deletes the previous n words Deletes n lines starting with current Delete lines x through y Reads le and inserts it after this line Reads le and inserts it after this line

d{nav_cmd} Overwrite many characters

Searching
/string ?string n N :set ic :set noic :set nu :x,yg/str * # Search forward for string Search backwards for string Go to next match Go to previous match Ignore case while searching Case-sensitive searching Turn on line numbers Search for str from line x to line y
Search for next instance of current word

:g/str/cmd Run cmd on lines containing str Search for last instance of current word

Replacing
:s/pt/str/ ag Replace pattern with string Flags g c & Replace all occurrences of pattern Con rm replaces Repeat last :s command

Download this Help Sheet now at gosquared.com/liquidicity Put it on your wall Referenced from http://www.lagmonster.org/docs/vi.html

2010 Go Squared Ltd.

You might also like