Introduction to Unix – CS 21 Lecture 8. Lecture Overview More detail on emacs and vi Regular expression matching in emacs and vi.

Slides:



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

Step-by-Step: Set an Access Password for a Document OPEN the peerreview document from the lesson folder. 1.Click the File tab and then click the Save As.
A Guide to Unix Using Linux Fourth Edition
PacNOG 6: Nadi, Fiji Using Commands in Linux Hervey Allen Network Startup Resource Center.
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.,
VIM: The basics Tang Wai-Chung, Matthew (MaFai) 29/12/2006.
CS 497C – Introduction to UNIX Lecture 17: - The GNU emacs Editor Chin-Chih Chang
Vi Editor TA for ITIS3100: Xu Fei
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.
Guide To UNIX Using Linux Third Edition
Lecture 02CS311 – Operating Systems 1 1 CS311 – Lecture 02 Outline UNIX/Linux features – Redirection – pipes – Terminating a command – Running program.
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.
Advanced Shell Programming. 2 Objectives Use techniques to ensure a script is employing the correct shell Set the default shell Configure Bash login and.
1 Unix Text Editors Creating files on the Unix system.
謝耀偉編著 國立高雄大學應用數學系 Living in Emacs DeveloperWorks, IBM.
Objectives Understand what MATLAB is and why it is widely used in engineering and science Start the MATLAB program and solve simple problems in the command.
An Introduction to Unix Shell Scripting
Introduction to Unix – CS 21 Lecture 9. Lecture Overview Shell description Shell choices History Aliases Topic review.
Chapter Three The UNIX Editors. 2 Lesson A The vi Editor.
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.
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.
Editing, vi and Configuration Files Introduction to Linux June 16, 2009 Papeete, French Polynesia Hervey Allen.
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.
Introduction to Unix – CS 21 Lecture 12. Lecture Overview A few more bash programming tricks The here document Trapping signals in bash cut and tr sed.
Introduction to Unix – CS 21
4 Editing files and Emacs Editing files The Emacs editor.
Chapter 5 Editing Text Files. Basic Concept A text editor works on a file buffer that is a memory copy of a disk file The disk file is not updated until.
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.
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.
Microsoft ® Word 2010 Training Create your first Word document I.
1 © 2012 John Urrutia. All rights reserved. Chapter 6 The vi Editor.
Getting Started with Linux Linux System Administration Editors.
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.
PacNOG 6: Nadi, Fiji Editing, vi & Configuration Files Hervey Allen Network Startup Resource Center.
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.
Editing, vi and Configuration Files Unix/IP Preparation Course July 19, 2009 Eugene, Oregon, USA
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.
Linux Working with files Saleh Khazaei
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.
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)
Linux Operations and Administration
The Emacs Editor Read: Forouzan, Appendix C
CSCI The UNIX System Editing files
Presentation transcript:

Introduction to Unix – CS 21 Lecture 8

Lecture Overview More detail on emacs and vi Regular expression matching in emacs and vi

Accessing All Emacs Commands Meta-x Tab completion Exploring all of the different commands Approximately 1800 of them

Quick Jump To A Line In vi G By itself, it jumps to the end of the file 3G Jumps to line 3 Any number works

Quick Jump To A Line In emacs Meta-x goto-line Then type in the line to go to Which is faster? Which is better? Which is more conformant to Unix style?

Search And Replace In Vi :s/old/new Replaces old with new on the current line :s/old/new/g Replaces all old with new on the current line :1,$ s/old/new/g Replaces all old with new in the whole file

Query-Replace In Emacs Meta-% Meta-x query-replace Prompts you for old pattern and new pattern Questions you on every instance if you would like to replace it

Change In vi C will delete the line you’re at and put you into insert mode “Changing” the current line c works much like d cc = change line cw = change word c10 = change next ten lines

Replace In vi From command mode: r will replace a single character R will put you into “Replace” mode Everything you type overwrites what was previously there

