Who.hasfiles Updates, Enables Web Sharing

Who-hasfiles web sharing The free remote file storage service – Who.hasfiles.com – has recently updated to include web sharing and hosting capabilities. We’ve written about Who.hasfiles.com before.

Essentially, Who.hasfiles offers 100 MB of free online storage. No, that’s not a whopping amount of space by any means, but what sets them apart is the manner in which you access it. Who.hasfiles allows for remote drive mapping from your operating system, all without installing anything. Your 100 MB of storage simply shows up as another disk or as a remote folder.

They have instructions for mapping the drive in Windows, Mac OS X, and Linux.

Web Sharing

The new feature that they are rolling out is the ability to share and hotlink files over the Web. Setting it up couldn’t be simpler. All you have to do is create a folder called web in the root of your storage space.

Who-hasfiles web folder

Anything you put inside the web folder is directly accessible on the Internet. Whoever access the link to your web folder will see a list of all your shared files. Speaking of which, the link to your web folder is as follows:

http://your-user-name.hasfies.com/web

People who access the link to your web folder will see a list of all your shared files. It’s great for quick-and-dirty file sharing.

Who-hasfiles - habibbijan web

File/Web Hosting

Another use for the Who.hasfiles web folder is direct linking (hotlinking) to files. For starters, you can upload your own index.html file if you don’t want people to see everything in your web folder. Heck, you can even build a small website with only static files (sorry, no PHP here).

A much more powerful use, though, is embedding files directly in blogs or forums. One area where this can be greatly useful is if you have a Blogger account or WordPress.com blog. Neither of those sites allow you to upload audio files, so this is another great way to get around Blogger’s upload limitations.

As you might expect, all you have to do to link directly to a file in your Who.hasfiles.com account is to first make sure that file is inside your web folder. Next, just type the full path to the file, like this:

http://your-user-name.hasfiles.com/web/name-of-file.pdf

In my case, I want to directly access that MP3 file in the picture above. For me to do so, all I have to do is type:

http://habibbijan.hasfiles.com/web/bondari-demo.mp3

Try it! In this manner, you can link to specific files from Blogger, WordPress.com, online forums, or from anywhere else you want. Hint: I suggest leaving all filenames lowercase and omitting spaces to avoid link frustrations.

I don’t know yet if Who.hasfiles imposes any bandwidth restrictions. I doubt it, especially considering that the free account only allows for 100 MB of storage. If someone from the company could comment, we all would appreciate it.

As we’ve mentioned before, you don’t get much space with Who.hasfiles, but we love how convenient it is to map a remote drive from any operating system. Just think of it like a remote USB flash drive from 2003. The addition of file hosting (and direct linking) is a welcome update.

Get 100 MB free at Who.hasfiles.com.

New Overview of MODx (MODx Series Part II)

A while back I did a brief overview of the MODx content management system. Well, I was asked to do a high-resolution video so you can see what the manager interface looks like and you can get an idea of why you might want to choose the MODx content management system for your next web site.

A video used to be embedded here but the service that it was hosted on has shut down.

Overview

Publish/unpublish a document by right-clicking the document:

Right-click a document to edit it
Right-click a document to edit it

You can set publish/unpublish dates by changing the Page Settings:

Set the Publish/Unpublish dates in the Page Settings tab
Set the Publish/Unpublish dates in the Page Settings tab

Build your own templates or use existing CSS and HTML by adding simple placeholders to the code. Just paste the HTML page into a new Template.

Sample of a MODx Template:


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>[*pagetitle*]</title>
<meta name="description" content="[*description*]">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link type="text/css" media="screen" rel="stylesheet" href="/assets/templates/uncomplicated/style.css" />
<base href="/"/>
</head>
<body>
<h1>[*longtitle*]</h1>
[*content*]

Where you put the [*placeholders*] is somewhat arbitrary, but the above example is how I usually put together my templates. It’s just important to remember how the substitution works. The text in the “Title” field will replace the [*pagetitle*] placeholder tag.

