Vi Cheat Sheet

July 2nd, 2009

The VI editor is a screen-based editor used by many Unix users. The VI editor has powerful features to aid programmers, but many beginning users avoid using VI because the different features overwhelm them.

This sheet cheat is aimed to provide beginners with a summary of simple to use everyday commands that should help them master this text editor as soon as possible.

Modes


Vi has two modes insertion mode and command mode. The editor begins in command mode, where the cursor movement and text deletion and pasting occur. Insertion mode begins upon entering an insertion or change command. [ESC] returns the editor to command mode (where you can quit, for example by typing :q!). Most commands execute as soon as you type them except for “colon” commands which execute when you press the ruturn key.

Quitting


: x Exit, saving changes
:q Exit as long as there have been no changes
ZZ Exit and save changes if any have been made
:q! Exit and ignore any changes

Inserting Text


i Insert before cursor
I Insert before line
a Append after cursor
A Append after line
o Open a new line after current line
O Open a new line before current line
r Replace one character
R Replace many characters

Motion


h Move left
j Move down
k Move up
l Move right
w Move to next word
W Move to next blank delimited word
b Move to the beginning of the word
B Move to the beginning of blank delimted word
e Move to the end of the word
E Move to the end of Blank delimited word
( Move a sentance back
) Move a sentance forward
{ Move a paragraph back
} Move a paragraph forward
0 Move to the begining of the line
$ Move to the end of the line
1G Move to the first line of the file
G Move to the last line of the file
nG Move to nth line of the file
:n Move to nth line of the file
fc Move forward to c
Fc Move back to c
H Move to top of screen
M Move to middle of screen
L Move to botton of screen
% Move to associated ( ), { }, [ ]

Deleting Text


Almost all deletion commands are performed by typing d followed by a motion. For example, dw deletes a word. A few other deletes are:
x Delete character to the right of cursor
X Delete character to the left of cursor
D Delete to the end of the line
dd Delete current line
:d Delete current line

Yanking Text


Like deletion, almost all yank commands are performed by typing y followed by a motion. For example, y$ yanks to the end of the line. Two other yank commands are:
yy Yank the current line
:y Yank the current line

Changing text


The change command is a deletion command that leaves the editor in insert mode. It is performed by typing c followed by a motion. For wxample cw changes a word. A few other change commands are:
C Change to the end of the line
cc Change the whole line

Putting text


p Put after the position or after the line
P Put before the poition or before the line

Buffers


Named buffers may be specified before any deletion, change, yank or put command. The general prefix has the form “c where c is any lowercase character. for example, “adw deletes a word into buffer a. It may thereafter be put back into text with an appropriate “ap.

Markers


