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.

Slides:



Advertisements
Similar presentations
A Guide to Unix Using Linux Fourth Edition
Advertisements

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.
VIM: The basics Tang Wai-Chung, Matthew (MaFai) 29/12/2006.
Vi Editor TA for ITIS3100: Xu Fei
Chapter 5 Editing Text Files
UnixUnix Basic. Convention Italic text indicates text displayed by the computer system. For example, login: indicates a login prompt displayed by the.
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
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:
Linux environment ● Graphical interface – X-window + window manager ● Text interface – terminal + shell.
Chapter 3 Mastering Editors
Chapter Three The UNIX Editors. 2 Lesson A The vi Editor.
Introduction to vi. Intro to vi vi is a ubiquitous text editor. It is available for Linux, Unix, Mac OS X and Windows (from and.
The UNIX development environment CS 400/600 – Data Structures.
More on Linux - vi Opening Discussion zWhat did we talk about last class? zYou will use the command line a lot in this course. So lets review.
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:
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.
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.
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.
1May 16, 2005 Week 2 Lab Agenda Command Line FTP Commands Review More UNIX commands to learn File name expansion - * Introduction of vi.
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.
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.
1 Lecture 3 More on editors: emacs and vi COP 3344 Introduction to UNIX.
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.
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
Purdue Linux Users Group Presents Linux 201: Session 1 Everything you ever wanted to do in VIM Thor Smith.
CS:414 introduction to Unix and Linux
Vim basics Vi IMproved.
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
Technical University of Kosice
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
The Linux Command Line Chapter 12
Presentation transcript:

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

Vi Modes of Operation – Command Mode Allows the entry of commands to manipulate text Default mode when vi starts Use Escape key to move into command mode – Insert Mode and Puts anything you type into the current file To get into insert mode, commands are a (append) and i (insert) 1. Use the i command to move into insert mode (Press i key). 2. Attempt to type in the title of your favorite song. 3. Use the Esc key to move to command mode.

Exiting the Vi Editor :q Quit the editor :q! Quit without saving changes to the file 1.Use the Esc key to make sure you are in command mode. 2.Use the :q command to try to quit vi 3.Use the :q! command to force quit without saving (Enter :q! ).

Saving Changes in vi :wq Write/save changes and quite :w Write/Save changes, but don’t quit 1.Type vi mysong to re-edit your song file. 2.Use the i command to move into insert mode (Press i key). 3.Retype the title of your favorite song. 4.Use the Esc key to move to command mode. 5.Use the :w command to write/save your edits to file. 6.Use the i command to enter insert mode (Enter i ). 7.Type Title: somewhere on the line with the song title. 8.Use the Esc key to move to command mode. 9.Use the :wq command to save and quit vi.

Vi Editor How to type commands in command mode [count] command [where] count : Its a number where : Specifies how many lines or how much of the document the command affects. It can also be any command that moves the cursor.

Moving the cursor in vi h key move cursor to the left one position l key move cursor right one position j key move cursor down one line k key move cursor up one line 1.Type vi mysong to re-edit your song file. 2.Use the l command several times to move cursor to the far right 3.Use the a command to move into append mode (Press a key). 4.Use the Enter key to start a new line of text. 5.Type: Artist: and then the name of the artist 6.Use the Esc key to move to command mode. 7.Practice moving cursor up, down, left, and right with h,l,j,k keys. 8..

Simple vi editing commands r replace one character under the cursor x delete 1 character under the cursor. 2x delete 2 characters (3x, etc.) u undo the last change to the file 1.Use the Esc key to make sure you are still in command mode. 2.Reposition your cursor and use the a, l, r and x commands to repair any typos in your title and artist, and change the title to ALL CAPS 3.Use the :w command to save your changes.

Cutting text in Vi d^ Deletes from current cursor position to the beginning of the line d$ Deletes from current cursor position to the end of the line Dw Deletes from current cursor position to the end of the word dd Deletes one line from current cursor position. Specify count to delete many lines.

Cutting & Yanking Text in Vi ddDelete (cut) 1 line from current cursor position 2ddDelete (cut) 2 lines (3dd to cut 2 lines, etc.) ppaste lines below current line 1.Move cursor to top line and type dd to cut the title line 2.Use the p command to paste the title line below the artist line 3.Use the p command to paste it again.

Cutting & Yanking Text in Vi yyyank (copy) a single line 2yyyank (copy) 2 lines (3yy to copy 3 lines, etc.) Ppaste lines before current line 1.Move cursor to first of the 2 title lines and type 2yy to yank/copy 2 lines 2.Move cursor to the first line, then use the capital P command to paste the two yanked links above the artist

Vi Editor To go to a specific line in the file :linenumber 1.Go to the 3 rd line by typing :3 2.Go to the 1 st line by typing :1 3.Go to the last line by typing G

Vi string/search /[pattern] search forward for the pattern ?[pattern] search backward for the pattern n search for the next instance of a string 1.Search forward for the next line containing the string Title by typing /Title 2.Search forward for the next instance of Title by typing n 3.Search backward for the most recent instance of Title by typing ?Title 4.Search backward for the next most recent instance of Title by typing n

More commands yl yank a single character. Specify count to yank more characters yw yank a single word. Specify count to yank more words d^ Deletes from current cursor position to the beginning of the line d$ Deletes from current cursor position to the end of the line Dw Deletes from current cursor position to the end of the word

Practice Editing with vi Take 5 minutes to practice what you’ve learned by entering as many of the lyrics to the song as you can. Use yank and paste to repeat chorus lines. Use :w to write changes every 30 seconds. Have one title line at line 1. Have one artist line at line 2. Save file and exit vi when finished or time expires.