vim column editing

Vim: Column editing

When editing code you pretty often want to edit multiple lines at once. Say you have this text:


And want to insert something before each name. Here is what you do:

  • Place the cursor on M
  • Press ctrl-V
  • Extend the selection to all lines pressing j
  • Press I (that’s shift-i) and start typing “Hello “, you will only see text on the first line
  • Hit ESC, and the text is on all lines

Like this

Hello Mia
Hello John
Hello Claus

Now say you’ve made some text and want to append something to each line. Here is what you do:

  • Place the cursor after the a
  • Press ctrl-V
  • Extend the selection to all lines pressing j
  • Press $ to extend it to the end of line
  • Press A (that’s shift-a) and start typing “is at home.”, you will only see text on the first line.
  • Hit ESC, and the text is on all lines
Mia is at home.
John is at home.
Claus is at home.

That is pretty neat.

Vimmynights Color Scheme

Building your vim for sweeet editing

My goal was to get a modern vim, that would help me edit ruby and rails projects along with some php and java coding as well. I’m a huge fan of the Jetbrains suite of tools, but lately the amount of resources required is spiking my top. Soo alternatives are dear – I’ve been an active vim user for the last 12 years, so that’s one of my first choices. Back to basics in a sort of way. First thing is to get macvim, it’s a vim built for osx, and it’s compiled with ruby support too.

Using a modern vim, you want to install vim-pathogen, a brilliant plugin by Tim Pope that loads bundles for you. You more or less don’t have to bloat your .vim directory every time you want to install something. A really great start for using pathogen is this article on

From here on I created a repository on git for my .vim directory. The layout is as follows

Enter the bundles, I’ve included quite a few useful bundles, that will tune your vim into a great ide. Here are the bundles.

  • Ack – An integrated way of using grep -R inside your vim.
  • Ctrl-p – Similar to the command-t option in textmate. Granted a command-t extension does exist, but it requires native compiling, so I opted out for ctrl-p instead, which works out of the box.
  • Neocomplcache – A more flexible keyword completion, than the builtin vim.
  • Tlib – A requirement by snipmate and supertab.
  • Addon-mv-utils – A requirement by snipmate and supertab.
  • Snipmate – Allows you to tab complete code snippets, like textmate.
  • Commentary – Will let you comment blocks of code, easily.
  • Blockle – A way of effective change between ruby do/end and braces {}.
  • Bundler – Integrates bundler into vim.
  • Endwise – Smart addition of end after if, do, def and lots of other keywords.
  • Fugitive – Great integration of git into vim, complements the vim-git bundle
  • Git – Easier integration of git into vim, you’ll want to supplement with fugitive too.
  • Markdown – Markdown syntax.
  • Matchit – Easily find matching if else endif keywords.
  • Pasta – Paste into vim adjusted to destination context.
  • Pathogen – The essential plugin for loading plugins from the bundle directory.
  • Rails – Well it’s pretty obvious what this plugin does, it gives you some rails candy
  • Ruby – Adds some nice candy to vim for editing ruby files.
  • Ruby-refactoring – Ruby refactoring tools
  • Ruby-test – Lets you run tests under the cursor with <Leader>-t (<Leader> is default mapped to ‘\’).
  • Rvm – Use RVM under vim, change ruby version easily. See the FAQ if you’re running zsh.
  • Shoulda – Adds some candy to using shoulda in ruby.
  • Supertab – Will give your a dropdown tab completion list of keywords you can use.
  • Surround – Will give you an easy way to surround text with tags, brackets, parentheses, and more
  • Textobj-rubyblock – Select ruby blocks with ar and ir.
  • Vimmynights – My own colorscheme, it is based on the darkblue scheme.

Theese are all included in the repository as submodules, linking to the original github projects. So you can run to get the latest version.

Now you’re set for running a smooth vim. With multiple tabs, a nice statusbar, fast file finding with ctrl-p, and git integration.

I’ve included a list of my mostly used commands here. A lot of shortcuts just sits in the fingers.

Happy vimming – Of course I’ll be happy to hear about your setup and shortcuts.

A working MAMP Stack

Usually I do my php development in a vmware instance of ubuntu. However, since vmware eats a sh*tload of resources, and my macbook only carries 4gb, I wanted to run it natively.

Enter macports – an alternative to compiling and building everything by hand. I’ve been messing with it for some time now – I still haven’t really found a way to enjoy it though. Anyways here’s a little gist that will install a MAMP stack for you.

