UNIX Intro.86 10. vi  vi is the standard UNIX text editor v Contents 1.Why use vi ? 2. vi Basics 3.Moving Around 4.Inserting Text.

Slides:



Advertisements
Similar presentations
In the last Session… ls -l command seven fields nine permissions of a file ls -ld file ownership file permissions (three-tiered file protection system)
Advertisements

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.
Cosc 4750 Getting Started in UNIX Don’t be afraid of the prompt, in linux it can be your best friend. In some cases, the only way to do certain things.
Program Development Tools IDE vs point tools Two tool flavors exist for developing embedded software: -IDEs: (Integrated Development Environments) i.e.,
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.
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 Three The UNIX Editors. 2 Lesson A The vi Editor.
The UNIX development environment CS 400/600 – Data Structures.
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.
4 Editing files and Emacs Editing files The Emacs editor.
Chapter 5 Editing Text Files. Basic Concept A text editor works on a file buffer that is a memory copy of a disk file The disk file is not updated until.
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.
Basic vi Commands Michael Davis Phd Student, Atmospheric Science.
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.
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.
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
Vim basics Vi IMproved.
Guide To UNIX Using Linux Third Edition
Vi Editor.
Unix Fundamentals - Part iii vi Editor
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
Text Editors Vim (Chapter 6) Emacs (Chapter 7)
The Linux Command Line Chapter 12
Emacs CSC 135.
Chapter 2 Basic vi Editor.
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
Day 5 Emacs Editor David A. Gaitros Department of Computer Science
The Linux Command Line Chapter 12
Presentation transcript:

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

UNIX Intro.87 5.Deletion 6.Cut & Paste 7.File-related Commands 8.Text Substitution 9.Recovering after a Crash

UNIX Intro Why use vi? v very powerful v useful simple subset of commands v portable (PCs, mainframes, etc.) v designed for slow networks v full-screen

UNIX Intro vi Basics 2.1.Starting vi 2.2.Two Modes 2.3.The vi Window 2.4.When to type RETURN 2.5.Finishing a vi Session

UNIX Intro Starting vi  vi file Start editing file v Changes are stored in a buffer, so you must save to change the file. v If the machine crashes, the buffer can usually be recovered (see later).

UNIX Intro Two Modes v Command mode –move cursor, save, delete text, quit vi, etc. v Input mode –for inserting text –start by typing i; finish with ESC –cannot quit, delete, etc. in this mode –If in doubt, press ESC a few times. This will put you back in command mode.

UNIX Intro The vi Window v Bottom line is the status line v Some, but not all, commands are shown on the status line. v Often you type a command and nothing appears on the screen!

UNIX Intro.93  Colon commands (e.g. :q! ) and search commands (e.g. /text ) require a RETURN.  Commands that start with a letter (e.g. ZZ, G ) and control characters (e.g. ^L ) do not require a RETURN 2.4. When to type RETURN

UNIX Intro Finishing a vi Session  Get to command mode (press ESC s) ZZ save changes to the file and quit (no RETURN ) :q! quit without saving (press RETURN )

UNIX Intro Moving Around 3.1.Basic Cursor Movements 3.2.Larger Moves

UNIX Intro Basic Cursor Movements h move cursor one place to left j down one k up one l right one w move forward one word b back one word No RETURN required!

UNIX Intro Larger Moves G go to last line G go to line number G go to line number10G ^G shows the current line number ^F Forward a screen ^B Back a screen

UNIX Intro.98 /text Search forward for text /func search for func /printf( search for printf( /^foo search for foo at start of line Type RETURN !

UNIX Intro Inserting Text v Move to insertion point  Switch to input mode: i v Start typing; BACKSPACE or DELETE for deletion  ESC finish; back in command mode No RETURN

UNIX Intro.100 v Over a slow network, the screen may not refresh properly ^L refresh screen (in command mode)

UNIX Intro Deletion v Must be in command mode. x Delete character that cursor is on. dd Delete current line. D Delete from cursor position to end of line u Undo last command

UNIX Intro.102 :i,jd Delete lines i to j :23,29d Delete lines 23 to 29 v Special line numbers:.means the current line number ^means line number 1 $means last line :.,$d Delete from current line to the end of file.

UNIX Intro Cut & Paste 6.1.Cut & Paste Meaning 6.2.Cut & Paste with Deleted Text 6.3.Moving Text

UNIX Intro Cut & Paste Meaning v Cut commands remove text from the screen, and store it in a buffer v Paste commands copy text from the buffer to the screen

UNIX Intro Cut & Paste with Deleted Text v d or dd or D delete from screen and store text in a buffer v move cursor to new location  p paste contents of buffer to right of cursor posn

UNIX Intro Moving Text v Cut and Paste with move  :i,jmk move lines i through j to start after line k :3,8m10 move lines 3 to 8 to start after line 10 :20m. move line 20 to after the current line :1,.m$ move lines 1 through current line to the bottom

UNIX Intro File-related Commands :w file writes vi contents to new file :w >> file appends to file :w! file writes over file :w! writes over input file :r file read in file; places it starting at current cursor position

UNIX Intro Text Substitution :s/old/new/g replace every occurrence of old by new. Dangerous! :s/Hat/Haad/g

UNIX Intro.109 :i,js/old/new/g replace every occurrence of old by new between lines i and j :2,200s/Andy/Andrew/g :1,.s/fc/function/g from line 1 to current :23,$s/pd/procedure/g from line 23 to end

UNIX Intro Recovering after a Crash vi -r List files that can be recovered vi -r file Recover file.  You should make a backup of file first: cp file file.bak