Advanced VI - PowerPoint PPT Presentation

1 / 14
About This Presentation
Title:

Advanced VI

Description:

Execute a command and have vi replace the ... CTRL B Backward a whole screenful of new text. Task 2 ... I and i. A and a. O and o. R and r. U and u. Task 3 ... – PowerPoint PPT presentation

Number of Views:39
Avg rating:3.0/5.0
Slides: 15
Provided by: Kami47
Category:
Tags: advanced

less

Transcript and Presenter's Notes

Title: Advanced VI


1
Advanced VI
  • Searching
  • Substituting
  • Setting Parameters
  • Miscellaneous Commands

2
Searching for a String
  • To find the next occurrence of a string, use
    /
  • To find the previous occurrence of a string, use
    ?
  • Repeat the original search exactly n
  • Repeat the search in opposite direction
    N

3
Special Characters in Search String
  • (caret or circumflex) matches the beginning of
    a line eg, /the (finds the next line that
    begins with the)
  • (dollar sign) matches the end of a line eg,
    /! (finds the next line that ends with an
    exclamation mark.
  • (.) A period matches any character anywhere in
    the search string
  • eg, /l..e (finds line, followed, like)
  • \gt End of word indicator, eg /s\gt (finds next
    word that ends with an s)
  • lt\ Beginning of word indicator, eg, /\ltThe (finds
    the next word that begins with The)
  • matches any single character in the bracket,
    eg, /disck

4
Substituting
  • addresss/search-string/replace-string/g
  • For address
  • A period represents the current line
  • A dollar sign represents the last line
  • Eg, 1,s/better/best
  • 1,s/better/best/g
  • 6,S/good/better
  • 12, 25,s/bad/good
  • 1,.,s/worse/bad

5
Setting Parameters
  • Setting number, to give the line numbers
  • set number
  • set nonumber
  • Setting show mode, to show you if you are in
    input mode or not
  • set showmode
  • set noshowmode
  • Setting the ignore case in search
  • set ignorecase
  • set noignorecase

6
Executing Shell Commands
  • Execute a shell command form vi
  • !command
  • Execute a command and have vi replace the
    current line with the output from the command
  • !!command
  • Create a new interactive shell
  • sh
  • bash

7
Cut, copy and paste
  • To yank (copy) the current line yy
  • 4yy
  • To cut, use the delete commnad
  • dd, 6dd
  • To paste the deleting or yanking character or
    word
  • P inserts before the character, p inserts after
    it
  • To paste the deleting or yanking lines,
    sentences, or paragraphs
  • P puts before the line, p puts it after

8
Task 1
  • 1.What is the command to obtain a listing of your
    current directory without leaving vi?
  • 2. What command instructs vi to substitute 1998
    with 2001 in all over the text?

9
Sentence ( ) and Paragraph
  • ) Moves forward to the beginning of next
    sentence or paragraph
  • ( Moves backward to the beginning of the
    current sentence or paragraph

10
Viewing the work buffer
  • H (Home) key positions the cursor at the left end
    of the top line of screen.
  • M (Middle) key moves cursor to the middle line
  • L (Lower) moves it to the bottom line

11
Viewing the work buffer
  • ltCTRLgtD Scroll the screen Down, half a
    screen-ful
  • ltCTRLgtU Scroll the screen Up half a screen
  • --------------------------------------------------
    ---
  • ltCTRLgtF Forward a whole screenful of new text
  • ltCTRLgtB Backward a whole screenful of new text

12
Task 2
  • What are the differences between the following
    commands?
  • I and i
  • A and a
  • O and o
  • R and r
  • U and u

13
Task 3
  • What command would you use to search backward
    through the Work Buffer for lines that start with
    the word it?
  • What command substitutes all occurrences of the
    phrase this week with the phrase next week?

14
Some other commands
  • Join two lines
  • J
  • Repeat the recent command
  • . (period)
  • Finds next character (eg. c) on the current line
  • fc
Write a Comment
User Comments (0)
About PowerShow.com