CSCI The UNIX System Editing files

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.
Cosc 4750 Getting Started in UNIX Don’t be afraid of the prompt, in linux it can be your best friend. In some cases, the only way to do certain things.
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
CS 202 Computer Science II Lab Fall 2009 September 3.
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.
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:
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.
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.
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.
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.
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.
1 © 2012 John Urrutia. All rights reserved. Chapter 6 The vi Editor.
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.
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.
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.
ICE UNIX TUTORIAL. File System Commands cd – change directory cd – change directory ls – list contents ls – list contents rm – remove/delete rm – remove/delete.
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
Chapter 3: Mastering Editors Chapter 3 Mastering Editors (Emacs)
Vim basics Vi IMproved.
Guide To UNIX Using Linux Third Edition
Nassau Community College
Vi Editor.
Vim.
Vi Introduction Tony Kombol.
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
You do want to create and edit programs?
Emacs CSC 135.
C151 Multi-User Operating Systems
Linux Operations and Administration
The Emacs Editor Read: Forouzan, Appendix C
In the last class… The vi basics command, input and ex mode
Day 5 Emacs Editor David A. Gaitros Department of Computer Science
The Linux Command Line Chapter 12
Presentation transcript:

CSCI 330 - The UNIX System Editing files EDITORS iN LINUX Editing files NIU - Department of Computer Science

Editor features enter text search and replace copy, cut and paste undo and redo importing and exporting text save and cancel CSCI 330 - The UNIX System 3

Text files Unix file name does not require file extension Unix file system does not consider the extension when treating files However, some extensions are commonly used Program source code: .c .cc .cpp .f .f77 .f95 Compiled object code: .o .a .so .sa Compressed files: .z .gz .zip Archive files: .tar .tz Web site source code: .html .shtml .php Executable files typically have no extension Text files that will be moved to Windows: .txt CSCI 330 - The UNIX System

Unix Text editors vim emacs pico nano GUI editors mousepad xedit CSCI 330 - The UNIX System

The vi Editor short for: visual editor available on all UNIX systems original vi part of BSD Unix written by Bill Joy in 1976 many derived, improved versions available open source vim (vi improved) is part of GNU/Linux vi has multiple modes of operation: input mode, command mode, last-line mode CSCI 330 - The UNIX System

vi Editing modes : Command Mode Esc Input Mode Insert (i, I) CSCI 330 - The UNIX System vi Editing modes Command Mode Esc Input Mode CSCI 330 - The UNIX System Insert (i, I) Append (a, A), Open (o, O) Change (c), Replace (r, R) : Return Last-Line Mode NIU - Department of Computer Science

VIM TUTORIAL Online tutorial: vimtutor UNIX Text Editors VIM TUTORIAL Online tutorial: vimtutor Never start something you can’t exit To end vi tutorial in the middle of the session, execute the command :q! :q! = quit without saving :wq = write out (save) and quit F1 = help or :help :help <command> :q to exit help window CSCI 330 - The UNIX System 8 Copyright Department of Computer Science, Northern Illinois University, 2004 8

COMMANDS Delete characters Insert characters UNIX Text Editors COMMANDS Delete characters x deletes character under the cursor Insert characters i converts to insert mode then type characters <esc> to exit insert mode CSCI 330 - The UNIX System 9 Copyright Department of Computer Science, Northern Illinois University, 2004 9

COMMANDS Insert lines Append characters o = open line below cursor UNIX Text Editors COMMANDS Insert lines o = open line below cursor O = open line above cursor <esc> to exit insert mode Append characters A converts to insert mode at end of a line then type characters CSCI 330 - The UNIX System 10 Copyright Department of Computer Science, Northern Illinois University, 2004 10

COMMANDS Deletion Using motions for movement d$ deletes to end of line UNIX Text Editors COMMANDS Deletion d$ deletes to end of line dw deletes to beginning of next word de deletes to end of current word d + motion Using motions for movement Use any of the motions above Use count for repetition 2w = move cursor two words forward 0 = start of line CSCI 330 - The UNIX System 11 Copyright Department of Computer Science, Northern Illinois University, 2004 11

COMMANDS Using repetition as part of deletion Deleting a line Undo UNIX Text Editors COMMANDS Using repetition as part of deletion 2dw deletes next two words Deleting a line dd = delete line 2dd = delete two lines Undo u = undo one command U = restore a line cntl-R = redo a command CSCI 330 - The UNIX System 12 Copyright Department of Computer Science, Northern Illinois University, 2004 12

COMMANDS p = put back the deleted text (in new place) UNIX Text Editors COMMANDS p = put back the deleted text (in new place) one of the delete command above + put = cut-and-paste More general cut-and-paste v = start visual mode (start block) move cursor to end of block y = yank (copy to buffer) then p = put in new place CSCI 330 - The UNIX System 13 Copyright Department of Computer Science, Northern Illinois University, 2004 13

COMMANDS Location ctrl-g = show position in file UNIX Text Editors COMMANDS Location ctrl-g = show position in file G = go to bottom of file gg = go to top of file <number>G = go to line <number> CSCI 330 - The UNIX System 14 Copyright Department of Computer Science, Northern Illinois University, 2004 14

COMMANDS Search Search for matching parentheses UNIX Text Editors COMMANDS Search /<phrase> = search /<phrase>\c = ignore case ?<phrase> = search backwards n = repeat search N = repeat search in the other direction cntl-o = move backward one instance cntl-i = move forward one instance Search for matching parentheses Put cursor on (, [ or { % = go to matching one % = go to first one again CSCI 330 - The UNIX System 15 Copyright Department of Computer Science, Northern Illinois University, 2004 15

COMMANDS Substitute (replace) :s/thee/the = changes first one UNIX Text Editors COMMANDS Substitute (replace) :s/thee/the = changes first one :s/thee/the/g = changes all (global change) :s/thee/the/gc = change all with query :#,#/thee/the/g = only change within that line range CSCI 330 - The UNIX System 16 Copyright Department of Computer Science, Northern Illinois University, 2004 16

COMMANDS Files :w filename = write a file (save) :!ls = list directory UNIX Text Editors COMMANDS Files :w filename = write a file (save) :!ls = list directory :!xx = any command CSCI 330 - The UNIX System 17 Copyright Department of Computer Science, Northern Illinois University, 2004 17

SETTING OPTIONS Options for search :noic, etc. = turn it off UNIX Text Editors SETTING OPTIONS Options for search :set ic = ignore case :set hlsearch = highlight matches :set icsearch = incremental search :noic, etc. = turn it off Make permanent by putting in ./.vimrc CSCI 330 - The UNIX System 18 Copyright Department of Computer Science, Northern Illinois University, 2004 18

The emacs editor originally started as editor macros in 1976 Gosling Emacs available for Unix in 1981 GNU Emacs created by Richard Stallman in 1984 very popular editor on Unix until recently history: editor war: emacs vs. vi uses lisp-like macro language for powerful features and extensions: programming language sensitive editing email client news reader has built-in tutorial: ^h-t CSCI 330 - The UNIX System

THE PICO AND NANO EDITORS part of the popular pine mail utility on UNIX developed by the University of Washington pico = pine email composer nano is improved open source of pico available for GNU/Linux very intuitive operation on-screen guide and help CSCI 330 - The UNIX System

GUI Editors use onscreen direct manipulation via mouse and menus emacs xedit mousepad require to run X11 window server CSCI 330 - The UNIX System