1 Lecture 3 More on editors: emacs and vi COP 3344 Introduction to UNIX.

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.
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
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:
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.
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.
Introduction to vi (a Unix, Linux, and Windows text 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:
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.
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.
1 © 2014 John Urrutia. All rights reserved. Chapter 7 The “ Emacs “ Editor.
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.
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.
Getting Started with Linux Linux System Administration Editors.
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.
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.
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.
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
Vim.
Vi Introduction Tony Kombol.
Linux 104 Training Module File Editing.
Lecture 3 More on editors: emacs and vi COP 3344 Introduction to UNIX.
Text Editors Vim (Chapter 6) Emacs (Chapter 7)
Emacs CSC 135.
Chapter 2 Basic vi Editor.
Linux Operations and Administration
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:

1 Lecture 3 More on editors: emacs and vi COP 3344 Introduction to UNIX

2 emacs In order to use emacs via the secure shell, you need to do the following: –Download and run the program X-Win32 –Edit profile so that TunnelX11 connections is enabled (Tunneling) The command "emacs" will start the "emacs" text editor in "scratch" mode, with an empty buffer "Scratch" mode is a pain to use, will not warn you about saving your work, and will cause various other grief Specifying a file name will have "emacs" open that file (or start a new file). emacs (avoid this) emacs

3 emacs - basic commands Arrow keys are used to navigate around document If configured, the mouse can work, but you will learn to work without it The caret symbol (^) indicates you must press and hold the control key first, then press the key for the command. Undo! ^x u or ^- will undo the most recent command (one of the only places in UNIX where you can undo something) Saving ^x ^s saves the buffered text to the currently specified file ^x ^c exits "emacs"

4 emacs - cutting and pasting ^k cuts text (kills) from cursor to end of line ^y pastes text (yanks back) (ctrl-shift-2) sets a "Mark" at the current cursor position Use the arrow keys to move to the end of the text you want to cut (will not highlight) ^w cuts text from "Mark" to current cursor position Move to position you want to insert the cut text ^y then brings the text back at the current cursor position

5 emacs - command summary (arrows) Move cursor (bksp) Move cursor left one space, deleting character (this may or may not work depending on your configuration) (del) Typically works like you would expect bksp to work ^a Move to beginning of line ^b Move back one character (same as left arrow) ^e Move to end of line ^f Move forward one character (same as right arrow) ^n Move to next line (same as down arrow) ^p Move to previous line (same as up arrow) ^v Move forward one page

6 emacs - command summary cont ^x ^s Save buffered text to currently specified file ^x ^w Write buffered text to a specific file ^x ^f Find a file and copy it into buffer ^x ^c Exit "emacs" (if you are in "scratch" mode it will NOT warn you to save your work) ^d Delete character at current position ^s Search forward ^r Search backward ^k Cut (Kill) text from cursor to end of line Set "Mark" ^w Cut text from "Mark" to current cursor position ^y Paste text at current cursor position ^x u Undo most recent command ^- Undo most recent command (alternate) ^g Cancel command ("Get out" of a string of ctrl commands)

7 vi vi is available on most Unix systems and is as powerful as emacs - personal preference on which one to use vi vi has two modes –Command mode: in this mode characters you type are interpreted as commands –Insert mode: characters you type are inserted as part of the text –vi starts out in insert mode –Typing i switches to insert mode –The ESC key puts you back in command mode vi is case sensitive so upper case and lower case commands act differently Commands are not displayed on the screen and do not require a return or enter

8 CommandDescription vi filestart at line 1 of file vi +n filestart at line n of file vi + filestart at last line of file vi +/pattern filestart at pattern in file vi -r filerecover file after a system crash Starting vi

9 vi - saving and quitting CommandDescription :e fileedit file (save current file with :w first) :wsave (write out) the file being edited :w filesave as file :w! filesave as an existing file :qquit vi :wqsave the file and quit vi :xsave the file if it has changed and quit vi :q!quit vi without saving changes

10 Keys pressedEffect hleft one character l or right one character kup one line j or down one line bleft one word wright one word (start of sentence )end of sentence {start of paragraph }end of paragraph Moving the cursor

11 Keys pressedEffect 1Gtop of file nGnGline n Gend of file Wfirst character of insertion Uup ½ screen Ddown ½ screen Bup one screen Fdown one screen Moving the cursor continued

12 Keys pressedText inserted aafter the cursor Aafter last character on the line ibefore the cursor Ibefore first character on the line oopen line below current line Oopen line above current line vi - inserting text

13 Keys pressedText changed or replaced cwword 3cwthree words cccurrent line 5ccfive lines rcurrent character only Rcurrent character and those to its right scurrent character Scurrent line ~switch between lowercase and uppercase vi - changing and replacing text

14 Keys pressedText deleted xcharacter under cursor 12x12 characters Xcharacter to left of cursor dwword 3dwthree words d0to beginning of line d$to end of line ddcurrent line 5ddfive lines d{to beginning of paragraph d}to end of paragraph :1,. dto beginning of file :.,$ dto end of file :1,$ dwhole file vi - deleting text

15 SearchFinds /andnext occurrence of ``and'', for example, ``and'', ``stand'', ``grand'' ?andprevious occurrence of ``and'' /^The next line that starts with ``The'', for example, ``The'', ``Then'', ``There'' /^The\>next line that starts with the word ``The'' /end$next line that ends with ``end'' /[bB]oxnext occurrence of ``box'' or ``Box'' nrepeat the most recent search, in the same direction Nrepeat the most recent search, in the opposite direction vi - searching for text

16 CommandDescription :s/pear/peach/g replace all occurrences of ``pear'' with ``peach'' on current line :/orange/s//lemon/g change all occurrences of ``orange'' into ``lemon'' on next line containing ``orange'' :.,$^<file/directory/g replace all words starting (note word anchor ^<) with ``file'' by ``directory'' on every line from current line onward, for example, ``filename'' becomes ``directoryname'' :g/one/s//1/g replace every occurrence of ``one'' with 1, for example, ``oneself'' becomes ``1self'', ``someone'' becomes ``some1'' vi - searching and replacing text

A few helpful vi links vi Manual (on our department’s web pages) – vi Reference Card – vi Cheat Sheet – 17