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.
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Designing Electronics with Linux | May 22, 2013 |
| Dynamic DNS—an Object Lesson in Problem Solving | May 21, 2013 |
| Using Salt Stack and Vagrant for Drupal Development | May 20, 2013 |
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
- I once had a better way I
14 min 39 sec ago - Not only you I too assumed
32 min 2 sec ago - another very interesting
2 hours 25 min ago - Reply to comment | Linux Journal
4 hours 18 min ago - Reply to comment | Linux Journal
11 hours 12 min ago - Reply to comment | Linux Journal
11 hours 28 min ago - Favorite (and easily brute-forced) pw's
13 hours 19 min ago - Have you tried Boxen? It's a
19 hours 11 min ago - seo services in india
23 hours 43 min ago - For KDE install kio-mtp
23 hours 44 min ago
Enter to Win an Adafruit Pi Cobbler Breakout Kit for Raspberry Pi

It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Pi Cobbler Breakout Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- 5-21-13, Prototyping Pi Plate Kit: Philip Kirby
- Next winner announced on 5-27-13!
Featured Jobs
| Linux Systems Administrator | Houston and Austin, Texas | Host Gator |
| Senior Perl Developer | Austin, Texas | Host Gator |
| Technical Support Rep | Houston and Austin, Texas | Host Gator |
| UX Designer | Austin, Texas | Host Gator |
| Web & UI Developer (JavaScript & j Query) | Austin, Texas | Host Gator |
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?




Comments
I hate vi
Why on earth would anyone ever use this now? Basic text editors much more intuitive than vi have been available for over a decade. Why hasn't this abortion of a text editor been put to rest? There is no reason to even learn it except for some reason, a lot of Linux certification tests have vi questions in them.
Why in God's name does this text editor have it's own command line? It's a TEXT EDITOR. jed and kate are more powerful for crying out loud. Why should I feel like I should to learn this cumbersome piece of crap?
"Even if you use a different editor for most of your work, it helps to know the basics of the ubiquitous vi." <==WHY?