Here’s a graphic I made to demonstrate how the values in the editor are substituted any instances of the placeholders in the template. MODx offers the easiest templating I know of. Stay tuned for a hi-res video illustrating how you can take an existing HTML/CSS layout and turn it into a MODx template… for now, only the low-res video is available.

MODx uses simple placeholders for templates
MODx uses simple placeholders for templates

MODx also allows you to add custom fields to any document, but that’s a more advanced topic… stay tuned.

Requirements

The requirements for MODx are quite similar to the requirements of other CMS’s.

  • PHP (4.4.x or above)
  • MySQL (4.1 or above)
  • Apache with mod_rewrite (used for friendly URLs)

Advantages

  • Document Tree. Using other CMS’s it can be difficult to locate content. “Where was that legal notice? I know the URL, but I just can’t find the content to edit it!” MODx makes it easy to find and edit your content.
  • Isolation of Responsibilities. It’s very simple to isolate roles so a team can work on a site: content folks can login to the manager and edit content, front-end designers can build HTML and CSS templates that integrate EASILY into MODx without a steep learning curve, and PHP developers can write code, and each of these separate groups can work in their respective areas with very simple overlaps.
  • Simple Templates. There are no special logical tags to learn for templates; PHP scripts can be saved directly in the database and called from any document. Not all CMS’s provide this kind of isolation, and no other CMS makes it as easy to use existing HTML and CSS layouts.
  • Dynamic Menus. They make it easy to move content around your site, and menus will generate themselves automatically!
  • Speed. All CMS’s are slower than a static site, but MODx is one of the faster CMS’s that I’ve seen using load time benchmarking.
  • Small database footprint. You can get a hundred pages on your site and end up using only a few megabytes in your database. Other CMS’s use much more space in the database.
  • Extendable! It is insanely simple to add existing PHP scripts to MODx.

Limitations

As much as I like MODx, it may not be the best choice for your particular needs.

  • 5000 page limit. The new version of MODx will support more, but if you have more than 5000 pages on your site, MODx may not be for you. There are work-arounds, however…
  • Open-Source. If you are in a corporate environment and you NEED to have someone on-call for help resolving technical problems, then you should probably look for a different CMS. MODx is open-source. The forums are a great place to get help, but there is no dedicated support staff.
  • Versioning. Some CMS’s offer rollback features for the content in your templates or posts (similar to giving you levels of “un-do”), but the current version (0.9.6.3) does not offer this by default. You can add this functionality, but it is not built-in; it is slated to be included in the next version of MODx

Summary

I hope that the video gives you an idea of what this content management system looks like. Hopefully you can see how you might use it for one of your own projects. Don’t forget the MODx Wiki and the MODx forums for additional resources. Stay tuned for more videos.

TipsFor.us is now on Facebook

If you are a Facebook addict casual user, I invite you to visit the official TipsFor.us Facebook fan page.

TipsForUs - Facebook

Yeah, it’s pretty bare right now, but you are welcome to change that. Feel free to become a fan, add any photos or videos that you like, and participate in the discussion board.

Facebook also taps into our RSS feed, so if you spend 23 hours a day on Facebook (you know who you are), it can alert you whenever we post a new article.

If you ever have a quick tip or an article suggestion, or if you just want to say Hi, please feel free to write on our Wall.

Most importantly, if you find our site helpful, we humbly request that you become a fan (just click the button in the top-right corner). If you have been resisting the temptation to create a Facebook account, maybe now is the time to finally give in to the pressure? Resistance is futile.

We look forward to meeting you on our Facebook page!

Batch Image Resize in Vista with Image Resizer Powertoy Clone

Back in the days of XP, Microsoft released a great set of tools they called Powertoys.  Potentially the most useful of these being a shell addition that allowed you to right click on a set of selected images and resize them.  Like a lot of people, I figured this function would just be built into Vista…  It’s not.  Also, there is currently no Vista Powertoy that has the same function (There may be, at a later date – I’ve heard rumors of several in development).  But what to do until then?

