Lesson 4-Mastering the Visual Editor. Overview Introducing the visual editor. Working in an existing file with vi. Understanding the visual editor. Navigating.

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.
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.
CS 497C – Introduction to UNIX Lecture 9: The vi/vim Editor Chin-Chih Chang
Lecture 02CS311 – Operating Systems 1 1 CS311 – Lecture 02 Outline UNIX/Linux features – Redirection – pipes – Terminating a command – Running program.
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.
1 Unix Editors (ee, ed, ex, vi, vim) and Compilers (g77, gcc) Speaker: Li-Wen Chen Date:
Chapter 3 Mastering Editors
Basic Text Processing, Redirection and Pipes. 222 Lecture Overview  Basic text processing commands head, tail, wc  Redirection and pipes  Getting to.
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:
리눅스 : Lecture 5 UNIX 유틸리티 : text editor, compilation (make), …
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.
Unix Environment Input Output 2  List Content (ls) ◦ ls (list current directory) ◦ ls –all (include hidden files/folders)  Make directory (mkdir) ◦
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.
Introduction to Unix (CA263) File Editing By Tariq Ibn Aziz.
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.
Lesson 3-Touring Utilities and System Features. Overview Employing fundamental utilities. Linux terminal sessions. Managing input and output. Using special.
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.
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.
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
Lesson 5-Exploring Utilities
Vim basics Vi IMproved.
Guide To UNIX Using Linux Third Edition
Vi Editor.
Unix Fundamentals - Part iii 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
Text Editors Vim (Chapter 6) Emacs (Chapter 7)
The Linux Command Line Chapter 12
Chapter 2 Basic vi Editor.
CSCI The UNIX System Editing files
In the last class… The vi basics command, input and ex mode
The Linux Command Line Chapter 12
Presentation transcript:

Lesson 4-Mastering the Visual Editor

Overview Introducing the visual editor. Working in an existing file with vi. Understanding the visual editor. Navigating through a file. Adding text to a file. Avoiding confusion while entering commands to shell and vi.

Overview Deleting text from a file. Undoing editing commands. Creating new files with the visual editor. Making changes to the text. Moving and copying text. Writing a file and quitting the editor.

Introducing the Visual Editor Bill Joy, a student of the University of California, wrote the vi editor. The UNIX/Linux visual editor is a powerful, fast, command- driven screen editor. The vi visual editor is available on all systems and is an essential tool. The vi editor allows the movement of cursor to a specific location in a file.

Introducing the Visual Editor The vi editor is present on every UNIX environment, uses few computing resources, and includes many tools. Standard UNIX releases include vi, and Linux provides vim, which includes some vi improvements. Command mode and append/insert are the two modes of the vi editor.

The command mode allows a user to access a file with basic vi commands. The append/insert mode allows a user to insert data characters in a file. Introducing the Visual Editor

Working in an Existing File with vi Files are central to the UNIX computing environment. The visual editor is used to create new files and edit existing files. The vi editor does not permit text to be added directly when editing a file. The “cat” utility can be used for creating a file in UNIX.

We can edit the files created by the cat command. We can access/open the files by giving the "vi filename" command. The command will open the files in the command mode. Working in an Existing File with vi

Understanding the Visual Editor Moving around in a file: Opening a file in vi allows a user to delete, move, copy and paste and save and quit the file. A user cannot insert characters while in the command mode. The fundamental way to move the cursor in a file is to do it with the direction keys.

Understanding the Visual Editor Moving around in a file (continued): The vi editor interprets the h, j, k, and l keys as a command to the move the cursor in specific directions. The workstation either flashes or beeps if an attempt is made to move the cursor beyond the existing text.

Understanding the Visual Editor Moving around in the file (continued): The vi editor also provides a forward search command for moving the cursor to a specific word in the text. The /text is the forward search command for moving the cursor to a specified text. The “n” command can be used for locating the next occurrence of a target string specified in the forward search command.

Understanding the Visual Editor Working with text: To insert characters to the file, we have to change from the command mode to the insert/append mode. The vi editor provides the dd command for deleting an entire line of text from a file. The “dd” command even deletes blank lines.

Understanding the Visual Editor Working with text (continued): After dd finishes deleting, it remains in the command mode. The “x” (x-out) command deletes only a single character under the cursor. The “a” command switches the vi editor from the command mode to the append mode and allows text to be entered to a file.

Understanding the Visual Editor Working with text (continued): The “u” command undoes the last text change made to the file. The ESC key instructs the vi editor to switch from the append/insert mode to the command mode. A user can check the mode he is working in with the ESC key. The “o” command tells the editor to open a new blank line between the cursor line and the next line in the file.

Understanding the Visual Editor Quitting the editor: The “wq” command instructs the editor to write the file and quit the editor. The “q” command can be used for quitting the editor if no changes are made to the file being edited. The “q!” command instructs the editor to quit without saving the changes made to the file.

Understanding the Visual Editor Creating and reading a file in the editor: A new file can be created in the vi editor by specifying the filename with the vi command. A file opens in the command mode. Text can be entered by switching to the insert/append mode. The “r” or the “read” command locates a file and reads its contents into the current file, starting immediately after the cursor line.

Navigating Through a File Using the direction keys: The arrow keys and the h, j, k, and l direction keys, either alone or in conjunction with the number keys, make it possible to move the cursor to any character in a file. The “set number” command tells the editor to display the line number on the screen. The commands “G” and “:$” instruct the editor to move to the last line of a file.

