This course is in a series of mini-courses to help you with Bash Shell Scripting. It is divided into several sections as you can see below. In addition, to help you in the challenge of learning bash shell scripting you will find a quiz at the end of each mini-course. Bash Shell: Basics Bash Shell: vi Text Editor Bash Shell: Nano Text Editor Bash Shell: Scripting Basics Bash Shell: Regular Expressions Bash Shell: Text Filters
The second course will help you understand the basics of working with the vi text editor in Linux. At some time everyone who uses Linux will need a text editor. One of the most important reasons for learning vi is that it is loaded on every Linux distro by default whereas others like nano or emacs are not. So whatever, text editor you choose be sure you load it and use it before you need it.
Course Difficulty The course level is for the inexperienced Linux User / Administrator. The focus is to provide a foundation for using basic text editors.
Lesson 2
Course Outline vi Introduction vi Movement vi Buffers vi search vi Text Editing vi Global Replacement vi Split Screen vi Save and Exit vi Key Options Quiz
Get a Free vi Quick Card
The administrator will be required to use a text line editor to manage the many configuration files that need to be edited. You have a wide range of text editors you can choose from. There are several good GUI-based text editors, and several text-mode type editors that you would invoke from the command-line.
Text-mode editors are light-weight, fast, and don't require a lot of overhead to run. Also, if you ever have trouble booting your system to the GUI, you may find yourself having to hand-edit configuration files from the command-line in order to fix the problem. Of course, you wouldn't be able to use a GUI-type text editor for that. You can also use a text-mode editor to perform remote system administration. That's a handy feature if you ever have to remotely configure a Linux server.
At first glance, you may be somewhat mystified as to why anyone would want to use vi. It is, after all, possible to create text-mode programs with pull-down menus, but the developers of vi decided not to include them. So, you're probably thinking that vi is terribly difficult to learn. "Why not learn something else?", you're asking. Here's where that first look can be somewhat misleading.
Editing commands are executed with either a single keystroke or combination of keystrokes. You can perform your editing functions without having to lift your hands from the keyboard to reach for the mouse. That can be a handy feature if you have to make lots of changes to a large file. There's also a more pragmatic reason. If you intend to take any certification exams for Linux, there's a good chance that you'll be tested on vi.
To open vi, you can just type "vi" at the command-line. It's handier to specify a filename when you open vi, but this will show you the opening screen that you otherwise wouldn't see.
As you can see, the official name of the program is now "VIM", which stands for "vi IMproved". Linux users are so used to entering the "vi" command, that most Linux distros allow you to still use it.
To get rid of the opening screen so that you can start editing, press the "i" key. When you want to save the file, press the "Escape" key, and enter either the ":w" or ":wq" command along with the filename that you've chosen.
You can also specify which file you wish to open when you open vi. If the file you specify hasn't yet been created, you will be taken to a blank vi screen. When you enter the command to save the file, it will then be automatically saved under the name that you specified.
vi mytext.txt
Note: In order to open certain system configuration files with vi, you'll have to either be logged on as "root", or preface the command with "sudo".
Copyright CyberMontana Inc. and BeginLinux.com
All rights reserved. Cannot be reproduced without written permission. Box 1262 Trout Creek, MT 59874
|