Archive for October, 2008

World of Goo

Friday, October 24th, 2008

I don’t usually go for the casual games but I’m making an exception for World of Gooo. It is a terribly, terribly addictive puzzle game that will suck you in for hours. I totally blame Shamus for bringing it to my attention. I read about it on his page, watched the video, read a review someone linked in comments and was intrigued. So I went and downloaded the demo which is actually the whole Chapter 1 (out of 4) of the game. I grabbed it from FilePlanet but in retrospect it was terrible, terrible idea due to the long queues. Which, actually says something about the game. I downloaded stuff from FilePlanet before (Morrowind mods mostly) and I never had to wait in a queue.

World of Goo Wait time was over 40 minutes for me. I just opened the window and went to make myself some dinner. When I came back the thing downloaded. I launched the game and… Well, needless to say, next thing I knew was that it was 3AM in the morning and I needed to stop messing around with the goo-bals and go to sleep. Well, that and get the full game cause I like totally used up the demo in that time. Seriously.

wog_header.jpg

I highly recommend checking it out, but you will probably want to avoid FilePlanet and use one of the alternate download locations. Either that or just get the Demo via Steam. If I knew there was a Steam version I would never bother with the FilePlanet shit.

What is the object of this game? You build wobbly structures by connecting silly looking balls of goo to get to a hard to reach target. That could be a whole game in itself and it would probably keep you amused for hours. It is a blast just to sit there playing with the physics of connecting the balls and keeping these structures from keeling over. But the game constantly throws in new twists into the gameplay. For example, no two stages in Chapter 1 are alike. You start with simple stuff such as building towers. Then you graduate to building bridges over wide gaps of terrain. You learn how to wedge your structures between walls. You learn how to support them with helium balloons to make even longer, wobblier bridges. There is one level which is a hexagonal tumbler forcing you to build a structure that can be rolled over on it’s side or upside down and still work. Every time you start a new level you can expect to be surprised and challenged in a new, entertaining way.

goo1.png

Unlike many other puzzle games there is no one correct solution for each level. Many other games force you accomplish tasks in particular way, and their puzzles seem like a game of “figure out how the designers want me to do this”. World of Goo is different - the game play is entirely free-form and you never feel like you need to follow specific patterns to succeed. The game gives you hints along the way but it never really prods you or shows you how to do things. You are your own master, and whenever you figure out a way to complete a level while saving more goo-balls you feel immense sense of accomplishment.

All the extra balls you rescue in each level, go into the World of Goo Corporation area which is a sandbox where you can use them to build a tower. There is an online component to this which you can enable. Once you do you will see funky little clouds appear above and below your tower. These signify how tall are the towers created by the other players. So you can have a sort of competition going on with all the other World of Goo folks out there. It’s probably worth adding that you can go back and replay every level at any time you want to see if you can score better (and thus gain more goo-balls for your tower).

goo3.png

The game is visually stunning - the levels are designed astonishingly well, with great attention to detail. Strong art direction gives the game a unique look, which accompanied by the cute sound effects and a lot of humor make for an incredible experience. Not to mention that the game will run on just about anything ranging from a toaster to your high end gaming rig.

It is almost hard to believe that this incredibly polished, detailed and meticulously designed product is an indie game written from scratch by two guys working out of local coffe-shops. Yep, there was no huge dev-team behind this title. Just two dudes with their laptops. Which is all the more reason to give them some of your money right now. At $20 this game is a steal. You won’t regret buying it, unless of course you miss couple of deadlines due to it’s highly addictive nature. Hell, you will feel better about yourself when you buy it knowing that your hard earned cash helped to support two talented independent game developers.

Please Stop Forwarding me ‘The Secret’ Video

Thursday, October 23rd, 2008

Normally I wouldn’t discuss this sort of stuff here, but in the last week or so 3 different people sent me a link to this video (or a similar one). This included my cousin who really should have known better. In fact I initially assumed she sent it as a joke because I did not think anyone related to me by blood could actually fall for something silly as this. But alas, these things seem to be more deceptive than I have thought.

