Unix Fundamentals - Part iii vi Editor

Slides:



Advertisements
Similar presentations
In the last class… The vi basics command, input and ex mode Input mode – entering and replacing text Saving text and quitting – the ex mode.
Advertisements

June 1, 1999Vi Editor1 Introduction to UNIX C. Vi Editor.
CS 497C – Introduction to UNIX Lecture 8: The vi/vim Editor Chin-Chih Chang
A Guide to Unix Using Linux Fourth Edition
Editing with vi Or more fun than you thought you’d have without a mouse Prof. Chris GauthierDickey.
CIS 240 Introduction to UNIX Instructor: Sue Sampson.
Vi Editor TA for ITIS3100: Xu Fei
Chapter 5 Editing Text Files
1 Using Editors Editors let you create and edit ASCII files UNIX normally includes two editors: vi and Emacs Vi and Emacs are screen editors: they display.
CS 497C – Introduction to UNIX Lecture 9: The vi/vim Editor Chin-Chih Chang
Starting Vi Opening an existing file vi filename Creating a new file vi filename In your workshop directory, create a new file called mysong vi mysong.
CS465 - UNIX The vi Editor. Creating Files Most human-readable files on Unix are created with a text editor Unix has many, many different editors ed a.
Copyrights© 2008 BVU Amplify DITM Basics of OS,UNIX/LINUX and Shell programming Page:1 Lesson 3: Vi- editor By Simi By Simi.
CSCI 330 T HE UNIX S YSTEM Editing files. E DITOR C ONCEPTS Editing a file is to modify the content of a file Text editor: Enter and modify text in a.
Using Linux Text Editors. Use Non-Graphical Linux Text Editors Graphical Text Editor.
1 Unix Editors (ee, ed, ex, vi, vim) and Compilers (g77, gcc) Speaker: Li-Wen Chen Date:
Chapter 3 Mastering Editors
Chapter 3: The UNIX Editors ASCII and vi Editors.
Chapter Three The UNIX Editors. 2 Lesson A The vi Editor.
Agenda Using vi Editor Starting vi Session Command / Input Modes Entering Text Editing Text Saving vi Session Aborting Editing Session.
T HE VI EDITOR. vi has 2 modes: command mode (initial or "default" mode) insert mode [Esc] is used to switch to command mode. In general, vi commands:
Course materials may not be reproduced in whole or in part without the prior written permission of IBM. 5.1 © Copyright IBM Corporation 2008 Unit 7 Editing.
Software I: Utilities and Internals Lecture 2 – The vi Text Editor * Modified from Dr. Robert Siegfried original presentation.
Introduction to Vim Robbie CSCI2100 Data Structures Tutorial 3.
Chapter8 The vi Editor. Introduction to vi u Modes of Operation u The Work Buffer  During the editing session, vi make all changes in the buffer  Advantage.
UNIX Intro vi  vi is the standard UNIX text editor v Contents 1.Why use vi ? 2. vi Basics 3.Moving Around 4.Inserting Text.
Text editors Why should I use an editor ? It is very important to able to use at least one text mode editor a text mode editor is so useful on remote machines.
Unix Editors. u Editors in Unix come in two general flavours: –modal editors have "modes" v generally input mode and command mode –input mode allows entry.
Tony Kombol.  Why text edit?  Many programs and features require configuration ▪ Configuration is kept in files ▪ Usually in the /etc directory  Changes.
Unix Session IV.
Text Editing February 2 nd, 2004 Class Meeting 3.
1 of 47 Chapter 4: The vi Editor – First Look Copyright ©2008 by Pearson Education, Inc. Upper Saddle River, New Jersey All rights reserved.
Chapter Three Text Editing1 System Programming Text Editing.
VI EDITOR University of Mississippi. Vi Editor What is Vi ? ▫Vi is a screen based editor. ▫The screen of your terminal will act as a window into the file.
Chapter 9 Using Text Editors. vi Editor visual Editor, ASCII text editor, no formatting capabilities almost as powerful as MS Word, has 26 clipboards.
1 © 2012 John Urrutia. All rights reserved. Chapter 6 The vi Editor.
Introduction to Unix (CA263) File Editing By Tariq Ibn Aziz.
Lesson 4-Mastering the Visual Editor. Overview Introducing the visual editor. Working in an existing file with vi. Understanding the visual editor. Navigating.
Chapter Three The UNIX Editors.
Linux Class #03. File Access Permissions Types of users in Linux: Local User (u) Group User (g) Other User (o) Each User can have 3 types of permissions:
Isecur1ty training center Presented by : Eng. Mohammad Khreesha.
THE vi EDITOR. Introduction There are three editors available in almost all versions of Unix: ed, ex and vi. The ed program is the original editor that.
Text editing and more basic commands CS 2204 Class meeting 3 *Notes by Doug Bowman and other members of the CS faculty at Virginia Tech. Copyright
Agenda Using vi Editor Starting vi Session Command / Input Modes Entering Text Editing Text Saving Edited File Aborting Editing Session.
Agenda Using vi Editor Starting vi Session Command / Input Modes
Vi editor Pronounced: `vee eye‘’. Agenda Describe the background of vi Editor Use vi editor to: create text files edit text files Our Goal is to create.
Amir Afzal UNIX Unbounded, 5th Edition Copyright ©2008 Chapter 6: The vi Editor – Last Look 1 of 55 Copyright ©2008 by Pearson Education, Inc. Upper Saddle.
Getting Started with Linux Linux System Administration Editors.
BIF703 FTP (File Transfer Protocol) Utility vi editor Utility.
ITX2000 Remote hosts and web servers Prof. Xiaohong (Sharon) Gao Room: T125 Ext: Week 14 – UNIX vi text editor.
Basic VI Tran, Van Hoai Faculty of Computer Science and Engineering HCMC Uni. of Technology
CS:414 introduction to Unix and Linux
Guide To UNIX Using Linux Third Edition
Nassau Community College
Vi Editor.
Vim.
Vi Introduction Tony Kombol.
Linux 104 Training Module File Editing.
Lecture 3 More on editors: emacs and vi COP 3344 Introduction to UNIX.
IT244 - Introduction to Linux / Unix Instructor: Bo Sheng
Linux System Administration Editors
Free Ride Review Game.
Text Editors Vim (Chapter 6) Emacs (Chapter 7)
New Perspectives on Windows XP
Chapter 2 Basic vi Editor.
An Introduction to Computers and Visual Basic
The Emacs Editor Read: Forouzan, Appendix C
CSCI The UNIX System Editing files
In the last class… The vi basics command, input and ex mode
Presentation transcript:

Unix Fundamentals - Part iii vi Editor UNIX III Unix Fundamentals - Part iii vi Editor 4-Sep-98 1 1

Unix Editors Unix editors are key to use creatively the computer; Editors allow to: create & alter text files; format text files; and more. The ex family of editors consists of ex - line editor (replaces ed) edit - trimmed down version of ex vi - visual editor ed - original standard editor. 4-Sep-98 3 3

Memory Buffer Files are stored in system’s hard drive; When using an editor, a copy of the files is pulled into memory (RAM), leaving the original file undisturbed; This copy is stored in a temporary workspace called the buffer (in memory); Changes are made to this copy, not to the original file; To keep the changes, one has to write (w) the buffer onto the system’s hard drive. 4-Sep-98 3 3

History of vi vi editor was developed at UC Berkeley, as part of BSD Unix; AT&T System V made vi part of the operating system; Before vi the standard editor was ed; ed was a line-oriented editor. When ex came along, ed became a subset of ex; ex allows the user to work on a full-screen mode. This mode is called visual display (vi). 4-Sep-98 3 3

History of vi (cont) When working with ex editor, there are five modes of operation: ex command mode; ex input mode; vi command mode; vi input mode; and vi last line mode. Using vi most likely we use vi command mode & vi input mode. Ocassionally, we will be using last line mode. 4-Sep-98 3 3

vi Screen Editor Modes of Operation: 4-Sep-98 3 3

vi Screen Editor when vi is invoked, it starts in the command mode. This means that any keyboard stroke is interpreted as a command. in command mode we can: delete words; delete lines; change a spelling error; and more. 4-Sep-98 3 3

vi Screen Editor To change to (text) input mode, use the append command (a). This is, press [a]-key. when in input mode, key strokes will be interpreted as text to be stored in the buffer, not as a command; To exit the input mode, use the [Escape]-key; To save the changes in command mode, or the text typed in input mode, we use the write command (w). w saves the entire buffer, or a segment of it. 4-Sep-98 3 3

vi Screen Editor Modes of Operation: 4-Sep-98 3 3

vi Screen Editor Basic Commands: Cursor Position: [h], [j], [k], [l], and [Return]; (text) Input Mode: [a], [i], [o], [O]; Leave (text) Input Mode: [Esc]; Delete / Replace: [x], [dd], [r]; Undo Changes: [u], [U]; Save / Quit vi editor: [Z][Z], :[w], :[q][!], :[w][q]; Erase characters: [Delete], [Ctrl][h]. 4-Sep-98 3 3

vi Screen Editor Additional vi Commands: Cursor Position including scrolling, paging, and searching: [Ctrl][d], [Ctrl][f], [Ctrl][b], [Ctrl][u], [e], [b], [G], n[G], [Ctrl][g], /patterm, [$], [0]; Commands to operate on words, lines, sentences, paragraphs: [c], [d], [y]; Abbreviations for words, lines, sentences, paragraphs: [w], [b], [e], [<], [>], [O], [$], [{], [}]; Print buffer: [p], [P]; Join lines: [J]; 4-Sep-98 3 3

vi Screen Editor To invoke vi: 4-Sep-98 3 3

vi Screen Editor 4-Sep-98 3 3

vi Screen Editor When calling vi, it responds by displaying on the screen the contents of the file, followed by a series of tildes (~); vi starts in command mode; Cursor is positioned at the beginning of file (upper left-hand corner of display); To leave vi, type the following sequence: [Esc][:][w][q] [Return] or [Esc][:][w] [Return] :wq stands for write & quit; :w stands for quit. 4-Sep-98 3 3

4-Sep-98 3 3

vi Screen Editor Cursor Movement: Use the [arrow keys], or [h]: left move, same line; [l]: right move, same line; [k]: cursor up one line; [j]: cursor down one line; [Return]: position cursor at beginning of next line down. 4-Sep-98 3 3

vi Screen Editor (text) Input Mode: To start typing text, use any of the following commands: [a]: appends; [i]: insert; [o] and [O]: open. Press [Return] to start a new line. When typing use the [Backspace] or [Delete] keys to backup and correct mistakes. 4-Sep-98 3 3

vi Screen Editor Wraparound The length of a line on the screen may not correspond to its actual line in the editor; A line longer than 80 characters (typically) may show on the screen as two lines, but vi recognizes it as a single line; Solutions: Hit [Return]-key before the eightieth character; In command mode, type :set wrapmargin=nn :set wm=nn nn is a number representing margin size. 4-Sep-98 3 3

vi Screen Editor Use of the four (text) input modes: [a]: enters whatever is typed after the cursor, pushing the rest of the line to the right; [i]: enters whatever is typed before the cursor, pushing the rest of the line to the right; [o]: opens a new line below the cursor & places the cursor at the beginning of the new line; [O]: opens a new line above the cursor & places the cursor at the beginning of the new line; 4-Sep-98 3 3

vi Screen Editor Deleting & Changing Text: All these commands are made from the command mode, and vi stays in command mode after they are executed; Use [Esc]-key if not in command mode; [x]: erases the character under the cursor; nn[x]: erases nn-1 characters to the right of the cursor, and the character under the cursor; [d][d]: deletes the line where cursor is positioned; [r]char: replaces the character under the cursor by the character char. 4-Sep-98 3 3

vi Screen Editor Undoing Changes: These commands undo what it has been just done; [u]: undo the last change. Issue only in command mode; if a line has been deleted using [dd], press [u] to recover the line; if [i] is used to insert the word mush in a line, [u] will remove the word (we must return to command mode). [U]: undo all the changes made on the current line. 4-Sep-98 3 3

vi Screen Editor Exiting vi editor: [Esc][Z][Z]: writes the contents of the buffer onto disk for permanent storage. Uses the filename that it was used to enter vi; [Esc][:][w][q]: w stands for write. and q stands for quit. Similar to [Esc][Z][Z]; [Esc][:][q][!]: quits vi, and discards the changes made to the temporary buffer. 4-Sep-98 3 3

vi Screen Editor Cursor-positioning Commands [b]: moves the cursor to the beginning of a word; [e]: moves the cursor to the end of a word; [0]: (zero) moves the cursor to the beginning of the current line; [$]: moves the cursor to the end of the current line. Note: with [0] or [$] the cursor does not jump to the next line or above line as it does with the [b] and [e] key commands. 4-Sep-98 3 3

vi Screen Editor Screen Scrolling & Paging Commands [Ctrl][d]: scrolls or pages the cursor down, usually 12 lines at a time; [Ctrl][f]: scrolls or pages the cursor forward, usually 24 lines at a time; [Ctrl][u]: scrolls or pages the cursor up, usually 12 lines at a time; [Ctrl][b]: scrolls or pages the cursor back, usually 24 lines at a time. Note: These commands are appropriate for mid-size text files, where a few scrolls will cover the entire file length. 4-Sep-98 3 3

vi Screen Editor Screen Scrolling & Paging Commands These are commands issue while in command mode; nn[G]: moves the cursor to line number nn; [G]: moves the cursor to the end-of-file; [Ctrl][g]: echoes the line number the cursor is currently on. 4-Sep-98 3 3

vi Screen Editor Pattern Search Commands issued while in command mode; /string [Return]: vi positions the cursor at the first occurrence of string string - forward search; ?string [Return]: vi positions the cursor at the first occurrence of string string - backward search; 4-Sep-98 3 3

vi Screen Editor Deletion, Changes & Rearranging Text Operator + Scope = Command; Example: dd is operator d, and scope d. dw is operator d, and scope w. Operators: [d]: delete text, and stores a copy in a temporary memory buffer; [p]: put(s) text, recovers text from temporary memory buffer; [y]: yanks (copies) text, and places in temporary memory buffer, for positioning elsewhere; original remains unchanged; [c]: change operator; equivalent to delete & insert. 4-Sep-98 3 3

vi Screen Editor Deletion, Changes & Rearranging Text Scope: [e]: from cursor position to end-of-current-word; [w]: from cursor position to beginning of next word; [b]: from the cursor position backwards to beginning of current word; [$]: from the cursor position to end-of-current-line; [0]: from cursor position to beginning-of-current-line; [)]: from cursor position to beginning of next-sentence; [(]: from cursor position back to beginning of current-sentence; [}]: from cursor position to beginning of next-paragraph; [{]: from cursor position back to beginning of current-paragraph; 4-Sep-98 3 3