A wonderful little program has been developed that emulates the identical functionality of the XP resizer Powertoy, on Vista.  It’s called the “Image Resizer Powertoy Clone.” Best news:  It’s open source and free.

You can grab it at Here.

To use it, all you have to do is highlight the images you want to resize, right-click, and select Resize Pictures.  You will then receive a dialogue window prompting you to choose a size from the most common, or you can click Advanced for more control.

It will not overwrite the images. Instead, it will rename the copy to have the image size after the original file name.

Ace that Exam by Studying Flashcards Online (7 Resources)

Classes have started again at most universities, so now is the perfect time to make sure those grades don’t start slipping. While studying hard and making A’s come naturally for some people, most of us need a little help and motivation.

One of the most tried-and-true methods of studying is to create and review flashcards. While I can personally attest that flashcards have helped me pass many classes (especially Latin – semper ubi sub ubi), I hate dealing with flashcards. It seems that I’m always running out, or losing them, or maybe I can’t read what I previously wrote. It’s a mess.

Fear not. Here are seven online resources for creating and managing flashcards online. With a little luck (and some hard work), they can help you make the grade this semester.

Study Bulb logo 1. StudyBulb

Link – http://www.studybulb.com

StudyBulb describes itself as a free online collaborative community for study materials. The site launched in April 2008 and is still in early Beta. Despite their Beta status, they have a growing number of existing flashcards that you can browse, ranging from Elementary difficulty through College. Of course, you can create a free account and start contributing your own.

One handy feature of StudyBulb is the ability to copy an existing collection of cards to your own account. They also provide a mobile link to each collection for reviewing on a web-enabled mobile phone. Nice!

StudyBulb is promising, but is weak on content right now. The interface is simple and slick, so I hope they continue to grow.

Try it now: Test your knowledge of the King Arthur legend.

Quizlet Logo 2. Quizlet

Link – http://quizlet.com

Quizlet is a popular free online flashcard portal with a number of features. Originally created in 2005 by a lone high-school student with the purpose of making French vocabulary more fun, Quizlet has since grown into a massive site with millions of existing flashcards. Naturally, you can create a free account and start your own collections.

To aid the learning process, Quizlet offers five different review modes, ranging from the simple Familiarize mode to the more fun and strenuous Scatter and Space Race modes. Nothing strains your knowledge like quickly typing answers to overhead flying questions, I suppose.

Other neat features include flashcard sharing (Facebook included) and the ability to add friends and classmates to study groups (public or private). Quizlet can also track your study progress with accuracy scores.

Quizlet is impressive, for sure. Once their iPhone app works out some kinks, it will be even better.

Try it now: Test your knowledge of European capitals.

Study Stack logo 3. Study Stack

Link – http://www.studystack.com

Study Stack offers a number of creative ways to help memorize information. Though the foundation of the site is built around flashcards, Study Stack allows you to test yourself in some engaging and unusual ways. Getting tired of traditional flashcards? Try reviewing your material as a hangman game, or maybe a word search. You can even play a game of bug match, in which you maneuver a rather happy spider across the screen in an attempt to catch the bug that represents the correct answer. Think of it as multiple choice, but with… bugs and spiders. Hey, whatever helps you learn….

Study Stack - Bug Match

If your mobile phone supports Java, you can export data to it for review on the go. Study Stack has a decent amount of existing material, but you can always create a free login and contribute your own.

Try it now: Need to do some review for the A+ Certification Exam?

Flashcard Exchange logo4. FlashcardExchange

Link – http://www.flashcardexchange.com

FlashcardExchange proudly boasts that it is the world’s largest flashcard library. That may be true, considering that the current flashcard count is approaching 17 million. It’s also one of the oldest (launched in 2001). However, it’s also one of the only flashcard sites that separates free from premium services.