I’ll spare you watching the clip which is incredibly boring and stupid and simply tell you what it is about. It is either a promotional clip for The Secret or the whole movie. I don’t know because I couldn’t watch the whole thing.

The Secret is a strangely popular self help phenomenon which promises you wealth, success and fulfillment of all your dreams if you only follow few simple rules. You know - the usual stuff but with a new packaging. The clip I linked too starts with a intriguing intro that introduces the concept as some sort of DaVinci Code secret passed down through generations among the wealthy and influential people of this world. They are really selling it hard and putting a modern, up-to date spin on the same old shit paddled by the self-help guru’s for years. Watching this video totally reminded me of the self help buy from Donnie Darko.

It’s funny how just about every self help program uses the same damn scheme:

  1. Create a list of positive traits that are exhibited by successful people - stuff like confidence, diligence, positive thinking, etc..
  2. Establish a deceptively simple process which reinforces these traits
  3. Emphasize that the process ALWAYS WORKS by showing how the individual traits can be attributed to successful people
  4. Make sure you define the gains one gets from the process very vaguely and establish that they are based on personal circumstances and thus are not quantifiable or measurable in a scientific way
  5. Explain lack of gains/results as failure to apply the process properly

It is quite brilliant actually. The process always works, but it cannot be tested because it is so subjective. So if it is not working for you and your friends you are doing it wrong. In fact, you are probably all influencing each-other by comparing your gains. You should stop comparing and instead go back to the source (eg. buy more books) and double up your efforts to follow the process.

The Secret establishes the process to be visualizing something that you want and thinking positively about it. They call it “the law of attraction” which supposedly tates that if you want something badly enough it will happen. So for example, if you want a promotion, you should ask the universe for the promotion, then imagine yourself as if you were already promoted and act accordingly. You will then somehow inexplicably “attract” your promotion. Simple, and curiously enough it will always work.

The process requires you to buy into it fully - if you have any doubts, or any misgivings about it it will not work. If you think about your promotion in negative terms then you are miss-applying the process. If you try to test the process you fill fail because there is no time frame on it. The only thing you can measure is success. If you get promoted - the process helped you. If you don’t, then you either applied it wrong or did not wait long enough. Perhaps the promotion is on it’s way and you are fucking your chances up with all this negativity. It’s quite brilliant!

Brilliant but not new. The secret about “The Secret” is that this very method has been used to rip people off their hard earned money since the begging of time. Most religious organizations applied it in some capacity throughout the ages - some with more success than others. Every single self help guru is using the exact scheme - only dressed up a bit differently.

This is what I tell all the people which forward me this video: if you want a self-improvement philosophy that actually may work for you read The Alchemist by Paulo Coelho. It is a short book, and an easy read. It will take you two evenings tops, and once you read it you will see that The Secret is a crock of shit. Why? Because it tells you to sit on your ass and imagine things until they come true, and then claims credit for everything good that happens in your life. It is bullshit and you know it. It is self-help masturbation!

Coelho’s s not in the self-help business. His book is a nice story that you can read to yourself and to your kid, which urges you to follow your dreams whatever it takes. If you really want something, if you feel like you have a destiny to fulfill then put everything on the line, and go for it. If you are willing to sacrifice everything to fulfill your dream then you can hardly ever fail - Coelho claims that “the whole universe will conspire to help you”. There are no promises in the book - it is just a story. The universe doesn’t really conspire to help anyone. But if you take risks and follow your dreams you will probably be much happier than someone stuck at a dead end job they hate. You may fail, you may lose a lot but at least you will have the satisfaction of having tried. And you probably won’t hate your life - you will get up, dust yourself off and try again.

Writing a Minimalistic MVC Framework in PHP

Wednesday, October 22nd, 2008