Overwrite Mode In Emacs Hitting the Insert key changes modes in emacs Takes you into and out of overwrite You suddenly will find yourself overwriting instead of inserting Check for (Ovwrt)

Emacs Buffer Primer When emacs is run without any parameters, it opens up a buffer called *scratch* All files opened and all messages that pop up are stored in different buffers and are always accessible Window vs. buffer Just because you can’t see it, doesn’t mean it is gone

Switching Buffers And Multiple Windows Cntrl-x, cntrl-b List all buffers Cntrl-x b Switch to buffer Cntrl-x 4 b Switch to buffer in another window

Adding Or Getting Rid Of Windows Cntrl-x 2 Add another window (vertically) Cntrl-x 3 Add another window (horizontally) Cntrl-x 1 Only show one window

Read Only Files In Emacs % will appear on the bottom of the screen indicating that the file is read- only You won’t be able to change the file in any way, you’ll just be able to read it

Read Only Files In vi vi will warn you when you attempt to modify a read-only file It will let you change the file, though If you attempt to save the changes, it will warn you again Using the !, you can force the changes vi will let you modify a read-only file!

The Mark And The Point In order to highlight large sections of text, emacs introduces the idea of the mark and the point Mark Set with Cntrl- The position of the cursor when set Point Wherever the cursor is located

Using The Mark And Point Cntrl-w Kills (cuts) the region from the mark to the point Forwards or backwards doesn’t matter Some actions automatically set the mark Cntrl-y Pasting (yanking) sets the mark

Parenthesis Matching In Emacs Emacs will warn you when parenthesis are mismatched () [] {} Emacs will always tell you what a parenthesis matches On screen Temporarily highlight Off screen State what matches

Accessing Unix Commands in vi vi has access to the shell and can run commands :!COMMAND Will allow you to run one command !!COMMAND Replace the current line with output of the command

Inserting Files And Commands In vi :r FILE Insert the contents of FILE directly where the cursor is !} COMMAND Pipe the contents of the current paragraph into COMMAND and replace the current paragraph with the output

Accessing Unix Commands In Emacs Oh yeah? Watch this! Meta-x shell Actually opens up a shell (command line) INSIDE of emacs that allows you to run any program and still move around, cut and paste, and do anything you want The shell is located in another buffer *shell*

Regular Expression Matching In vi Just like searching for a normal pattern Syntax is mostly the same as grep Some symbols must be escaped \? \+ \( \) Character sets are escape characters

Character Sets \d = digit \D = non-digit \a = alphabetic character \A = non-alphabetic character \l = lowercase character \L = non-lowercase character \u = uppercase character \U = non-uppercase character

Special Syntax Magic. * $ treated as special characters This is the default mode No Magic *. $ treated as normal characters Must be escaped

Regular Expression Matching In Emacs Cntrl-Meta-S Regular expression search forwards Cntrl-Meta-R Regular expression search backwards Syntax is mostly the same as grep Some characters must be escaped \( \)

Colors In Vi Special types of files are recognized Programming languages Objects are colored depending on their status Keywords, comments, variables are all colored differently

Colors In Emacs Emacs as well has colors, but not necessarily on by default Meta-x font-lock-mode

Programming Modes In Emacs More than just colors C and C++ files HTML files VHDL files Perl, prolog, ml, lisp, shell programming … Pretty much any language you can think of has had a mode in emacs written for it Some are more extensive than others

Startup Files.emacs Contains all the commands that get executed every time you start emacs Sets default values.XXXrc General form of startup files

Fun With Emacs Doctor Adventure Solitaire Pong Tetris!

In Lab Today You will play around with both Emacs and vi You will try out both basic file editing as well as some of the more advanced features

Next Week We look more at shells and specifically we look at special features of bash Midterm next Thursday Covers all material up from the first day of class until next Tuesday