Presentation is loading. Please wait.

Presentation is loading. Please wait.

Guide To UNIX Using Linux Third Edition

Similar presentations


Presentation on theme: "Guide To UNIX Using Linux Third Edition"— Presentation transcript:

1 Guide To UNIX Using Linux Third Edition
Chapter 3: Mastering Editors Guide To UNIX Using Linux Third Edition

2 Objectives Explain the basics of UNIX/Linux files, including ASCII, binary, and executable files Understand the types of editors Create and edit files using the vi editor Create and edit files using the Emacs editor Guide to UNIX Using Linux, Third Edition

3 Understanding UNIX/Linux Files
Almost everything you create in UNIX is stored in a file All information stored in files is in the form of binary digits Binary digits are also known as bits Bits have two states: 1 (on) and 0 (off) 0’s and 1’s as a way to communicate with a computer is known as machine language Guide to UNIX Using Linux, Third Edition

4 Understanding UNIX/Linux Files (continued)
Machine language (or bit combinations) is translated into plain English using ASCII ASCII stands for American Standard Code for Information Interchange ASCII uses a byte (a string of 8 bits) to represent keyboard characters such as letters and numbers Text files contain printable, ASCII characters Binary files contain nonprintable characters, or machine language Guide to UNIX Using Linux, Third Edition

5 Guide to UNIX Using Linux, Third Edition

6 Executable Program Files
Programmers develop source code as text files that are compiled before being executed Programmers also create scripts, which are files containing commands; scripts are interpreted Executable program files are compiled and interpreted files that can be run Guide to UNIX Using Linux, Third Edition

7 Using Editors Editors let you create and edit ASCII files
UNIX/Linux normally include two editors: vi and Emacs vi and Emacs are screen editors: they display the text you are editing one screen at a time Guide to UNIX Using Linux, Third Edition

8 Using the vi Editor Called vi because it is visual; it immediately displays on screen the changes that you make to text Works in three modes Insert: lets you enter text Command: lets you enter editing commands Extended (ex) command set: lets you use an extended set of editing commands Guide to UNIX Using Linux, Third Edition

9 Using the vi Editor (continued)
To create a new file in the vi editor, type vi and the name of the new file at the command prompt Guide to UNIX Using Linux, Third Edition

10 Using the vi Editor (continued)
When started, the vi editor is in command mode To insert text into a file, you must switch to insert mode You can repeat the line just entered with the repeat command (.) To edit what you’ve just typed, move the cursor with the various keyboard cursor movement keys Guide to UNIX Using Linux, Third Edition

11 Using the vi Editor (continued)
In order to insert text, you issue the “i” command to enter insert mode (Figure on page 131) Guide to UNIX Using Linux, Third Edition

12 Using the vi Editor (continued)
Guide to UNIX Using Linux, Third Edition

13 Using the vi Editor (continued)
While still in command mode: To delete text, move to a character and then type “x” You can undo a command (reverse its effects) by typing “u” To search for a text pattern, type a forward slash (/), type the pattern, and press Enter Guide to UNIX Using Linux, Third Edition

14 Using the vi Editor (continued)
Guide to UNIX Using Linux, Third Edition

15 Using the vi Editor (continued)
The status line at the bottom of the screen displays information, including line-oriented commands and error messages (Figure on page 136) Guide to UNIX Using Linux, Third Edition

16 Using the vi Editor (continued)
Searching and replacing is a line-oriented command that executes independently of the cursor position (Figure on page 137) Guide to UNIX Using Linux, Third Edition

17 Using the vi Editor (continued)
Saving a file and exiting vi You should always save the file before exiting vi, otherwise changes are lost To save a file and continue working on it, type the :w (write) command While in command mode, use the :wq (write and quit) command to save and exit iv, or the :zz command to exit after saving You can also use :x to save and exit Guide to UNIX Using Linux, Third Edition

18 Using the vi Editor (continued)
Guide to UNIX Using Linux, Third Edition

19 Using the vi Editor (continued)
In vi, you can also: Add text from another file Leave vi temporarily to perform other UNIX/Linux tasks, then return to your file Change your display while editing, such as adding line numbering Copy, cut, and paste text to help editing Print text files Cancel an editing session Get help Guide to UNIX Using Linux, Third Edition

20 Using the vi Editor (continued)
Guide to UNIX Using Linux, Third Edition

21 Using the vi Editor (continued)
Turn on line numbering when you want to work with a range of lines and refer to the line numbers to specify text (Figure on page 141) Guide to UNIX Using Linux, Third Edition

22 Using the Emacs Editor More complex than vi, but it is more consistent
Not modal Supports a sophisticated, extensible macro language Reputed to have more features than any other UNIX/Linux program Guide to UNIX Using Linux, Third Edition

23 Using the Emacs Editor (continued)
Guide to UNIX Using Linux, Third Edition

24 Using the Emacs Editor (continued)
Guide to UNIX Using Linux, Third Edition

25 Using the Emacs Editor (continued)
Creating a new file in Emacs Type the Emacs command with the name of the new file after it at the command line If you are using the GNOME interface, start Emacs by clicking the Main Menu icon, clicking Programs, clicking Applications, and then clicking Emacs Guide to UNIX Using Linux, Third Edition

26 Using the Emacs Editor (continued)
Guide to UNIX Using Linux, Third Edition

27 Using the Emacs Editor (continued)
The menu bar at the top of the Emacs screen has categories for commands File: Options for file operations Edit: Text-editing functions Options: Special options Buffers: Access to storage buffers Tools: Options for extra tool functionality Help: Access to manuals and other help tools Guide to UNIX Using Linux, Third Edition

28 Using the Emacs Editor (continued)
Editing an Emacs file To navigate the cursor location, use the arrow keys, or Ctrl key combinations Text is inserted by typing Ctrl+x and then “u” is the undo command You can cut, copy and paste text There is a text search feature as well Lets you format documents with word wrap Guide to UNIX Using Linux, Third Edition

29 Reformatting a File Use the Alt+q command to turn on the word wrap feature in Emacs (Figure on page 147) Guide to UNIX Using Linux, Third Edition

30 Chapter Summary Bytes are computer characters stored using numeric code (e.g., ASCII) The vi editor is a popular choice among UNIX/Linux users to edit text files Emacs editor Popular alternative to vi Has a powerful extensible command syntax Navigate an Emacs file with cursor movement keys or Ctrl key combinations Guide to UNIX Using Linux, Third Edition


Download ppt "Guide To UNIX Using Linux Third Edition"

Similar presentations


Ads by Google