This is an outcome of a conversation I had recently. Apparently saying that MVC is a fairly simple concept is some sort of blasphemy. But it is. You really don’t need to use the almighty RAILS or a rails like framework like CakePHP in order to the whole Model, View, Controller separation. That’s the beauty of the idea - you can write your own MVC framework from scratch quite easily. In fact, sometimes it is probably preferable to do so. It’s true that you should avoid reinventing the wheel but sometimes you just want lean, minimalistic code with as few dependencies as possible. This is where you would do something like the example below.

This is a bare bones minimalistic core of a MVC system. It’s the index file - the driver or super-controller whatever you want to call it. Users will hit this page, and it will hand off the control to an appropriate Controller class. Thanks to the malleability of PHP this can be accomplished in just few simple lines:

<?php
 
define("COMMON", "/path/to/common/includes/");
 
include COMMON."Util.class.php";
 
if(empty($_GET["module"]))
   die("   <h1>Error: No Module Specified</h1>
            <p>Sorry, no module was specified.</p>
            <p>Please check your URL</p>");
 
if(empty($_GET["action"]))
   die("   <h1>Error: No Action Specified</h1>
            <p>Sorry, no action was specified.</p>
            <p>Please check your URL</p>");
 
$module = Util::sanitize($_GET["module"]);
$action = Util::sanitize($_GET["action"]);
 
$controller = $module."DefaultController";
 
if(file_exists("controllers/$controller.php"))
{
   include "controllers/$controller.php";    
   $active_controller = new $controller();
 
   if(!method_exists($active_controller, $action))
      die("    <h1>Error: Action Not Defined</h1>
                <p>Sorry, the action <strong>$action</strong>
                is not defined in <strong>$module</strong>.</p>
                <p>Please check your URL</p>");
   else    
      $active_controller->$action($_GET);
}
else
   die("   <h1>Error: Module Not Found</h1>
            <p>Sorry, module <strong>$module</strong> 
            does not exist.</p>
            <p>Please check your URL</p>");
?>

Note that I’m using some shortcuts here. For example I assume that you can figure out for yourself how to sanitize user input strings. I moved that functionality to the Util class which I import up top. You probably figured it out already, but if you didn’t this is essentially the folder structure you will need to have in your webroot directory:

croppercapture97.jpg

The rest of it should be straightforward. For example, let’s say you access this page with the following URI:

http://example.com/?module=user&action=view

This will trigger our file to try to locate the file user.php in the sub-folder controllers and import it. Then it will assume that the file contains a class user and will attempt to initialize it. Note that I did this in PHP4 so I’m using the old style constructors. You can easily modify it for PHP5. Finally, it will check if the newly created instance contains the method view and will attempt to execute it.

The controller class would then initialize a model class which would query the DB for user information, do whatever processing needs to be done and then pull in a View class which would deal with the displaying of the data on the page. It would probably utilize some templating scheme.

I’d actually implement a base class (let’s name it DefaultController) which would be the parent for all the other controller classes. In it I would implement all the basic CRUD functions in the most generic way possible. This way, when you decide to add a new controller to your project you can simply create an empty class stub which extends DefaultController and still have some functionality there. A very simplistic controller class would look something like this:

class DefaultController
{
  var $model;
  var $view;
 
  function DefaultController()
  {
    // find out the name of this module so that we can apply it in other places
    $module = substr(get_class($this), 0, strpos(get_class($this), "controller"));
 
    $model_name = $module."Model";
    $view_name = $module."View";
 
    include "models/$model_name.php";
    include "views/$view_name.php";
 
    $this->model = new $model_name();
    $this->view = new $view_name();
 
  }
 
  function read($args)
  {
    if(empty($_GET["id"]))
        $this->idError();
 
    $id = Util::sanitize($_GET["id"]);
    $this->model->populateFromDB($id);
    $this->view->render("read", $this->model);
  }
 
  function update($args)
  {
    if(empty($_GET["id"]))
        $this->idError();
 
 
    if(!empty($_POST))
    {
        $this->model->populate($_POST);
        $this->model->update();
    }
 
    $id = Util::sanitize($_GET["id"]);
    $this->model->populateFromDB($id);
    $this->view->render("update", $this->model);
 
  }
 
  function create($args)
  {
    if(!empty($_POST))
    {
        $this->model->populate($_POST);
        $new_id = $this->model->create();
        $this->view->render("thankYou", array("caption" => "Record Inserted", "id" => $new_id));
    }
    else
    {
        $this->view->render("create", $this->model);
    }
 
  }
 
  function delete($args)
  {
    if(empty($_POST))
    {
        if(empty($_GET["id"]))
            $this->idError();
 
        $id = Util::sanitize($_GET["id"]);
        $this->model->populateFromDB($id);
        $this->view->render("delete", $this->model);
    }
    else
    {
        $this->model->populate($_POST);
        $this->model->delete();
        $this->view->render("thankYou", array("caption" => "Record Deleted"));
    }
 
  }
 
  function idError()
  {
    die("<h1>No Record Specified</h1> <p>You need to specify a record ID to perform this action.</p>");
  }
 
}

Again, this is really minimalistic code. As you can see there is no error checking and no validation. Most of the time I’m delegating control to other classes and making even more assumptions. For example I’m assuming that a model class would have methods such as populate (which would essentially pre-populate it’s fields from an associative array passed in as an argument) and populateFromDB which would query the database and populate it by using the stored data. You can’t really make the models too generic since their structure will be based on the database table layout. You could probably try something clever - such as using an associative array instead of defining fields of all the database columns. This way you could have a fairly generic structure.

class DefaultModel
{
  var $fields;
  var $table_name;       
  var $db;     
 
  include COMMON."config.php";
  include COMMON."MyDatabase.class.php";
 
  function DefaultModel()
  {
    $this->table_name = substr(get_class($this), 0, strpos(get_class($this), "model"));        
    $this->fields = array(); // associative array
 
    // the database stuff is defined in config.php imported above	    
    $this->db = new MyDatabase(__DB_HOST__, __DB_DATABASE__, __DB_USER__, __DB_PASSWORD__);
    $this->db->dbconnect();          
  }
 
  function populateFromDB($id)
  {
    $results = $this->db->query_into_array("SELECT * FROM ".$this->table_name." WHERE id='$id'");
    $this->populate($results);
  }
 
  function populate($array)
  {
    foreach($this->fields as $key => $val)
       if(@key_exists($key, $array))
         $this->fields[$key]["value"] = $array["$key"];           
  }
 
  function insert()
  {
    $sql = "INSERT INTO ".$this->table_name." (submitted_on";
 
    foreach($this->fields as $key => $row)
      if($key != "id" and $key!='submitted_on' and $key!="last_updated_on")
        $sql .= ", $key";
 
 
 
      $sql .= ") VALUES (NOW()";
 
      foreach($this->fields as $key => $row)
        if($key != "id" and $key!='submitted_on' and $key!="last_updated_on")
          $sql .= ", '$row[value]'";
 
      $sql .= ")";
 
      $this->db->query($sql);
 
      return mysql_insert_id($this->db->getLink());
  }
 
  function update()
  {       
    $sql = "UPDATE ".$this->table_name." set last_updated_on=NOW()";
 
    foreach($this->fields as $key => $row)
      if($key != "id" and $key!='submitted_on' and $key!="last_updated_on")
        $sql .= ", $key='$row[value]'";
 
    $sql .= " where id='".$this->fields["id"]["value"]."'";
 
    $this->db->query($sql);
  }
 
  function delete()
  {    
    $this->db->query("DELETE FROM ".$this->table_name." WHERE id='".$this->fields["id"]["value"]."'");
  }
 
}

Note that I’m using a made up wrapper class instead of calling MySQL functions directly. This is just something that I did ages ago - I created a generic database class to interface with my code. Now whenever I switch database engines all I need to do is re-implement that class using appropriate syntax. Since all my SQL is going through that class I can even intercept it and correct illegal statements. For example my code might be using MySQL specific keywords, but the Postgress implementation of MyDatabase will automatically transform these queries into something that Postgress understands.

Then again, you may not want to do that. Parametrized queries may be a better idea here. They would be yet another step of abstraction. You could establish some common naming conventions then define parametrized queries in each database to follow them and simply have your wrapper class call them by name instead of actually building SQL queries.

Other than that the class is fairly generic - you will have to define the fields array on your own which can be easily done in the child class’ constructor. It’s not ActiveRecord or anything so there will be a considerable amount of work involved setting it up each time but it is serviceable.

I’m nor going to do a View class here because this post is getting crowded with code. But you get the idea - I’d use the same methodology as above, define as many generic methods as possible and then override them as needed in child classes.

I’m not sure how projects like CakePHP implement their MVC model. This is just an example of how I would go about developing one if I had to. It is probably very simplistic and unsophisticated compared to the other stuff available out there. But that’s sort of the point. Anyone can implement an MVC framework of sorts - for better or for worse. This one is mine. Yours may be very different but that’s ok. Constructive criticism is as always appreciated. Just remember that I pretty much pulled it out of my ass during a lunch break sort of as a proof that it is really not that complicated.

The Practical Reasons to Hate DRM

Tuesday, October 21st, 2008

I admit it - when it comes to music, I’m really a simpleton. True music buffs probably would call me “part of the problem” or something equally bad. I may hear a song on the radio, or perhaps in a commercial or in movie credits and go “oh, I like that one” which causes all the musically sophisticated people to roll their eyes in unison and/or do a facepalm and proceed to explain to me how popular music is total crap, or how that particular band sold out years ago and respectable people shun it now. It can be quite embarrassing sometimes and thus I rarely admit to liking certain songs until I’m sure that I’m not committing some unforgivable social faux pas. I usually hide my true nature as a musically inept, unsophisticated, (even barbaric) freak of nature around people I don’t know very well.

I guess due to some fatal flaw in my brain I don’t seem to be capable of picking a very narrow genre of music to worship and shun just about everything else. I mean, I’m like this with technology too - I might be opinionated, but not religious about my software. I use vim, emacs, eclipse and visual studio - whichever seems to be the best tool for a job at a given time. That’s how I view music too - I sample from different genres and usually find something easy on the ears in each one. Apparently this is a shameful habit which is frowned upon by civilized people. Apparently if you know what music someone listens too, you can make all sorts of judgments about their personality. Personally, I’d never judge people on something like their taste in music or, I don’t know, the browser they use, but I digress.

Because of this strange quirk in my musical sense, I get hopelessly perplexed every time someone asks me what music do I listen to. I honestly do not know what to say. You’d think I’d have a stock answer for this by now, but I don’t. So usually before I try to change the subject I just blurt out something like “oh, you know… I like just about everything” which sounds silly and contrived every single time. Seriously, there is just no one genre that I could pick as my favorite. This is even worse when people start talking about their favorite bands, albums, songs and artists. It’s horrible cause I don’t have any. I tend to like 2-3 particular songs per artist on average. I never really liked the ideas of albums because to me they were always a mix of 80% filler stuff that I did not care for and 20% of total win. I know that many people think differently but again - I’m a freak of nature here.

Also, I tend to identify music using the mnemonic device called “the song that goes like this” where I start humming the tune or try to sing the words (badly) and then get embarrassed and stop. Most “civilized” folks will then tell me the artist, the album, the name of the track, the year it was released the record company and etc. I usually don’t make a point to remember all of that cause it’s in the mp3 tags - right? I mean, I can look it up next time it comes up - right.

As you can imagine talking about music makes me uncomfortable, because I tend to just enjoy it rather than study and/or worship it. So whenever this conversation happens I try to steer it towards the more familiar grounds. Like, where do you get your music. Cause that opens up a whole new list of topics I actually can talk about at length like filesharing, best torrent sites, evils of DRM and etc. That’s the stuff I know and care for.

For example, I couldn’t care less who sings that song that goes “dam dam di dam”, or whether it is classified as pop, rock, hip-hop or r&b. What I really care about is whether or not it is locked up by DRM. After all that is what really affects my ability to enjoy the music. All that other stuff is just meta-info that I can look up later. Sadly, most people think the opposite. They don’t really care about DRM because:

  1. It is an acronym, and acronyms are scary things that only nerds understand
  2. It doesn’t affect them personally, because they don’t know their music has it
  3. Besides, if it helps the artists to get paid, then it can’t be bad

Time and time again I tried to explain to people why DRM is bad, but I realize now that I have been going about it the wrong way. There are really two ways to approach the subject:

  1. Theoretical way: using reason, logic and particular examples
  2. Practical: by telling people about a personal experience so that they can emphasize

Little did I know that logic and reason is the domain of the stuck up elites, and academic eggheads. Normal people hate logic because it confuses them. Worse, when you talk to them in a logical way, and ask them to use reason and common sense they feel offended. They go “who the hell does this guy think he is, telling us to be all logical and stuff”. This pisses people off and they stop listening. So I could talk till I’m blue in the face how DRM is cryptologically unsound, and draw diagrams with Bob, Alice and Eve (where Alice==Eve). I could talk about how DRM is offensive and implies we customers are all criminals. But all of that just aggravates the issue and does not impart any understanding on the civilized folks who like to buy their music at iTunez.

It seems that it is much more effective to appeal to these people on an emphatic emotional level and tell them a story of how you lost your music collection due to DRM.

steal_this_comic.png
comic © xkcd

Unfortunately (or fortunately for me) I was smart enough to avoid DRM all my life so I have no personal horror stories to share. Sad but true. Do you have any stories I could use? If you do, please share them below. I’d totally appreciate it, as it would help me to put a personal spin on these stories.

Common argument I get from DRM apologists is naturally the “Apple wouldn’t do me that way” argument. The reasoning here is that since Apple is not going anywhere anytime soon your music is safe. At any time you can go and de-authorize your old devices and authorize new ones. Likelihood of Apple going out of business, even in the shitty economy we have now is almost infinitesimal. And it’s not like they could just switch of iTunes since it is one of their biggest sources of income.

I agree - they are not going anywhere, and they are not going to just switch of iTunes. It doesn’t mean they are not going to fuck you over one day once iTunes ceases to be profitable. It may happen - someone will one day come up with a better service, snatch their market share and then all iTunes users will get stuck with collections forever bound to 5 old machines they no longer use. After all, this is precisely what Microsoft, Yahoo and Wallmart have done recently. All were huge corporations with tons of money and assets. No one expected them to go out of business. But at some point their DRM offering stopped being profitable (or perhaps it never was but they got tired of dumping money into it) and they pulled the plug.

When your music collection becomes obsolete it won’t be because some catastrophic bankruptcy, hostile takeover of the century, a nuclear war breaking out or asteroid hitting the earth. It will be because some CEO making an executive decision to phase it out to save money, improve the bottom line of the company or simply to make you re-buy all your songs from their new service. Sad thing is that I’m probably preaching to the choir here. Normal people who buy DRM’d music don’t read my blog because… Well, because they don’t read as a rule. No, I’m serious.

Do this experiment - go up to people you know and ask them if they read any good books lately. More than a half the time you going to get an answer among the lines of “I don’t really have time to read books”. The rest of the people will either tell you about some silly self-help book, a pulpy romance/action novel paperback they picked up at Wallmart counter for $1.50 or the bible. I’m not saying there is anything wrong with reading the bible - it’s just, you know - nice to branch out sometimes and read other types of literature too.

I was sort of shocked when I started doing that. Over time I got used to the idea that majority of the population is only semi-literate and that for most people a page of text without any pictures is scary and boring. It is quite terrifying but then again when you watch the news and it sort of makes sense. You see the half coherent, illogical drivel and nonsense all around and then you remember that after all these are the very same people who don’t read, don’t learn and don’t want to know shit. And then you start to wonder what kind of music do these idiots on TV listen to - cause then you could like totally judge them harsher!

Vim LaTex

Monday, October 20th, 2008

I noticed that in the past I produced several posts about combining LaTex and Emacs. While I do like Emacs and respect it’s formidable power I do not consider myself an Emacs user. Most of my day-to-day work is done in Vim which brings different kind of editing power to the table. Emacs is a lisp based framework for building text editing applications - fully programmable, easily customizable and almost endlessly extensible. The power of Emacs comes from what it can do. Vim’s power stems from what it does - and that is providing very powerful and yet simple modal text editing environment. I wanted to say intuitive, but yeah - that would be a lie. Vim is powerful because it allows you to accomplish just about anything in 3-4 keystrokes by chaining and combining simple commands.

Using Vim makes editing text much simpler and easier. It removes a lot of key-presses and movements. Let me give you an example - in a typical coding session you may want to copy the current line, and paste it below. Assuming your cursor is in the middle of the line how would you go about accomplishing it? Typically you would do:

  1. Hit Home to skip to the beginning of the line
  2. Hold shift and hit End to highlight the line
  3. Press Ctrl+C to copy the line
  4. Hit End again to put the cursor at the end of the line
  5. Hit Enter to insert a new line
  6. Press Ctrl+V to paste the line

How do you do it in Vim?

  1. Press the following keys in a sequence: yyp

That’s it. You want to paste the line 3 times? Do yy3p. This is the power you get when you use Vim. Of course die-hard emacs fanboys will remind me that one could always use Emacs’ VIP mode which emulates vi’s modal editing features. And they would be absolutely right. As I said, Emacs is a framework for building editors rather than an editor. So when you launch it in VIP mode you are really using Vi with the lisp powerhouse underneath it.

In theory you could combine the neat features of AUCTex on Emacs and the power the VIP mode gives you to get the best of both worlds. But if you don’t need these features - if you are a Vim purist or if you just need a simple modal text editor I have a nice alternative for you. It’s called VimLaTex.

vim-latex.gif

While it does not have the nice rendering features of AUCTex, VimLaTex is a must-have if you are planning to use Vim to edit LaTex files. The package itself is tiny - you just drop few hundred KB into your .vim directory and add few lines to your .vimrc.

The suite will add bunch of useful menus to your toolbar:

croppercapture100.jpg

These menus are your standard IDE like features - for example options for inserting packages, or snippets of code for special environments and etc.. A lot of the entries come with predefined key-bindings which make your life much easier. For example:

  1. To compile your file do: \ll
  2. To view compiled file do: \lv

You can set the preferred format for both options above by invoking :TTarget. It works like a charm both on Windows and Linux when I tried it.

VimLaTex also uses an interesting concept of placeholders. Whenever you use it to generate snippet of code, it will put funny looking character sequences inside of it. They may look silly until you realize how useful they are. For example let’s say you want to insert a figure:

\begin{figure}[h]
    \centerline{\psfig{figure=«eps file»}}
    \caption{«caption text»}
    \label{fig:«label»}
\end{figure}«»

The placeholders are there to make your life easier. When you press Ctrl+J vim will jump to the first «» delimited sequence and select it. This way you can just type over it. Press Ctrl+J again (while still in insert mode) and you will jump to the next one. How awesome is that?

If you are a Vim lover who also happens to use LaTex or a LaTex user who loves Vim definitely check this one out.