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.
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.
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.
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.
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.
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.
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:
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.
October 24,  Creating and Opening Files  Save and Exit  Navigation  Shortcuts  Copying, Cutting and Pasting  Searching and Replacing  More.
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.
IT244 - Introduction to Linux / Unix Instructor: Bo Sheng
Linux System Administration Editors
Technical University of Kosice
GETTING TO KNOW YOUR KEYBOARD
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:

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

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 <filename>

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"

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

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

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)

vi vi is available on most Unix systems and is as powerful as emacs - personal preference on which one to use vi <filename> 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

Starting vi Command Description vi file start at line 1 of file vi +n file start at line n of file vi + file start at last line of file vi +/pattern file start at pattern in file vi -r file recover file after a system crash

vi - saving and quitting Command Description :e file edit file (save current file with :w first) :w save (write out) the file being edited :w file save as file :w! file save as an existing file :q quit vi :wq save the file and quit vi :x save the file if it has changed and quit vi :q! quit vi without saving changes

Moving the cursor Keys pressed Effect h left one character l or <Space> right one character k up one line j or <Enter> down one line b left one word w right one word ( start of sentence ) end of sentence { start of paragraph } end of paragraph

Moving the cursor continued Keys pressed Effect 1G top of file nG line n G end of file <Ctrl>W first character of insertion <Ctrl>U up ½ screen <Ctrl>D down ½ screen <Ctrl>B up one screen <Ctrl>F down one screen

vi - inserting text Keys pressed Text inserted a after the cursor A after last character on the line i before the cursor I before first character on the line o open line below current line O open line above current line

vi - changing and replacing text Keys pressed Text changed or replaced cw word 3cw three words cc current line 5cc five lines r current character only R current character and those to its right s current character S ~ switch between lowercase and uppercase

vi - deleting text Keys pressed Text deleted x character under cursor 12 characters X character to left of cursor dw word 3dw three words d0 to beginning of line d$ to end of line dd current line 5dd five lines d{ to beginning of paragraph d} to end of paragraph :1,. d to beginning of file :.,$ d to end of file :1,$ d whole file

vi - searching for text Search Finds /and next occurrence of ``and'', for example, ``and'', ``stand'', ``grand'' ?and previous 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]ox next occurrence of ``box'' or ``Box'' n repeat the most recent search, in the same direction N repeat the most recent search, in the opposite direction

vi - searching and replacing text Command Description :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''

A few helpful vi links vi Manual (on our department’s web pages) http://www.cs.fsu.edu/general/vimanual.html vi Reference Card http://limestone.truman.edu/~dbindner/mirror/vi-ref.pdf vi Cheat Sheet http://www.lagmonster.org/docs/vi.html