It load everything into /opt/local – so thats where you should look for things. Let’s just take a look at what’s being installed.

  • apache2 – well that goes without saying
  • php5 – that too is pretty straight forward
  • mysql5-server – I’ve had some different suggestions here. Some suggests mysql5 +server instead
  • php5-mysql – will install the php5 extension mysqli, which is needed to get phpmyadmin running, which is my preferred mysql admin tool.
  • php5-mcrypt – is needed to put a cork in phpmyadmin’s warning on the frontpage

That sums it up for packages. Next step is to get things working. The guys at macport apparently think things shouldn’t be standard, so mysqld.sock isn’t placed in /tmp but in /opt/local…

It took me digging and poking until I found out what was wrong. But of course it has to know where to connect. Be sure to remember to run mysql_secure_installation. After this you should restart apache and it should spin nicely.

Oh yeah – I’ve made a couple of handy aliases.

Enjoy :-) – oh btw – feedback is always welcome, also if you’ve found a better way of doing this!

Update-> You might like this post about taking the pain out of macports


Grails and Jenkins – a run down of how to get grails 2.0 to play nice with maven

In this time of writing grails-maven 2.0.x haven’t been publicized on any maven repository yet. This makes it increasingly difficult to build grails 2.0 projects using maven. What to do?

Quite simple really – clone into the grails-maven repos and build it yourself. You may need to disable the signing of the plugin. Once that is done – just release it to your own repos.

The description in the grails documentation, which will only work for 1.3.x – you need to change the version to 2.0.x – where x is the current release of grails.

Once you’ve run grails:create-pom, you’re pretty much set. Well – that’s not the whole truth. There are some quirks.

First quirk is that the maven release plugin didn’t play nice with the grails command line tool. When you release your maven project, the pom version is incremented, but the app.version of isn’t. This was solved when I closed issue #10 of grails-maven.

Next quirk is testing – grails runs its own test suites, so you need to disable maven-surefire-plugin.

Next quirk is getting the right version into your scm. Here I had to apply grails:set-version and scm:checkin as a both a postgoal and completion goal. Why is that? Replease:prepare checks in pom.xml to your scm. But it doesn’t know anything about or grails. This is how you educate your maven release plugin.

Note that you need maven-scm-plugin >= 1.6 if you want it to play with git.

Right now I’m messing with my ruby stack, trying to get a staging environment running. Now I would like it to look like a production environment. With the same scalability. I’m targeting ruby 1.9.2 and rails 3.

From what I can read it’s
mysql – in a master/slave setup with replication, where all writes are done to the master and reads are done on individual nodes. I was planning on deploying it on an ubunto 10 lts. What do you use? Rvm? I mean the apt-get packages are way outdated. I’ve applied capistrano to my project, so everything should run smoothly.

Lets share setup here. Whats your take on it?

Dream no small dreams. They have no power to stir the souls of men.

— Victor Hugo

Oc4j servers are still in production, and thus must be dealt with in regard of continuous integration and deployment. Normally you could use the admin.jar or admin_client.jar to deploy your application with. This isn’t possible if the target is an enterprise server with multiple oc4j instances. In that case you need to wield dcmctl – an oracle tool.

In the following example I have hudson running on a linux box, the same is the oc4j instance. First of all I create a certificate to facilitate ssh access to the server. I copy the public key to the account used to access the oc4j server. The certificate is placed in the maven project under src/main/cert.

Using the

You will need to add the full path to the script in hudson when defining the post job. Like /opt/hudson/workspace//ear/

Add the argument hudson to the script and it will play nice. Since hudson will run the script in the root of the workspace.

I am reading David J. Andersons book Kanban - Successful Evolutionary Change for Your Technology Business.

I noted some of the key aspects in his recommendations in securing quality in software.

Both agile development and traditional aproaches to quality have merit.
TDD provides a great lift in quality, but so does unit testing after functional coding.

Code inspections improve quality.
Do it often and in small batches. Fx. 30 minutes every day.

Collaborative analysis and design improve quality.
Ask the team to work together when analyzing problems and designing solutions, the quality will be higher. Scott Ambler calls this Agile Modeling.

The use of design patterns improves quality.
Of course this is common sense, however it will still help people recognize what is being done and help remove design defects.

The use of modern development tools improves quality.
Modern tools will help detect common errors, through inspections and static and dynamic code analysis.

I use Kanban at work – it is highly recommended!