Vi Editor

  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Vi Editor as PDF for free.

More details

  • Words: 975
  • Pages: 3
Chapter8 The vi Editor

Introduction to vi υ

Modes of Operation :

ESC Input mode

Command mode Insert, Append, Replace …

υ

Last Line mode Enter

The Work Buffer  During the editing session, vi make all changes in the buffer

Basic (Loading and Saving files) υ υ υ υ υ υ υ

vi [filename] - start vi ( edit filename) vi +[number, /string] - begin with start line, first matching string, relatively :e filename - edit filename :q - terminate vi without saving :q! - terminate vi, leave file unchanged :w - save edited file, stay in vi :r filename - read in text in filename

Command mode - Moving the Cursor υ υ υ υ υ υ υ υ υ

Input Mode υ υ υ υ υ υ υ υ υ

i - insert before the cursor a - append after the cursor o - insert the text on a new line after the current line r - replace the current one character, automatically return to command mode I - insert the text at start of line A - insert the text at end of line O - insert the text on a new line before the current line R - overwrite all character until press <ESC> <ESC> - return to command mode

l,h,j,k - move right, left, down, up w,b,e - move right one, left one, to end of word W,B,E - equivalent above except the space delimited word -,Enter - move start of upper line, start of next line ^,$ - move start of line, end of line +u,d,b,f - move screen one half-page up, one half page down, one page up, one page down in text H,M,L - move left end of top, middle line, bottom line G - move to last line nG - move to nth line

Command mode - Deleting text υ υ υ υ υ υ υ

x - delete the character under the cursor dw - delete to the of word dW - delete to end of space delimited word D - delete to end of line dd - delete the current line u - undo the last change made U - restore current line to previous state

1

Command mode - Changing text υ υ υ υ υ

cw - change to end of word cb - change to begin of word cW - change to end of space delimited word cB - change to begin of space delimited word cc - change the current line

Searching for a String υ

The Search Commands  /xxx - search forward for text string xxx  ?xxx - search backward for text string xxx  / - repeat search forwards  ? - repeat search backwards  n - repeat search in same direction  N - repeat search in opposite direction

υ

Special Characters in Search Strings  ^ - the beginning-of-line indicator  $ - the end-of-line indicator  . - the any character indicator  \> - the end-of-word indicator  \< - the beginning-of-word indicator  [ ] - the character class definition

Substituting One String for Another υ υ

[address]s/search-string/replace-string[/g] address  number - line number  77,100 - line 77 through 100  1, . - the beginning of the work buffer through the current line  .,$ - the current line through the end of work buffer  1,$ - the entire work buffer  % - the entire work buffer  .,.+10 - the current line through the tenth following line

Miscellaneous Commands υ υ

 End line mode - :f υ υ

The Put, Delete and Yank Commands υ

The General Purpose Buffer  Store the text that you most recently changed, deleted and yanked.  Undo command uses the general purpose buffer when it restores text

υ

y - yank command  yy, Y - yank the current line  nyy, nY - yank the n line from current line

υ υ

J - join command -g - status command (line number of current line, total number of line) . - period command (repeat the most recent command that made a change) ~ - tilde command (change between lowercase and uppercase)

Reading and Writing Files υ

Read Command

υ

Write Command

 :[address]r [filename]  :[address]w[!] [filename] - overwrite mode  :[address]w>>filename - append mode  address - the same as substitution command

p - paste the text on a new line after the current line P - paste the text on a new line above the current line

2

Setting Parameters υ

Setting Parameters in a Startup File  Bourne and Korn shell - .profile EXINIT = ‘set param1 param2 …’ export EXINIT

 C shell - .login setenv EXINIT = ‘set param1 param2 …’

 .exrc set param1 param2 … υ

Parameters  :set all - show all parameter  number, nonumber - show line number, hide line number  wrapmargin=nn - break the line by inserting character at the closest blank delimited word boundary λ

Setting Parameters υ

Parameters (Cont.)  Shell[=pathname]  showmode, noshowmode - give a cue to let you know when vi is in Input Mode  flash, noflash - beep when give invalid command or press <ESC> in Command Mode  ignorecase, noignorecase - ignore case in search  magic, nomagic - special characters in search strings have no special meanings (except ^, $)  list, nolist - show -> ^I, end of line -> $  wrapscan, nowrapscan  autoindent, noautoindent  shiftwidth=nn

nn - the number of character from the right side of the screen

Units of Measure υ υ υ υ υ υ

Character Word - <space>, ,, numeral, punctuation marks Line - Sentence - period, exclamation point, question mark, followed by two <space> or a Paragraph - blank line Screen

3

Related Documents

Vi Editor
November 2019 27
Vi Editor
November 2019 29
Vi Editor
October 2019 29
Vi Editor
November 2019 36
Vi Editor Commands
May 2020 13
Vi Editor Commands
November 2019 20