Navigating Through a File Lowercase “n” or “/” (slash) can be used to instruct the vi editor to search forward, whereas uppercase N or ? (question mark) is used to search in the backward direction. The “set ignorecase” command can be used to switch off the case-sensitivity feature of vi’s search mechanism. The “set” command can be used to view the environmental features that are currently set.

Navigating Through a File The “w” command can be used to advance the cursor to the beginning of the next word. The dollar sign ($) instructs the editor to move the cursor to the end of the current line. The caret (^) and the zero (0) move the cursor to the beginning of a line.

Navigating Through a File Moving the Cursor in vi

Navigating Through a File Moving to a Specific Textual Character in vi

Navigating Through a File Moving the Cursor by Line Address and Location Display

Navigating Through a File Two single quotation marks instruct the editor to return to the previous location in a file. The display adjustment commands are used to adjust the workstation’s screen display to move forward or backward to a different block or section of code, regardless of its context.

CTRL-F displays the next screen of a text file. CTRL-D scrolls down one half screen of a text file. CTRL-D scrolls up one half screen of a text file. CTRL-B displays the previous screen of a text file. Navigating Through a File

Adding Text to a File The “i” (insert) command starts adding text to the left of the cursor. The “a” and “i” commands instruct the editor to move from the command mode to the append mode and start adding text at the cursor position. The “O” command is an instruction to open a line above the line where the cursor resides and shift to the append/insert mode.

Adding Text to a File The “I” command instructs the editor to move the cursor to the beginning of a line and to change to the append mode. The “A” command moves the cursor to the end of a line and switches the editor to the append mode. The I and A command instructs the editor to switch to command mode.

Avoiding Confusion While Entering Commands to Shell and vi The “who” command, when executed in a shell, lists the users currently logged on. In the vi’s command mode, it moves the cursor to a specific position and moves over to the append mode. In vi’s append mode, the characters are entered directly into the file being edited.

Deleting Text From a File Multiple lines, words, and characters can be deleted by prefacing the delete command with a number. The uppercase “D” command instructs the editor to delete the remainder of the line starting from the character under the cursor. The “df*” command deletes the text from the cursor to the first character * on the current line to the right of the cursor.

Deleting Text From a File The vi editor also allows lines to be deleted using the line number addresses. The d command also allows a comma to be used for specifying a range of lines to be deleted. Commands that employ line addresses require the ENTER key to be pressed after the command for execution.

Undoing Editing Commands The “u” command undoes the last editing change in the file. The vi editor in Linux allows multiple changes to be undone. The “U” command undoes any number of changes made to the current line where the cursor is located.

Creating New Files with the Visual Editor The vi filename command is used for creating a new file as well as editing an existing file. The vi makes a buffer copy of a file if it exists, else it starts editing a memory buffer using the new filename. A file created in vi can be made executable by executing the chmod command.

Making Changes to the Text The “r” command instructs the editor to replace the character located under the cursor with the very next character typed in by the user. It can also be used for breaking up a long line into parts. The uppercase “J” command can be used for joining two lines of text.

Making Changes to the Text The “R” command switches the editor to the “type-over” mode, wherein each letter typed replaces the character under the cursor as it moves down the line. The “s” command substitutes the character under the cursor with the text typed in by the user until the ESC key is pressed. The “cw” (change word) command allows a user to substitute a word or multitude of words for a single word.

Making Changes to the Text The “cc” command deletes the text from the current line and moves you from the command mode to the append mode. The “C” command puts the editor into the append mode and allows a user to change part of the line from the cursor position to the end of the line. The substitute command, a colon command, is used to exchange one regular expression for another in a file.

Making Changes to the Text The substitute command requires two words to be separated by slashes. The “g” at the end of the substitute command is a flag and can be used for replacing all occurrences of the target pattern with the addressed lines. The substitute command can also be restricted to lines having specific content.

Moving and Copying Text The “yy” command instructs the editor to copy the contents of the line where the cursor resides. The “p” or “P” command is used for pasting a new line in a new location below the cursor line. The dd and p commands can be combined to perform a cut and paste operation.

Moving and Copying Text Commands to Move and Copy Text

Moving and Copying Text Marking a place in the file: The “m*” command instructs the editor to mark a line of text and assign it a label specified in the *; it can have a value from a to z. A single quote character with the label name can be used for moving on to a specific label. Vi allows deleting, changing, and yanking of text from the current position to the marked spot.

Moving and Copying Text The delete, change, and yank commands

Moving and Copying Text Marking a place in the file (continued): The mark command can also be used for simplifying the tasks of deleting, moving, and copying large blocks of text by marking both ends of the block. Marking text is a powerful way to identify lines to delete, move, or copy. The move or copy commands can be used for moving or copying a block of text specified using line numbers.

Writing a File and Quitting the Editor The “w” command can be used for saving a copy of the current file to a new file. The w or write command can also be used for writing a part or block of text from the current file to a new file.

The “w!” command instructs the editor to overwrite the contents of the file if it exists, else creates a new file for saving the contents of the current file. The >> symbol, when specified with the w command, appends the text to the file specified. Writing a File and Quitting the Editor

Summary The vi is the editor used to create and edit files. Vi provides several utilities to edit text. Append/insert and command are the two modes of the vi editor. Files created in the cat command can be opened in vi.

Summary A user cannot insert data without switching to the append/insert mode. The I, a, i, A, o, and O commands instruct the editor to add text relative to the cursor position. The vi editor provides the change (c), yank (y), and delete (d) operators for text operations.

Summary The vi provides various utilities to move, edit, delete, and replace text. The :wq is used for saving and quitting the editor. The vi editor facilitates global changes, where the user specifies the target for replacement and the replacement text. Linux provides an advanced version of the vi, namely the vim editor.