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.

Slides:



Advertisements
Similar presentations
CS 497C – Introduction to UNIX Lecture 8: The vi/vim Editor Chin-Chih Chang
Advertisements

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.
CS 497C – Introduction to UNIX Lecture 17: - The GNU emacs Editor Chin-Chih Chang
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.
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:
1 Unix Text Editors Creating files on the Unix system.
Chapter 3 Mastering Editors
Chapter Three The UNIX Editors. 2 Lesson A The vi Editor.
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.
Intro. To Unix commands For those who’ve never used Unix before Quick tutorial to let you move around your Unix Accounts No discussion of inner workings.
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.
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.
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.
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.
MS-WORD MS-Word is a word processing software. it helps you to create letters, memo, reports etc. HOW TO OPEN WORD click start menu button write Ms-word.
Chapter 9 Using Text Editors. vi Editor visual Editor, ASCII text editor, no formatting capabilities almost as powerful as MS Word, has 26 clipboards.
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:
Microsoft Word Level 1 Michael Carco. Word Level 1 Agenda  Word Basics  Navigating in a Document  Inserting and Modifying Text  Creating and Modifying.
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.
Emacs, Compilation, and Makefile C151 Multi-User Operating Systems.
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.
October 24,  Creating and Opening Files  Save and Exit  Navigation  Shortcuts  Copying, Cutting and Pasting  Searching and Replacing  More.
Getting Started with Linux Linux System Administration Editors.
ITX2000 Remote hosts and web servers Prof. Xiaohong (Sharon) Gao Room: T125 Ext: Week 14 – UNIX vi text editor.
By Justin Higgins. What is a text editor? If you’ve ever used Microsoft word you know what a text editor is (albeit a bloated one). When you write a program.
CS:414 introduction to Unix and Linux
Chapter 3: Mastering Editors Chapter 3 Mastering Editors (Emacs)
Vim basics Vi IMproved.
Guide To UNIX Using Linux Third Edition
Vi Editor.
Unix Fundamentals - Part iii vi Editor
Vim.
Vi Introduction Tony Kombol.
Lecture 3 More on editors: emacs and vi COP 3344 Introduction to UNIX.
Text Editors Vim (Chapter 6) Emacs (Chapter 7)
You do want to create and edit programs?
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
Presentation transcript:

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 of text –command mode allows positioning within the file and more sophisticated text modification v primary Unix examples: ed and vi –modeless editors (or WYSIWYG: What You See Is What You Get) have only one mode v positioning and text manipulation are done by special key sequences (like arrow keys and function keys) –could also be done by mouse actions or menus v primary Unix examples: emacs or pico

ed u ed is the original line editor u Still one of the most powerful editors available –Isn't a screen editor so people dislike it v It doesn't give you a “local” or screen picture of what is in your file –Ability to make massive changes with one command u We will meet its power base later: regular expressions u Many of its capabilities have been incorporated into newer editors like vi and emacs

vi (1) u Developed by UCB and comes with all versions of Unix. u Difficult to use, but very fast for experienced users. u Has three modes: Start vi Input mode Colon command mode Command mode quit i : q Esc Inserting text Editing File manipulation

vi (2) u Starting vi terra[21] > vi filename u Several basic commands –arrow keys move the cursor –x delete the current character –dd delete the current line –u undo the change –/ search for the text following / –i change to input mode –esc go to command mode –:w write to file –:wq save and quit –:q quit (if no change after the last saving) –:q! exit without save

vi (3) Cursor Movement –h move one char left –j move one line down –k move one line up –l move one char right –w move to next word –e move to end of current word –b move to beginning of previous word –0 move to the beginning of the current line –$ move to the end of the current line Screen Movement –Hmove to top of screen –Lmove to bottom of screen –^F scroll down one page –^B scroll up one page –^U scroll up one half page –^D scroll down one half page Search –/ search for something –? search backwards for something Adding Text –o (O) opens new line below (above) the current line –i (I) inserts text before current char (beginning of line) –a (A) appends text after current char (end of line)

vi (4) Deletion Commands u x delete character under cursor u D delete to end of line u dd delete entire line u d$ delete to end of line u d0 delete to beginning of line u dw delete the next word u db delete the previous word Other Commands u. redo last modification command u u undo the last command u :w file write the buffer to this file u :r file read this file into the buffer Change Commands u s substitute a string for current char (end with ESC) u r replace current char with another u R overwrite text (end with ESC) u C replace to end of current line (end with ESC) u c0 replace to beginning of current line (end with ESC) u cw replace the current word (end with ESC) u cb replace the previous word (end with ESC)