A free membership will allow you to create unlimited flashcards, plus the ability to study and share them online. That’s about it. A premium membership adds such necessary features as the ability to print and export flashcards to Word or Excel.

To be fair, a premium membership is only a one-time fee of $20 USD, and it does add some other handy features, such as the ability to add pictures (jpg) and audio (mp3) to your flashcards. It’s up to you to determine if $20 is worth it. I’m glad to see that they offer support for the iPhone and iPod Touch, even for free members.

FlashcardExchange is indeed massive, and they have some nice features. I dig the keyboard support for manipulating cards. If you spring for the premium membership, there’s not much you can’t do. Otherwise, the free version is handicapped.

Try it now: Test your knowledge of the Greek alphabet.

Studyblue - logo5. Studyblue

Link – http://www.studyblue.com

Created in 2006, Studyblue aims to be much more than just a flashcard review site. While flashcards are certainly an integral part of their service, they also offer class notes, textbook outlines, study groups, and tutors. In fact, in their efforts to build quality content, Studyblue is willing to PAY you to upload your class notes and flashcards, up to $5,000 per semester. See their blog for details.

Studyblue is more than an individual study portal – it has features commonly associated with social networks. You can invite friends, create groups, send shouts, and participate in forums. There’s a big emphasis on connecting your profile with specific classes. Before you can do much of anything, you first have to add some enrolled classes. The flashcards and notes that you create will be associated with those specific classes.

The interface is slick and easy to use. Studyblue shows much promise, but there is room for improvement. Flashcard printing is not yet supported, nor did I find anything about exporting or mobile access. However, you CAN attach images to flashcards. Because of the emphasis on class, I found it difficult to link to a specific deck of flashcards. Instead, here’s a screenshot of me trying my hand at some French vocabulary review:

Studybulb - French vocab

Studyblue’s all-in-one approach will appeal to a lot of users. The ability to earn some extra cash is an added incentive.

Flashcard Machine logo6. Flashcard Machine

Link – http://www.flashcardmachine.com

As the name implies, Flashcard Machine focuses exclusively on interactive flashcards. No more, no less. Registration is free. Like FlashcardExchange, the service has been around since 2001. There are currently over 9 million available flashcards.

Concerning features, Flashcard Machine has the basics covered. You can create an unlimited amount of flashcards, plus view all the existing cards by subject. You can even attach audio and pictures to flashcards for free, though space is limited to only a few megabytes. You can’t export flashcards to another format, but you CAN print (via printer-friendly HTML). Mobile access on the iPod is available, but it requires integration with iStudyToGo ($20).

Using Flashcard Machine is simple. No, it doesn’t keep any detailed statistics about your overall accuracy, but for quick-and-dirty flashcard review, it’s hard to beat. You can manipulate the cards with simple keystrokes.

Flashcard Machine - Latin words

Flashcard Machine’s simple interface won’t turn any heads, nor does it have any fancy social networking features, but if all you want is to create and learn some flashcards, it’s got you covered.

Try it now: Need to review a little Greek mythology? You can get an overview of the cards, but actually attempting them requires registration (free).

Anki logo7. Anki

Link – http://ichi2.net/anki

Anki derives its name from the Japanese for “to memorize.” As such, it’s in a league of its own among flashcard sites. I debated whether or not to include it in this article because it is primarily an installable application, but it DOES include online access.

Anki is not just a flashcard creator, it’s a Spaced Repetition System (SRS). In a nutshell, Anki intelligently determines how often to repeat individual flashcards based on how well you’re able to determine the answer. If you know the answer easily, Anki might wait several days to show you the card again. If you fumble with the answer (or don’t know it), Anki will repeat the card soon.

Anki - Main

The program is completely free and open-source, and is available for Windows, Mac, and Linux. See screenshots. Anki includes online support – you can sync your cards across multiple computers, plus study them online from any Internet-connected computer. Yes, you can even access your cards on most mobile devices, including the iPhone. Windows Mobile support is currently experimental.

