370 likes | 400 Vues
Linux Operations and Administration. Professor Sabol. Objectives. Describe key features of GUI and command-line text editors available in Linux Use the vim editor to create and edit text files. Text Editors in Linux. Text editor Program used to create and edit plain text files
E N D
Linux Operations and Administration Professor Sabol
Objectives • Describe key features of GUI and command-line text editors available in Linux • Use the vim editor to create and edit text files
Text Editors in Linux • Text editor • Program used to create and edit plain text files • Not same as word processor • Main purpose: to create a file to be used by another program, for example: • Hypertext Markup Language (HTML) for a Web browser • Source code that a compiler can process • Shell script • Text file containing a sequence of commands
Text Editors in Linux (cont’d.) • Two types of text editors: • Command-line editors • GUI editors
GUI Text Editors in Linux • Linux GUI text editors • Similar to Notepad in Windows • Advantage: • Select and edit text quickly with the mouse • Widely used GUI text editors: • KWrite • Gedit
KWrite: A GUI Text Editor for KDE • Also called programmer’s editor for the K Desktop Environment • To start: • Type kwrite at a command prompt • Opens a new empty file in Kwrite • Use Kickoff Application Launcher button • Advanced features: • Syntax highlighting to display text in different colors and fonts for programming languages • Bookmarks are markers placed on certain lines to help navigate through a text file
KWrite: A GUI Text Editor for KDE (cont’d.) Figure 4-1 KDE’s KWrite text editor
KWrite: A GUI Text Editor for KDE (cont’d.) • Activity 4-1: Exploring the KWrite Text Editor • Explore features of the KWrite text editor
Gedit: A GUI Text Editor for GNOME • GUI text editor included with GNOME • To start • Open a terminal window, type gedit, and press Enter • Syntax highlighting options • Plain text • Sources • Scripts • Others • Markup • Scientific
Gedit: A GUI Text Editor for GNOME (cont’d.) Figure 4-2 GNOME’s gedit text editor
Gedit: A GUI Text Editor for GNOME (cont’d.) • Activity 4-2: Exploring the Gedit Text Editor • Learn features of the Gedit text editor
Getting Started with the Vim Editor • vi command-line text editor • Included with most versions of UNIX and Linux • Learning curve • Knowing how to use it is crucial • vi has evolved into many different forms • vim • Stands for “vi improved” • vi command is now linked to the vim command
Getting Started with the Vim Editor (cont’d.) • Modular editor • Runs in different operational modes • Command mode • Use key combinations as commands instead of typing text • Insert mode • Typed text is displayed onscreen • Extend mode • Used for more advanced commands, such as saving files, exiting vim, or searching and replacing text
Starting Vim • Type vim and press Enter • Type vim filename and press Enter • If the file doesn’t exist, vim creates an empty file with this filename • Figure 4-3 • Window displayed after you start vim • Tilde (~) • Represents blank or empty lines in the file
Starting Vim (cont’d.) The vim text editor
Command Mode • Command mode • Chosen automatically when starting vim • Table 4-1 • Advanced navigational commands in vim
Table 4-1 Advanced vim navigational commands Linux Operations and Administration
Table 4-1 Advanced vim navigational commands (continued ) Linux Operations and Administration 18
Command Mode (cont’d.) • Activity 4-3: Using Vim in Command Mode • Use navigational commands in vim
Insert Mode • Must be in insert mode to type text • Change to insert mode with one of the commands in Table 4-2 • vim editor displays -- INSERT -- at the lower left • To indicate insert mode • Press the Esc key to change back to command mode
Insert Mode (cont’d.) Table 4-2 Commands for entering insert mode
Insert Mode (cont’d.) Figure 4-4 The vim editor in insert mode
Modifying Text • Modify text using the keyboard instead of the mouse • Table 4-3 • Commands for modifying text in vim • Must be in command mode • Activity 4-4: Using Vim in Insert Mode • Change to insert mode and modify text in vim
Modifying Text (cont’d.) Table 4-3 Commands for modifying text
Deleting Text • Table 4-4 • Lists commands for deleting text in vim
Deleting Text (cont’d.) Table 4-4 Commands for deleting text
Cut, Yank, and Paste • Cut text • Store text in a buffer • Paste text • Move from buffer to cursor location • Yank (copy) text • Keep in current location and copy to buffer • Table 4-5 • Commands used to yank and paste text in vim
Cut, Yank, and Paste (cont’d.) Table 4-5 Commands for yanking and pasting text
Undo Commands • Undo changes • Type u • Keep typing u until you have reached your oldest change • Activity 4-5: Modifying Text in Vim • Delete, cut, copy, and paste text in vim
Extended Mode • Offers advanced features • Save and quit • Search and replace • Customization options • Enter extended mode • Type the : symbol • Table 4-6 • Describes commands for saving files and exiting vim
Extended Mode (cont’d.) Table 4-6 Extended mode commands for saving and exiting
Extended Mode (cont’d.) Table 4-7 Extended mode commands to search for and replace text
Useful Commands • Table 4-8 • Commands for extended mode • Activity 4-6: Using Vim in Extended Mode • Use vim commands in extended mode
Useful Commands (cont’d.) Table 4-8 Additional extended mode commands
Summary • Linux GUI text editors • Easy to use • Comparable with Windows Notepad • vim text editor • Available with every major distribution of UNIX and Linux • Operates in several different modes • Insert mode • Command mode • Extended mode
Summary (cont’d.) • Command-line text editor • Use a variety of keys and key combinations in vim to perform operations