Named markers may be set on any line in a file. Any lower case letter may be a marker name. Markers may also be used as limits for ranges.
mc Set marker c on this line
`c Go to beginning of marker c line.
c Go to first non-blank character of marker c line.

Search for strings


/string Search forward for string
?string Search back for string
n Search for next instance of string
N Search for previous instance of string

Replace


The search and replace function is accomplished with the :s command. It is commonly used in combination with ranges or the :g command (below).
:s/pattern/string/flags Replace pattern with string according to flags.
g Flag – Replace all occurences of pattern
c Flag – Confirm replaces.
& Repeat last :s command

Regular Expressions


. (dot) Any single character except newline
* zero or more occurances of any character
[…] Any single character specified in the set
[^…] Any single character not specified in the set
^ Anchor – beginning of the line
$ Anchor – end of line
\< Anchor – begining of word
\> Anchor – end of word
\(…\) Grouping – usually used to group conditions
\n Contents of nth grouping
[…] – Set Examples
[A-Z] The SET from Capital A to Capital Z
[a-z] The SET from lowercase a to lowercase z
[0-9] The SET from 0 to 9 (All numerals)
[./=+] The SET containing . (dot), / (slash), =, and +
[-A-F] The SET from Capital A to Capital F and the dash (dashes must be specified first)
[0-9 A-Z] The SET containing all capital letters and digits and a space
[A-Z][a-zA-Z] In the first position, the SET from Capital A to Capital Z
In the second character position, the SET containing all letters
Regular Expression Examples
/Hello/ Matches if the line contains the value Hello
/^TEST$/ Matches if the line contains TEST by itself
/^[a-zA-Z]/ Matches if the line starts with any letter
/^[a-z].*/ Matches if the first character of the line is a-z and there is at least one more of any character following it
/2134$/ Matches if line ends with 2134
/\(21|35\)/ Matches is the line contains 21 or 35
Note the use of ( ) with the pipe symbol to specify the ‘or’ condition
/[0-9]*/ Matches if there are zero or more numbers in the line
/^[^#]/ Matches if the first character is not a # in the line
Notes:
1. Regular expressions are case sensitive
2. Regular expressions are to be used where pattern is specified

Counts


Nearly every command may be preceded by a number that specifies how many times it is to be performed. For example, 5dw will delete 5 words and 3fe will move the cursor forward to the 3rd occurence of the letter e. Even insertions may be repeated conveniently with thismethod, say to insert the same line 100 times.

Ranges


Ranges may precede most “colon” commands and cause them to be executed on a line or lines. For example :3,7d would delete lines 3-7. Ranges are commonly combined with the :s command to perform a replacement on several lines, as with :.,$s/pattern/string/g to make a replacement from the current line to the end of the file.
:n,m Range – Lines nm
:. Range – Current line
:$ Range – Last line
:’c Range – Marker c
:% Range – All lines in file
:g/pattern/ Range – All lines that contain pattern

Files


:w file Write to file
:r file Read file in after line
:n Go to next file
:p Go to previos file
:e file Edit file
!!program Replace line with output from program

Other


~ Toggle upp and lower case
J Join lines
. Repeat last text-changing command
u Undo last change
U Undo all changes to line

Install Google Chrome for Mac OS X & Linux

June 22nd, 2009

*Google has also released official builds of Google Chrome for Linux and Mac OS X (see update below). If you are looking to install Chrome on a USB stick, check out Portable Google Chrome.

The Google Browser port, known as Crossover Chromium, is available for download on Mac OS X as a native Mac .dmg file or on Ubuntu, RedHat, Suse, etc. as standard Linux packages.

Google Chrome for Mac OS X- Screenshot

screenshot - chrome for mac

Google Chrome on Linux – Screenshot

screenshot - google chrome for linux

Google Chrome is built with open source code from Chromium.

How to Install Google Browser on Mac / Linux

Mac users can simply drag the Chromium .dmg file into their Applications folder. Linux users should use the appropriate tools for their respective Linux distributions to unpack the installer package. Google Chrome on Linux is available for both 32bit and 64bit versions.

If you installed Google Chrome on Linux using the .deb package, you can uninstall the Google Browser using the Synaptic package manager or via the following command – sudo aptitude purge cxchromium

Google Chrome for Mac & Linux – Official Builds

Update: The official builds of Google Chromium are now available for Linux and Mac here. The interface and features of Chromium for Mac OS X are similar to that of Chrome for Windows but it’s a developer release and not very stable yet.

Dell Critical Update For Dell Dimension C521, E521 and OptiPlex 740

June 5th, 2009

A critical update is available for the following systems running Microsoft® Windows Vista™ which shipped between January 30 and February 15, 2007:

  • Dell Dimension™ C521
  • Dell Dimension™ E521
  • Dell OptiPlex™ 740
If your system is running Microsoft® Windows Vista™ it is strongly recommended that you download the latest driver update.
FAILURE TO LOAD THIS DRIVER PROMPTLY COULD RESULT IN CRITICAL SYSTEM ERRORS.

Download driver

NOTE: If you are experiencing a “No Operating System Found” error message, please refer to the following Knowledge Base articles prior to installing the update:

Dell Dimension™ C521/E521
Dell OptiPlex™ 740

Linux distribution strategic criteria

June 1st, 2009

Two New Gartner Linux Research Notes

Leading IT research and advisory company Gartner has published two new Linux research notes:

Cool Wallpapers Website – Free Downloads

May 23rd, 2009

I have stumbled upon a very cool wallpapers website where you can freely download very nice wallpapers automatically optimized to your screen resolution – check it out :

http://www.desktopnexus.com/

Moblin v2.0 Beta: Linux Netbook’s Distribution Released

May 22nd, 2009

Moblin, short for mobile Linux, is an open source project focused on developing software for Mobile Internet Devices (MIDs) and other new categories of devices such as netbooks and nettops. Intel launched the Moblin.org site in July 2007 and significantly updated the site in April 2008 with the launch of the Intel Atom processor family at the Intel Developer Forum in Shanghai. A custom SDK is also available on the site. The Moblin 2 OS was specifically designed to run on an Intel Atom processor in a netbook. In April 2009 Intel turned Moblin over to the Linux Foundation. Watch the below video for an introduction to the new beta version :


EU Fines Intel for Anti-Competitive Practices.

May 14th, 2009

Computer chipmaker Intel has been fined a record 1.06bn euros ($1.45bn; £948m) by the European Commission for anti-competitive practices.

The Santa Clara, California-based company dominated the 22-billion-euro (30-billion-dollar) market for the ubiquitous x86 CPUs with a 70-percent share during the more than five years it was accused of breaking EU antitrust rules.

“Intel has harmed millions of European consumers by deliberately acting to keep competitors out of the market for computer chips for many years,” EU Competition Commissioner Neelie Kroes said.

“Such a serious and sustained violation of the EU’s antitrust rules cannot be tolerated,” she added.

The commission said Intel had used wholly or partially hidden rebates to get PC makers such as Acer, Dell, HP, Lenovo and NEC to buy all or almost all their CPU supplies from Intel instead of US rival Advanced Micro Devices (AMD).

“Naturally, the commission favours strong, vigorous price competition, including by dominant firms,” Kroes told reporters in Brussels.

“However, Intel went beyond normal price competition by giving rebates to computer manufacturers on the condition that they bought all, or almost all, of their CPUs from Intel.”

Intel general counsel Bruce Sewell defended the rebates, arguing that computer makers approach the company seeking reductions and stressing that “there is no evidence that we were pricing below cost.”

EU antitrust regulators also accused Intel of paying computer manufacturers to halt or put off the launch of products containing microchips competing with Intel’s x86.

In addition, Intel allegedly paid a major electronic retailer, chain store MediaMarkt, to stock computers equipped with its chips.

Intel has announced that it will appeal against the verdict.

ESET Smart Security Wins CNET Editors’ Choice Award

May 8th, 2009

ESET, the leader in proactive threat protection, today announced that it received a CNET Editors’ Choice award for ESET Smart Security 4, the recently updated integrated security solution combining antivirus, anti-spyware and anti-spam functionality with a personal firewall. The coveted CNET Editors’ Choice award recognizes outstanding consumer electronics that represent the best available choice for quality, performance, design, service, value, and its logo is a mark of excellence denoting the best possible investment for consumers.

CNET Editors’ Choice winners are recognized as top products in their respective technology categories, and contribute to the standard by which all future products are judged. A key selection requirement is that it must also change the competitive landscape of its market, whether through innovative features, exceptional value for the price, remarkable ease of use, or a demonstrable boost to the lives of its users.

“ESET Smart Security is surprisingly light, consuming around 50MB of RAM when running, and ESET NOD32 has consistently scored near the top of several independent antivirus testing organization ratings for finding the most malware while encountering fewer false positives than most,” said Seth Rosenblatt, senior associate editor, CNET Downloads. “For getting all your security tools in one box, Smart Security is an effective and well-respected choice.”

“We are very excited about this honor from CNET as their Editors’ Choice award has become the hallmark of technology quality and innovation, and its logo is a symbol consumers know and trust,” said Anton Zajac, CEO, ESET LLC. “This is an exceptional achievement and we are very proud to be recognized for our dedication and commitment to providing users with the most advanced protection from evolving security threats.”

Built on the same engine that powers ESET NOD32 Antivirus, ESET Smart Security 4 also features anti-spam and firewall functionality, both of which received high marks in usability and effectiveness. ESET’s detection and diagnostic features safeguard users from deceptive forms of malware by digging deeper into the operating system, files and encrypted browser traffic to identify and eliminate hidden malware threats. ESET Smart Security 4 proactively blocks most new malware attacks before they can compromise systems or steal data.

For information on ESET Smart Security 4 and the CNET Editors’ Choice award, please visit http://www.cnet.com/editors-choice


Acer Travelmate 3260 Series MS Windows XP Drivers

April 26th, 2009

Below are the MS Windows XP 32bits Home Edition drivers for the Acer Travelmate 3260/3262 notebook. These were requested through a support ticket. It was made available publicly to help others also.

Drivers Download Links :

Xmarks – A Very Useful Firefox add-on

April 24th, 2009

If you haven’t tried Xmarks add-on with Firefox web browser then you’re missing on a whole lot of features. If you use more than one computer, keeping bookmarks and passwords synched between the machines can be a bit of a hassle. Actually, it can be a major hassle, unless you’ve got something like Xmarks at your fingertips.

Xmarks is an extension that provides the ability to sync bookmarks and passwords, backup and restore bookmarks, and provide access to your bookmarks from the Xmarks Web site. In addition, you have the ability to set up profiles, so you can separate your personal and work bookmarks if you want to.

Give Xmarks a test drive, you won’t regret it. Additional features include :

Site Info built into your browser

Click on the Xmarks info icon in your location bar to see detailed information about the site you are on, and discover other great sites just like it.

See suggested tags when you bookmark

The next time you add a bookmark, Xmarks will automatically suggest a list of bookmark tags. These suggestions are based on the tags other Xmarks users chose for the same site.

Quickly find tagged bookmarks

Type a tag name into the Firefox 3 location bar (also known as the Awesome Bar) to quickly find sites with that tag.