You can use Anki to learn most anything, but it excels in subjects that you plan to study for months or years, such as language. If all you want to do is cram for an exam, there are better choices. If you REALLY want to add material to your long-term memory, Anki is a prime choice. I strongly suggest watching the introductory videos to get going quickly.

You can find an assortment of pre-made decks of cards, but Anki works best if you create your own.

—-

So, which resource is the best? Naturally, that depends on your needs. Every service that I mention here will allow you to create and review flashcards – it’s up to you to determine which one has the features and the interface that you like most. If sheer numbers impress you, take a look at FlashcardExchange. If you want a flashcard portal that borders on a social network, Studyblue is your best bet. If you really want to learn a topic over an extended amount of time (such as a language), you owe it to yourself to check out Anki.

No matter which service you choose, may there be only good grades in your future!

Three Easy Ways to Try Ubuntu Without Breaking Anything

Broken Windows So, you’ve heard about this Linux thing and want to learn more about it? Perhaps you have heard about its inherent security and near-impermeability to malware. Perhaps you’re still on 2000 or XP and don’t want to shell out the cash for a newer Windows OS. Hey, the economy is tough, I know. Or perhaps you’re just attracted to the idea of open source and want to worship at the feet of Richard Stallman. Just kidding about that last part, I think.

No matter the reason, if you’ve never tried Linux, but have considered it before, consider this your invitation to start treading the Linux waters. No, you won’t drown.

But, but, I’m worried about breaking Windows!

Calm down. Your Windows installation will be fine.

But, but, I don’t know which Linux to choose. There are so many!

Yes, that’s true, but there are similarities between all of them. In fact, many of the available Linux distros are just slight alterations of one another. Think of it as one person with many different sets of clothes.

While any of the major distros will work just fine, I recommend Ubuntu to people trying Linux for the first time.

But, but, what if I don’t understand any of the programs?!

Relax, I bet you will. Perhaps you already use several popular open-source programs on your Windows computer, such as Firefox, Thunderbird, OpenOffice, VLC, or The GIMP? Plus, many common closed-source programs are also available on Linux, including most of the Google programs and Nero Linux. I bet you’ll be just fine.

I generally find that newcomers to Linux are most hesitant about disk partitioning and the potential risk of losing data. Ubuntu can handle disk resizing and partitioning with aplomb, but for the ultra-risk-averse, here are three ways to give Ubuntu a shot on your computer without breaking Windows or losing any data.

Method 1 – Live CD

The first thing to do is download a copy of Ubuntu. Have a slow connection (or just don’t feel like downloading)? No problem. Ubuntu can ship a disc to you for free, although you may have to wait ten weeks for delivery. Oh well, I guess that’s better than waiting 11 weeks for download over dial-up Internet.

Not sure which edition to download? If in doubt, just go for the Desktop edition (32-bit).

Next, burn the ISO that you downloaded to a blank CD as a disk image. You should be able to do this easily in any CD-burning software. For instance, in InfraRecorder (free), look for the Write Image option.

InfraRecorder Main

Once your new Ubuntu disc is burned, just leave it in your CD drive and reboot. There’s a pretty good chance your computer will boot straight to the disc. If it does not, reboot again and go into the bios at boot, usually by pressing DEL or F2, depending on the computer manufacturer. Look around for a BOOT section and set your CD drive as the first boot option. Don’t be scared. If you have trouble with this part, ask your neighborhood geek.

When your computer successfully boots from the CD, follow the prompts to Try Ubuntu. Within a few minutes, you should be staring at your brownish Ubuntu desktop, running straight from the CD. Congrats! Feel free to play around as much as you like, and when you reboot, your Windows will be there waiting for you.

Note: running from a CD is MUCH slower than running from your hard disk.

Method 2 – Wubi

Wubi windows If you want a more permanent solution than a Live CD, you owe it to yourself to check out Wubi.

