Linux: vi quick reference

Linux: vi quick reference

Linux: vi quick reference 150 150 Roderick Derks

Last Line Mode

Command Mode

Input Mode

Search Functions:

Screen/Line Movement:

Add/Append Text:

/exp                        Go forward to exp

0              Goto line start

a              Append after cursor

?exp                       Go backward to exp

$              Goto line end

A            Append at line end

:5                            Goto line 5

%            Goto matching

I              Insert before cursor

Move and Insert Text:

G             Goto last line

5i             Insert text 5 times

:3,8 d                      Delete line 3-8



:4,9m 12                  Move line 4-9 to 12

Word Movement:

Add New Lines:

:2,5 t 13                  Copy lines 2-5 to 13

W           Go forward one word

o             Open a line below cursor

:5,9w file                Write line 5-9 to file

3W         Go forward three words

O             Open a line above cursor


B             Go back one word


Save Files and Exit:

3B           Go back three words

Change Text:

:w                            Write buffer to disk


cw           Change a word

:w newfile              Write buffer to newfile

Search Functions:

3cw         Change 3 words

:w! file                    Write absolutely

n             Repeat previous search

C             Change a line

:wq                         Write buffer and quit

N             Reverse previous search

r              Replace one character

:q                            Quit editor


R             Replace/Type-over a line

:q!                           Quit, discard buffer

Delete Text:


:e!                           Reedit, discard change

x              Delete one character

Screen Movement:


dw          Delete one word

^d           Scroll down one half screen

Control Edit Session:

dd           Delete one line

^u           Scroll up one half screen

:set nu                    Display line numbers

D/d$       Delete to end of line

^f            Page forward one page

:set nonu               Turn off line numbers

d0           Delete to begin of line

^b           Page backward one page

:set all                    Show all settings

dG           Delete to end of file

H             Home, top of screen

:set list                   display invisible chars

4dd         Delete 4 lines

M            Middle of screen



L             Last line of screen

Global Replacement:

Cancel Edit Functions:


: %s/string_1/string_2/gc

u             Undo last change


:1,$ s/string_1/string_2/g

.               Do last change again


Global Delete




Copy and Insert Text:


Read in A File:

Y             Yank a copy of a line


:r file_name

5Y           Yank a copy of 5 lines



P             Put below cursor



p             Put above cursor






Word Processing Functions:



J              Join next line to current



4J            Join 4 lines to current



xp            Transposes 2 characters


Roderick Derks

Liefhebber van fietsen, van het oplossen van IT puzzels, en van het delen van informatie om anderen te helpen.

All stories by:Roderick Derks

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

    Your Name (required)

    Your Email (required)


    Your Message

      Your Name (required)

      Your Email (required)


      Your Message