emacs (1) u Emacs: (Editor MACroS) –developed by Richard Stallman and James Gosling amongst many others –modeless –has versions for Unix, Windows, and other systems –menu-driven and mouse-driven under X-windows. u Emacs uses special keys (ESC and CTRL) to perform editor functions other than input u This editor can do everything –Contains a complete programming language (a LISP interpretter) which can be used to write functions for use in the editor

emacs (2) u Key combination: a sequence of (special) keys –C-x "Control X" v Hold down Control key while typing x. –C-x C-c v Hold down Control key while typing x and c. v Or hold down control key while typing x, then release, then hold down control while typing c. –C-x u v Hold down the Control key, keep it down while typing x. Release the Control key and type u. –ESC x "Escape x" or "Meta x" v What always works: –Type the Escape key. Release. Type x. v What sometimes works (and is convenient): –Hold down the Alt key and x key at the same time

emacs (3) u Starting Emacs on a file: terra[23]% emacs myfile v myfile is either a new or existing filename. u The following happen: –If the filename you typed was an existing file, you will see the first page of the file on your screen. –If you typed a new filename, you will be faced with a blank screen, and you may type the file. –The file name will appear at the bottom of the screen.

emacs (4) u When you encounter problems... –Emacs is a very powerful editor v No matter what key combination you press, it probably does something! v Sometimes it does something you didn't want! –UNDO v To undo last operation: Ctrl-_ (Control & underscore) v You can also use: Ctrl-x u v Can be repeated to keep undoing operations –Cancel v If you get to a mode which you don't want –e.g: you typed Ctrl-x and emacs expects more v Type Ctrl-g – It will usually back you out of almost anything

emacs (5) Cursor Movement u Arrow keys move the cursor around screen. u Alternatively, use: –Ctrl-f Forward a character (Right) –Ctrl-b Back a character (Left) –Ctrl-n Next line (Down) –Ctrl-p Previous line (Up) Other Movements: u Ctrl-a Beginning of line. u Ctrl-e End of line. u Ctrl-v View next screen. u ESC v View previous screen. u ESC < Start of file. u ESC > End of file. u ESC f Forward a word. u ESC b Back a word. u ESC x goto-line Goes to a given line number.

emacs (6) Cut and Paste u To move a block of text Move cursor to start of block Set mark Move cursor to end of block. Ctrl-w Wipe out (Cut) ESC w Copy. Move cursor to new location Ctrl-y Yank back last thing killed (Paste). –The Ctrl-y may be repeated for multiple copies. Text Deletion u Backspace –Kill character before cursor u C-k –Kill line - deletes to end of line. u C-d –Delete character at cursor u ESC d –Delete next word. u C-x u Undo last change. –Repeat to undo as many changes as you wish. u ESC x revert-buffer –Undo all changes since last save.

emacs (7) Save / Exit u Ctrl-x Ctrl-s –Save file (over-write original) u Ctrl-x Ctrl-c –Exit from emacs. u Ctrl-x Ctrl-w –Save in different file –You are prompted for name Emacs creates extra files. u When you save using Ctrl-x Ctrl-s, the old file will be kept as filename~. u If you exit without saving, the modified unsaved file will be saved as #filename#. Other Commands u Check spelling –Type ESC $ v Check spelling of 1 word. –ESC x spell-buffer or ESC x ispell-buffer v Check spelling of file. u Insert a file –Ctrl-x i v Insert a file at current cursor position. u Reformat regions –ESC q Reformat paragraph –To reformat a region: Move cursor to start of block. Move cursor to end of block. ESC q

emacs (8) Searching u Search allows you to search for a string u Search from the cursor position to the end of file. u To search for a string, type Ctrl-s string v Ctrl-s again repeats v Ctrl-g to quit Search and Replace u Replace all occurrences of one string with another –ESC x replace-string v you are prompted for the replacement text u Query-replace asks before replacing each occurrence. –Type: ESC % –you are prompted for search & replace strings. u At each occurrence, respond: –y/n to replace/not replace. –! to replace all remaining –ESC to exit –? for lots more options

Pico u pico is the PIne COmposer –the text editor used in the University of Washington’s popular pine program u pico is a modeless editor like emacs –always in “insert” mode –command keys available are always listed at the bottom of the screen –examples: v Ctrl-g Gets help v Ctrl-r Reads a file v Ctrl-o Writes a file v Ctrl-x Exits pico

Exercise 1 u Use vi or emacs to edit a.plan file in your “home directory”. –finger your_usr_name –Or /usr/bin/finger –l your_usr_name