Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

1.Starting vi and dabbling with it

Code Block
languagebash
vi
i  # get into input mode
:a # add text after the cursor 

In input mode, type anything you want.

2a2.Saving in vi:

Esc

Get out of input mode and into command mode

Code Block
languagebash
:w vi_file_name  # save theas a vi file
Enter

2b.If you have saved the file once, just use

...

Code Block
languagebash
:w 
Enter

 

3.Exiting vi:

Esc
Code Block
languagebash
:q # quit vi

...

Code Block
languagebash
vi vi_file
ESC
:r import_file

 

6. Searching and replacing in vi:

6a.find a string of text in vi:

vi vi_file

Esc
Code Block
languagebash
 /text   # look for "text"

...

get the first result, and press N to find the next one.

6b. search and replace in vi:

vi vi_filename

Esc
Code Block
languagebash
 %s :%s/text/newtext   # replace "text" with "newtext"