Column (block) insert/delete on VIM

I know this is not new information at all, but every time I have to insert some text at some specific index for a group of consecutive strings I have to google something like “column insert VIM” (surprisingly, the title of this post) and search through the first 5 results for the correct solution. Well, the one I happen to understand, anyway…

So, here’s how it’s done:

  1. move the cursor to the uppermost character (if you’re selecting lines the way down, bottom if you’re going up) before which you want to insert text
  2. enter Visual Block Mode by pressing Ctrl+v (unless you mapped the paste action to it, in which case you probably already know how to column insert)
  3. select the column using the arrow keys
  4. press Shift+i (switching into Insert Mode)
  5. type the text you want to insert (will be displayed only on the first line)
  6. press esc two times
  7. ?????
  8. Profit!

In case you want to delete text, follow steps 1 through 3 and simply select all text you wish to delete, then press x and you’re done!

Mounting a CD/DVD image on a VirtualBox 4.0+ VM running headless

VBoxManage is a great tool, but it’s really too powerful to have such a weakly organized --help screen.

Plus, recent VirtualBox versions have a subtly different syntax for common operations, and you may find several ways to perform a basic task depending on the version the post you find is talking about.

So, in order to mount a CD or DVD image while your VM is running (headless or not it doesn’t really matter… obviously if it is headless you have no choice) you have to type the following:

VBoxManage storageattach "your VM name" --storagectl 'Controller IDE' --port 1 --device 0 --type dvddrive --medium /path/to/your/iso/image.iso

Remember to escape your VM name in case it has whitespaces! Of course you may use uuids instead of names and you may attach hdds, fdds and specify whatever option you want. Just type

VBoxManage storageattach

by itself to see the specific help with all the info you need.

Playing Sim City 4 on Ubuntu on a large display

I’ve always been a huge fan of the Sim City saga, a little less so for the Sims spin-offs, but I enjoyed them anyway. After some years without playing, and after catching some colleagues playing micropolis, I felt it was the right time to see if my city planner skills are still intact. Micropolis is soooo 1990, so I took a look at LinCity, which is kinda good, but still looks to me like a copy of SimCity 2000, and being SimCity 3000 the last I owned I decided to go for SimCity 4, as it really costs nothing on eBay.

A question that bothered me was: “will it run on Ubuntu?”. Well, maybe “bothered” is a little too strong a word to describe the 2 seconds that took me to google “sim city 4 ubuntu” and discover that yes, it can run on Ubuntu (almost) flawlessly. You can also follow the instructions on that site to install the game (basically you create a new drive in wine pointing to the folder you mount the CD on, follow the standard setup procedure and download the patch from EA site).

Still, two issues arose:

  1. it looks like the game has stability issues on multicore architectures
  2. the game does not detect my current display resolution (1920×1080), and does not list it among the available ones

The first is actually a no-brainer, as it is enough to feed wine a -CPUCount:1 option to force it to use one of your cores.

The second is just quite as easy, cause all it takes to set your custom resolution (can be almost any) is to specify a -CustomResolution:enabled -r1920x1080x32 option for the game executable. Having to pass those arguments to SimCity4.exe and not to wine itself, remember to escape them properly.

In the end, what I did is just create a shortcut on my applications menu like this:

wine /home/myUserName/.wine/dosdevices/c\:/Program\ Files/Maxis/SimCity\ 4\ Deluxe/Apps/SimCity\ 4.exe -CPUCount:1 "-CustomResolution:enabled" "-r1920x1080x32C"

Where of course 1920×1080 can be set to whatever resolution you use. Thanks for the advice!

Disable annoying show-desktop effect on Compiz after uninstalling Macbuntu

Some weeks ago I decided to give Macbuntu a try just to see how OS-X-ey my Ubuntu may look. Turns out it can really look pretty much like a Mac, with all of its fancy animations on every window maximize/minimize event, side-by-side windows display, mouse-sensible corners and everything.

Being the geek that I’m told I am though, I grew tired of all the swishes and fsshhes pretty quickly, so I decided to remove them altogether. Bad news is, you can’t just run as they tell you to.

  • First of all, I didn’t have any script on my Macbuntu folder. I didn’t want to download the whole 42MB archive from here, so I googled a little more and found this script on this (Italian) blog.
  • After running the script, Macbuntu was gone but.. so were all my themes!
  • I reinstalled gnome-themes-selected, gnome-themes-ubuntu and light-themes (cause I use Ambiance) packages using Synaptic and restarted X. My themes were back again, but still the show-desktop animation à la Mac OS was enabled, with every open window flailing its way (as in wacky-waving-inflatable-arm-flailing-tube-men) towards the bottom-left corner of the screen as soon as my mouse cursor touches it.
  • After some more googling, I discovered that the effect (found in compiz-fusion-plugins-extras) is called “magic lamp”, and can be disabled by going into System/Preferences/CompizConfig Settings Manager/Effects/Animations Plus and removing the entry for Magic Lamp from every event it’s attached to.

Now my beautiful, clean Gnome desktop is back! 🙂

BTW, I use an Emerald theme called “The Empire strikes back” which is really cool. You can find it here.

Hello world

This is my first post 🙂

My new year’s resolution to start a blog had to wait for 4 months…  But here we are! Let’s see how many posts will it take to make me give up, my bet is around 20 or so.

The main subject of this blog is programming, but other topics will hopefully come up! Stay tuned! (sounds like a memo or something..)