CS 497C – Introduction to UNIX Lecture 10: The vi/vim Editor Chin-Chih Chang

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

CS 497C – Introduction to UNIX Lecture 8: The vi/vim Editor Chin-Chih Chang
Editing with vi Or more fun than you thought you’d have without a mouse Prof. Chris GauthierDickey.
CS 497C – Introduction to UNIX Lecture 29: - Filters Using Regular Expressions – grep and sed Chin-Chih Chang
Program Development Tools IDE vs point tools Two tool flavors exist for developing embedded software: -IDEs: (Integrated Development Environments) i.e.,
CS 497C – Introduction to UNIX Lecture 22: - The Shell Chin-Chih Chang
Chin-Chih Chang CS 497C – Introduction to UNIX Lecture 28: - Filters Using Regular Expressions – grep and sed Chin-Chih Chang
CIS 240 Introduction to UNIX Instructor: Sue Sampson.
CS 497C – Introduction to UNIX Lecture 31: - Filters Using Regular Expressions – grep and sed Chin-Chih Chang
CS 497C – Introduction to UNIX Lecture 17: - The GNU emacs Editor Chin-Chih Chang
Linux+ Guide to Linux Certification, Second Edition
Chapter 5 Editing Text Files
CS 497C – Introduction to UNIX Lecture 18: - The GNU emacs Editor Chin-Chih Chang
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 23: - Simple Filters Chin-Chih Chang
CS 497C – Introduction to UNIX Lecture 9: The vi/vim Editor Chin-Chih Chang
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.
CS 497C – Introduction to UNIX Lecture 19: - The GNU emacs Editor Chin-Chih Chang
Filters using Regular Expressions grep: Searching a Pattern.
Copyrights© 2008 BVU Amplify DITM Basics of OS,UNIX/LINUX and Shell programming Page:1 Lesson 3: Vi- editor By Simi By Simi.
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:
Linux+ Guide to Linux Certification, Third Edition
Agenda Using vi Editor Starting vi Session Command / Input Modes Entering Text Editing Text Saving vi Session Aborting Editing Session.
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.
Week 3 Exploring Linux Filesystems. Objectives  Understand and navigate the Linux directory structure using relative and absolute pathnames  Describe.
January 23, 2007Spring Unix Lecture 2 Special Characters for Searches & Substitutions Shell Scripts Hana Filip.
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.
Agenda Regular Expressions (Appendix A in Text) –Definition / Purpose –Commands that Use Regular Expressions –Using Regular Expressions –Using the Replacement.
1 © 2014 John Urrutia. All rights reserved. Chapter 7 The “ Emacs “ Editor.
Introduction to Unix – CS 21 Lecture 8. Lecture Overview More detail on emacs and vi Regular expression matching in emacs and vi.
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.
4 Editing files and Emacs Editing files The Emacs editor.
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.
Introduction to Unix – CS 21 Lecture 7. Lecture Overview Regular expressions revisited emacs versus vi Basic emacs and vi usage.
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.
1 © 2012 John Urrutia. All rights reserved. Chapter 6 The vi Editor.
Lesson 4-Mastering the Visual Editor. Overview Introducing the visual editor. Working in an existing file with vi. Understanding the visual editor. Navigating.
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
1 Lecture 3 More on editors: emacs and vi COP 3344 Introduction to UNIX.
Linux+ Guide to Linux Certification, Second Edition Chapter 4 Exploring Linux Filesystems.
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.
FILTERS USING REGULAR EXPRESSIONS – grep and sed.
BIF703 FTP (File Transfer Protocol) Utility vi editor Utility.
Basic VI Tran, Van Hoai Faculty of Computer Science and Engineering HCMC Uni. of Technology
CS:414 introduction to Unix and Linux
PROGRAMMING THE BASH SHELL PART III by İlker Korkmaz and Kaya Oğuz
Vim basics Vi IMproved.
PROGRAMMING THE BASH SHELL PART IV by İlker Korkmaz and Kaya Oğuz
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)
Chin-Chih Chang CS 497C – Introduction to UNIX Lecture 28: - Filters Using Regular Expressions – grep and sed Chin-Chih Chang
Lesson 3: Find and Replace Tools
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:

CS 497C – Introduction to UNIX Lecture 10: The vi/vim Editor Chin-Chih Chang

String Search vi supports two forms of searches: –Search for a string or a regular expression in the entire file. –Search for a single character in the current line. Search commands in vi: –/str – searches forward for pattern str. –?str – searches backward for pattern str. –n – repeats search in the same direction. –N – repeats search in the opposite direction. –fch – moves cursor forward to first occurrence of character ch in the current line.

String Search –Fch – moves cursor backward to first occurrence of character ch in the current line. –tch – moves cursor forward onto but before first occurrence of character ch in the current line. –Tch – moves cursor backward onto but before first occurrence of character ch in the current line. –; - repeats search in the same direction made with f, F, t, or T. –, - repeats search in a direction opposite to that made with f, F, t, or T.

Searching with Regular Expressions vi accepts a generalized pattern containing some special characters (metacharacters) as the search expression. This pattern is called a regular expression and is used to match a group of similar strings. The regular expression characters used by vi :

Searching with Regular Expressions –* - matches zero or more occurrences of the previous character. –[pqr] – matches a single character which is either a p, q, or r. –[^pqr] – matches a single character which is not a p, q, or r. –. – matches a single character. –^pat – matches pattern pat at beginning of line. –\<pat – matches pattern pat at beginning of a word. –pat\> - matches pattern pat at end of a word.

Search and Replace (:s) Search and replace commands in vi : –:n1,n2s/s1/s2 – replaces first occurrence of string or regular expression s1 with string s2 in lines n1 to n2. –:1,10s/find/look/g – replaces all occurrences of find with look in lines 1 to 10. –:.,$s/find/look/gc – interactively replaces find with look from current line through the end. –:s – repeats the last substitution on the current line (Linux only).

Handling Multiple Files vi uses the Last Line Mode to handle multiple files and buffers. These are advanced file handling commands: –:r note – reads file note below current line. –:r !date – reads output of date between current line. –e note – stops editing current fine, and edits file note. –e! note – stops editing, but after abandoning changes made to current file.

Handling Multiple Files –:e! – loads last saved edition of current file. –[Ctrl-^] – returns to most recently edited file. –e# – returns to most recently edited file. –n – edits next file (when vi is invoked with multiple filenames). –rew – rewinds file list to start editing first file (when vi is invoked with multiple filenames). You can split the screen into multiple windows in vim. –:sp – splits the window. –[Ctrl-w][Ctrl-w] – moves between windows.