http://wubi-installer.org/

Without a doubt, Wubi is the easiest way to get a full Ubuntu installation without fear of damaging Windows. With a few clicks, Wubi will install Ubuntu within Windows, just like any other Windows application. No CDs to burn. No disk partitioning. Only good times.

To install Wubi, you can either download the installer directly, or run it straight from the Ubuntu Live CD.

Ubuntu CD Menu

When you first pop the Ubuntu CD into the drive, you will have the option to Install inside Windows. Clicking that option brings up the Wubi installer, allowing you to specify a few setup options.

Ubuntu - Wubi Setup

Choose a username and password, and off you go! Wubi will install like a typical Windows application. Go get a cup of coffee because installation will take a few minutes. When it’s done, reboot, and you will have your choice of Windows or Ubuntu to run.

At any point, if you decide to get rid of Ubuntu, just uninstall it in the Windows Control Panel (Add/Remove Programs), just like any other app.

Method 3 – Virtual Machine

The third option requires a little more nerd factor than the previous two, though not by too much. Most newcomers to Linux should stick with the first two options, but if you are a more experienced Windows user, go ahead and give method three a try – running Linux in a virtual machine.

A virtual machine allows you to run multiple operating systems simultaneously, all without conflicting or damaging one another. The only limitations are in how much RAM and disk space your host computer has.

All you need to run Linux in a virtual machine is:

  1. An ISO of a Linux distro (see Method 1 above)
  2. Free Virtual Machine server software

The titans of free virtual server software are VMware, VirtualPC, and VirtualBox. Of those three, I prefer VirtualBox.

http://www.virtualbox.org/

With VirtualBox, you can easily try Ubuntu without doing any damage to Windows, and if your computer was built within the last four years or so, the Ubuntu virtual machine should perform much faster than the Live CD as well.

Here’s a screenshot of my Macbook running Ubuntu in a virtual machine:

One cool aspect of VirtualBox is the ability to take snapshots of the current system. Scared your tinkering is about to break the virtual Ubuntu? Just take a snapshot first, then tweak to your heart’s content. You can always restore the previous snapshot with a click or two.

Want more information on setting up VirtualBox? See my previous walkthrough.

There you go – three easy ways to try Ubuntu without breaking Windows. I can’t promise it will become your favorite operating system, but now you have no excuse not to learn more about it! Enjoy.

A Reference for the VI Text Editor (aka VIM)

If you’ve done any programming at all on the command line (in Linux or OS X, or using Cygwin on Windows), you have probably heard of VI and the other powerhouse command-line editor, eMacs, and the epic battle between them long, long ago in a galaxy far, far away… The goal of this article is to give you a functional overview of the VI text editor and give you a useful reference of its commands. I spent a lot of time putting these notes together, so I hope they’re helpful.

Right off the bat, some purists will snipe me for saying “vi” when I really mean “vim” — the latter being the IMproved version. But pretty much everyone uses vim and they call it vi… most of the time when you type “vi” on the command line, it opens up vim anyway.

Open a file with vi just like with other editors: vi [filename] . If the file doesn’t exist, it will be created. And then you will have entered the realm…

There are 2 Modes: Insert and Command

The insert mode is the “normal” typing mode that you would normally think of when using a word processor. The command mode is when you are typing in commands to operate on the text (in lieu of menus, you’ve got to type in all commands). vi starts in command mode, but if you’ve gone to the edit mode, pressing Esc gets you back into command mode. Entering Insert mode is actually a command. Enter insert mode by pressing i (preceded by the Esc key if necessary): Esc to enter command mode. i to enter Insert mode.

How to Type Commands in Command Mode

The command mode commands are normally in this format: (Optional arguments are given in the brackets)

[count] command [where]

Count is the number of times to run the command (e.g. delete 7 lines), and where is the destination of the action, e.g. save this file as xxx.txt.

I’ve grouped the commands here loosely into groups, some of them corresponding to traditional menu names.

