Column mode in GVIM using the Alt key

Whilst writing my last post regarding column mode in Putty, I got thinking about which other apps might use this convention (alt key and mouse) for column mode. The first (and in fairness only) app I tried was Vim (the GVIM flavour).

I love Vim. Rarely does a week go by that I don’t learn some new trick with Vim. However by far my biggest gripe regarding Vim compared to my previous editor of choice (UltraEdit) is it’s column mode.

Generally speaking – unlike much of Vim (arguably) – column mode isn’t very intuitive to use. It’s a big enough pain that I simply don’t use it (I’ve tried to get in the habit on several occasions now). However, with the help of the alt key (as seen in the Putty post [LINK]), it’s slightly easier (at least as far as I’m concerned).

Unlike with Putty where I’m using it to select and copy text, with GVIM I’m using it to insert text.

How to use Column Mode in GVIM using the Alt Key

Note that this example is for GVIM only. Not the terminal version of Vim.

  • Place the cursor:
    • On the first line that you wish to insert text to
    • In the column that you wish to insert your text
  • Now hold down the alt key and place the cursor:
    • On the last line that you wish to insert text to
    • In the column that you wish to insert your text.
  • This should ‘draw’ a line from your top point to the bottom (see below)

  • Start typing the text you wish to insert. Initially this will appear only on the first line (I find this to be misleading, and it’s one of the reasons I dislike Vim’s column mode)

  • Now press escape. You should now see the remaining columns update:

Column/Block Mode in Putty

I find applications that have column mode extremely useful (eg. UltraEdit).

It wasn’t until I was looking over someone’s shoulder whilst they were working that I realised Putty has a column mode (albeit read only), and it’s elegantly implemented.

Using Column Mode in Putty

It’s really quite simple. Barely worthy of the bullet points in fact:

  • When you have Putty open, hold down the alt key and then using the mouse drag the area of the screen you wish to select.
  • With its default settings, Putty will then copy what you’ve selected to the clipboard.

When could this be useful?

I’ve only recently discovered it, so excuse my list of 1, but I find it useful when selecting a list of file names from an ‘ls –l’ command:

Note: I tried to get a screenshot of it in action. Unfortunately it doesn’t capture the fact you’ve highlighted certain text. So please use your imagination and pretend the items in the blue box above have been highlighted/selected.

Helpfully, it trims the trailing spaces when you then go to insert the clipboard contents into another application.

Of course, there are other ways to achieve this (eg. ls –1 will return just the filenames).

Still, it’s a handy trick to know.