Getting Started with Vi
In vi you can set options to change the editor's behavior using the ex :set command. For example, the search commands are normally case-sensitive; to change this use the :set ignorecase or :set ic option. Most options have a two-letter abbreviated version.
There are two types of options, Boolean (true/false) options and those that take a value. To turn off a Boolean option, add “no” to the front; for example, :set noignorecase or :set noic turns off the ignorecase option.
For options that take a value, use the equal sign followed by the value to set. For example, the default spacing for the shift commands (>, <, ^T and ^D) is eight spaces (one tab character), but most programmers prefer two to four spaces. Use :set shiftwidth=4 (or :set sw=4) to make all indentation commands use a four-space indent.
Here are some other useful options:
wrapmargin=N turns on word wrapping; specify the number of characters before the end of the line at which to wrap, for example :set wm=8.
autoindent (Boolean) indents each line you type the same amount as the previous line, for example, :set ai.
magic (Boolean, default true, no abbreviation) controls regular expression behavior in the search commands, for example, :set nomagic.
To set several options at once, combine them into one set command like this: :set noic wm=8 sw=4 nomagic ai.
To save options for future editing sessions, put them in your .exrc file. When you run vi, it runs any ex (colon-mode) commands found in that file. Omit the : character, simply enter the set commands.
A graphical editor's scrollbar tells you where you are, and you can click on it to view other parts of the file. Because vi has no scrollbar, it uses equivalent keyboard commands.
Ctrl-G displays the file status, including the current line number. Go to a particular line of the file with the XG command. G by itself jumps to the end of the file, or use :X as an alternate for XG.
Ctrl-F scrolls the screen one page forward, and Ctrl-B goes back one page. To move in half-page increments, use Ctrl-D (down) or Ctrl-U (up).
Some other miscellaneous commands:
The x command deletes the current character (uppercase X deletes to the left). A numeric prefix deletes several characters. Text deleted using this command is cut as with the d commands.
~ changes the current letter from uppercase to lowercase or vice versa.
Undo a mistake with the u command. Vim has multiple levels of undo. Repeating the u command undoes each step in turn; the Ctrl-R keystroke puts them back (redo). Other versions of vi have only one level of undo; typing u again simply undoes the undo, restoring the change.
An uppercase U undoes all changes made so far on the current line; once you leave that line, however, it doesn't work anymore.
Type . (period) to repeat the last edit command.
To repeat the last :s/// command (but modifying only the current line), type &.
The vim editor comes with a handy tutorial to let you practice many of these commands. Type vimtutor from the shell prompt or :help tutor from within vim.
History of Vi
The vi editor (the name is short for “visual”) initially was written in 1976 by Bill Joy at the University of California, Berkeley. It has been included in the BSD (Berkeley Standard Distribution) versions of UNIX ever since those days, and other versions of UNIX, including Linux, have adopted it over the years.
The vi editor is a descendant of ex, which in turn was based on ed. These older editors were designed for use on a teletype and could display only one line of text at a time; vi was the first UNIX full-screen text editor.
The original vi's source code has not been available due to copyright (until just a few months ago), but many clones have been written. The one included with most Linux distributions is vim (vi improved). The current standard BSD editor is nvi (new vi). Others include elvis, vile and stevie. These vi editors include the basic vi functionality, plus their own bells and whistles.
Practical Task Scheduling Deployment
July 20, 2016 12:00 pm CDT
One of the best things about the UNIX environment (aside from being stable and efficient) is the vast array of software tools available to help you do your job. Traditionally, a UNIX tool does only one thing, but does that one thing very well. For example, grep is very easy to use and can search vast amounts of data quickly. The find tool can find a particular file or files based on all kinds of criteria. It's pretty easy to string these tools together to build even more powerful tools, such as a tool that finds all of the .log files in the /home directory and searches each one for a particular entry. This erector-set mentality allows UNIX system administrators to seem to always have the right tool for the job.
Cron traditionally has been considered another such a tool for job scheduling, but is it enough? This webinar considers that very question. The first part builds on a previous Geek Guide, Beyond Cron, and briefly describes how to know when it might be time to consider upgrading your job scheduling infrastructure. The second part presents an actual planning and implementation framework.
Join Linux Journal's Mike Diehl and Pat Cameron of Help Systems.
Free to Linux Journal readers.Register Now!
- SourceClear Open
- SUSE LLC's SUSE Manager
- Tech Tip: Really Simple HTTP Server with Python
- My +1 Sword of Productivity
- Murat Yener and Onur Dundar's Expert Android Studio (Wrox)
- Managing Linux Using Puppet
- Non-Linux FOSS: Caffeine!
- Doing for User Space What We Did for Kernel Space
- Google's SwiftShader Released
- SuperTuxKart 0.9.2 Released
With all the industry talk about the benefits of Linux on Power and all the performance advantages offered by its open architecture, you may be considering a move in that direction. If you are thinking about analytics, big data and cloud computing, you would be right to evaluate Power. The idea of using commodity x86 hardware and replacing it every three years is an outdated cost model. It doesn’t consider the total cost of ownership, and it doesn’t consider the advantage of real processing power, high-availability and multithreading like a demon.
This ebook takes a look at some of the practical applications of the Linux on Power platform and ways you might bring all the performance power of this open architecture to bear for your organization. There are no smoke and mirrors here—just hard, cold, empirical evidence provided by independent sources. I also consider some innovative ways Linux on Power will be used in the future.Get the Guide