Modes

i – enter insert mode (you can also type ‘a’)

Esc – enter command mode

File (the colon commands, mostly)

:n create a new file (not common).

:e [filename] – Edit (open) a file.

:w – save. :w [filename] acts as “Save As”.

:wq – save and quit. Also ZZ (in caps).

:w [filename] – save as filename.

:set xxx – sets option xxx. See Preferences section below.

:q – quit.

:q! – quit without any prompts (i.e. quit without saving).

Edit

u – undo the last change (or redo it).

U – undo the changes to the current line.

ctrl r – Redo. This redoes whatever you undid.

. – Repeat last command.

x – deletes the character under the cursor (Del).

X – deletes the character before the cursor (Backspace).

d – delete (i.e. cut). Usage is dw, d$, d^, dd. to delete a word, delete till the end of the line delete to the beg. of the line, repeat delete, respectively.

y – yank (i.e. copy).

– clipboard. See “Multiple Buffers” below.

p – paste.

r – replace the character under the cursor (specify count).

/ – Find (searches from the current position towards the end)

? – Find (searches from the current position towards the beginning).

:s[regular expression] – Substitute (find and replace). See below.

View

:set nu – show line numbers (:set nu! to remove)

zc – folds Closed a section of code, delineated by {{{ # code here }}} #

zo – folds Open a section of code, delineated by {{{ # code here }}} #

Format

> – indent highlighted text (like tab)

< – shift tab.

Insert

O – open the line above the line the cursor is on.

o – open the line below the line the cursor is on.

R – enters Replace (overwrite) mode until Esc is pressed to exit.

Navigation

h – move the cursor left

j – move cursor down

k – move the cursor up.

l – move the cursor right.

control F – move forward one screen (i.e. page down)

control B – move back one screen.

H – home window line (top of visible)

L – last window line.

]] – next section/function

[[ – previous section/function

0 – Move to start of line (zero)

$ – move to end of line.

shift g – move to end of document.

gg – move to start of document

ctrl g – returns the current line number.

123 shift g – go to line 123.

Tools

% – when the cursor is on a (,),[,],{, or } this will locate its matching pair.

Window

:split – split screen horizontally

:vsplit – split screen vertically.

ctrl w [up/down/left/right] – jump to new portion of split screen.

ctrl z – move vi to background (recess to the Terminal)

fg – brings the process back to the ForeGround (type this in the shell after you’ve done a “ctrl z”).

Help

:h – help

crtl ] – follow a link in the help file.

:q – closes the help file (it’s actually a separate text file), so you quit it.

Search Commands (Find)

These commands let you search the current file looking for a given string. When you press the ‘/’ or ‘?’ key, the cursor will move to the bottom of the screen, where you will enter the string you wish to search for. Pressing the [RETURN] key will signal the end of the string, and cause the search to take place.

To include a ‘/’ or ‘?’ as part of the search string, you must “escape” any of these characters with the backslash character (\).

==> /search string[RETURN]

This command will let you search forward through the file looking for the string. The search will wrap around to the start of the file.

==> ?search string[RETURN]

This command will let you search backward through the file looking for the string. The search will wrap around to the end of the file.

Press n (n) to move to the next result. Press shift n (N) to move back to the previous.

Mnemonics:

The ‘/’ is a forward slash, and is used to search forward. The ‘?’ is the shifted ‘/’ key, and you can think of the act of shifting as reversing the command direction.

To repeat the search, press ‘/’ or ‘?’ depending on whether you want to search forward or backward for the next occurrence. When the cursor moves to the bottom of the screen, press [RETURN] without entering anything. Vi will use the last search string entered as its target.

Substitute (Find and Replace)

To substitute new for the first old on a line type :s/old/new

To substitute new for all ‘old’s on a line type :s/old/new/g

To substitute phrases between two line #’s type :#,#s/old/new/g

To substitute all occurrences in the file type :%s/old/new/g

To ask for confirmation each time add ‘c’ :%s/old/new/gc

Multiple Buffers ” : Frequently Used Text

Most users just use the general buffer, but you can cut and paste text from/to multiple buffers. There are 36, specified by all letters (a-z) and all digits (0-9). The buffer is specified using the command (the mnemonic here might be to QUOTE something). For example, the command: “mdd uses the buffer m, and the last two characters stand for delete current line. Similarly, text can be pasted in with the p or P command. “mp pastes the contents of buffer m after the current cursor position. For any of the commands used in the next two sections, these buffers can be specified for temporary storage of words or paragraphs.

These buffers remain in memory after vi has closed (for a while, at least… I’m not banking on these buffers being 100% persistent). So you can use them to store frequently used bits of text. For example, you may want to use:

“i to contain the block code for an if statement.

“h to contain basic html tags.

Copy, Cut, and Pasting

(i.e. Yanking, Deleting, and Pasting)

The command commonly used command for cutting is d. This command deletes text from the file. The command is preceded by an optional count and followed by a movement specification. If you double the command by typing dd, it deletes the current line. Here are some combinations of these:

d^ cuts (deletes) from current cursor position to the beginning of the line.

d$ cuts (deletes) from current cursor position to the end of the line.

dw deletes from current cursor position to the end of the word.

3dd deletes three lines from current cursor position downwards.

There is also the y command which operates similarly to the d command which take text from the file without deleting the text.

The commands to paste are p and P. They only differ in the position relative to the cursor where they paste. p pastes the specified or general buffer after the cursor position, while P pastes before the cursor position. Specifying count before the paste command pastes text the specified number of times.

Keep in mind that the targeting of the pasting actions isn’t where you’d expect from working with traditional word processors.

Execute External Commands

Type :! followed by an external command.

:! perl -d % launches the current (perl) script in debugging mode (very useful!).
:! php -l % if you’re editing a php file, this checks syntax.

Highlighting Text

v – enters visual mode so you can highlight a visual block. You can highlight entire lines AND columns. Very cool.

To highlight several lines: ctrl v, then hold shift and use the arrow keys and the Home and End keys as you would do normally in commercial word processor (or the j,k,l… equivalents). E.g., pressing d after highlighting a block would delete it (cut it).

Shift g moves to the end of the document.

Alternatively, with most terminals you can use the mouse to highlight a block of text, then move the cursor to where you would like to paste it. A right-click will paste the text. However, this method is a bit awkward because of the keyboard/mouse/keyboard interaction.

Setting Preferences using :set (Pimping Your Ride)

You can set a number of preferences in vi including text and highlight color. Many of these options can be set using :set. Notice than anything you can set, you can unset by using the same command followed by ! – the exclamation point is the universal program code for NOT.

:set ic – ignore case (for searches)

:set hls– sets highlighting for a search

:set is – include search

:set nohlsearch – remove highlighting (or use :set hls!)

:set ai – sets autoindent

:set nu – adds line numbers. (:set nu! to remove)

Edit your ~/.vimrc file to add preferences to this file to make them permanent. E.g. I have the following in my ~/.vimrc file:

highlight Comment ctermfg=lightblue
highlight Search ctermfg=0 ctermbg=3*
set tabstop=4

Other Useful Functions

To push a vi window (or any window, really, to the background) press ctrl z. To bring it back, press fg (for ForeGround). There is fg1, fg2, fg3, etc.

Conclusion

Well, there’s my reference for you fine folks. I may grow some more hair on my chest if I ever do the counterpart for eMacs… but I’m not holding my breath. As of Sunday, this article represents the knowledge gleaned from 2 years spent editing scripts on the command-line. In parting, I’ll share one little tidbit of wisdom: don’t worry too much about the navigation shortcuts: although some shells don’t support the standard arrow keys and Page-Up/Page-Down key bindings, most of them do. Whew!

Please feel free to add corrections or additions to the comments!