Howto disable syntax highlighting in Vimdiff

X > Y >> Z

Where X is the population of developers who read this blog, Y is those that use Vim and Z is those that use vimdiff regularly. I guess this post will only be useful to a tiny minority of my readers, but to them it might be the best thing they’ve read all year. (Well, it is 2016, right? It’s been a weird year.)

Vimdiff allows you to open two files in Vim and side by side compare them, pushing changes from one file to another. I’ve been using it as long as I’ve been working on b2/WordPress and even before then too. It’s supremely useful.


Over the years I’ve used many different terminals, with various settings and colour configurations. My vim settings change over time too as I move from one machine to another. Sometimes the colours look ok in Vimdiff, sometimes they don’t. Sometimes the colours are ok for one file type while conflicting in others.
The problem is that Vimdiff has it’s own colours it uses to show what parts of the files are different or missing. Those colours can sometimes hide actual text in the files. I find myself highlighting those lines with SHIFT-V to see the text.

I could pick a different colour scheme but then there’s no guarantee that a different part of text will be hidden by Vimdiff’s colour scheme. The easiest way to fix this is by disabling syntax highlighting completely when in Vimdiff and you do it like this. Open up your ~/.vimrc and add these lines:

if &diff
syntax off

With that in there Vimdiff goes from looking like this to the simplified appearance below.



Ironically, the theme I’m currently using in Vim in the screenshots above isn’t that problematic, but here are two screenshots that show the problem from another machine. In the second screenshot I have highlighted (with SHIFT-V) the line with the function name in the left side. As you can see, the text “function” is still invisible in the right side of the screenshot.

Vimdiff Vimdiff

If you don’t want to edit your .vimrc for whatever reason you can also manually do :set syntax=off from within the editor but you’ll have to do that for each of your files.

All the code above is GPLed WordPress code. Thanks to user hildred on Stackexchange for that one. Hopefully someone else will find this useful.

Find Duplicate Files in MacOS

In the past I’ve used FSLint or even some BASH magic to find duplicate files but I have a huge archive of photos and videos, some of which were renamed during import, and some were accidentally imported more than once, or moved about. It’s somewhat chaotic


So I was very glad to find dupeGuru! It’s a powerful application for MacsOS and Linux that allows you to scan one directory or more for duplicate files. It can search by content, or match filenames. It has modes for music and pictures, but I’ve stuck with the standard search as I want to only look for files that are 100% the same.

It found several gigabytes of duplicates for me, and it has a useful feature that symlinks duplicates to their parent. Even though the dupes still exist, they’re not taking up any space.

The developer is looking for help to maintain the project. You can find more information and source code too on the dupeGuru GH page.

For the love of Vim

A contributor to the Hackaday blog has a good old rant about how Vim is superior to Emacs. 

Of course it is (a silly argument), but he manages to give a quick overview of Vim and describes a few neat tricks beginners will find useful!

And after writing the text above I realised that there are going to be people reading this who have absolutely no idea what either Vim or Emacs are! They’re text editors, and they have passionate users. Yeah, that includes me too. 🙂

Throwing away old clothes

I hold on to things for way too long! The last four weeks have felt like a continuous purging of old “stuff” with several trips to the Kinsale Road site (BTW, it was a bit creepy to see a guy rummaging around in the electrical bins as soon as I dumped stuff in them, he could at least have waited until I left), and there’s still more to go. At least now I can walk around the attic without tripping over random objects.

set -o vi FTW

The Bash command line can be edited using the cursor keys but for the real power user you need to enable Vi mode:

$ set -o vi

Or add it to one of your Bash startup files.

Now, instead of the slow interactive editing you’ll get the command and insert mode of Vi! Users of Vi or Vim will feel right at home. You start in insert mode by default so it feels the same as before. You can type new text, move left and right with the cursor keys and delete text but press ESC and you can do all the things Vi command mode allows you to do.

Check out this extensive cheat sheet with examples or jump directly to the ascii version here!

Some tips to make Mac OS X Finder easier to use

Making the switch from Windows or Linux to Mac OS X is not without pain. The extra CMD key plays havoc with muscle memory, and the “Windows Explorer” of Mac OS X, Finder, is quite a different beast to what you might be used to in the Windows or Linux worlds.

About two weeks ago I decided to make the switch again to Mac OS X and I lamented the difficulty in using Finder to do simple tasks. I’m still not 100% happy with Mac OS X it but the tips on the following pages made things easier:

  • Home and End keys work on a line, not a document, silly.
  • Disable natural scrolling.
  • Switch CMD and ALT if you’re using a PC keyboard. I have a lovely split keyboard but the default configuration hurt my fingers.
  • Change the keyboard layout if your keyboard doesn’t work the way you’re used to. I still haven’t got this set up exactly as I want it to. In my terminal some keys act differently I think but I haven’t set aside time to work out which. I need to swap ” (shift-2) with @ (key to the top/left of right-shift). My muscle memory gets them mixed up all the time.
  • Automount SMB drives automatically. I haven’t been able to get the fstab method to work yet because my password has spaces but the “User Login” one works well enough.
  • Change Finder search so it searches the current directory by default.
  • Type the path into Finder.
  • 9 tips to improve Finder.
  • Sorting and arranging in Finder.
  • Right click on the directory name in Finder and show a dropdown of the path to that directory.
  • Install Mac Ports to get a working copy of Rsync and a better ls that lets me put parameters after the filename.

There are still oddities. When Mac OS X mounts an SMB share it does so with permissions that only allows the current user to edit files in the share. That’s perfectly understandable but it messes things up for Rsync when I’m syncing directories with a remote host. I’ve had to resort to using the “–size-only” parameter of Rsync so it won’t attempt to sync every file each time. I need to figure out if that can be fixed somehow.

I’ll update this post from time to time as I come across more oddities.

PHP Notice: Undefined variable: _SERVER in ..

I upgraded Linux on this server a while back and in the course of that upgrade PHP was upgraded too, to version 5.5.9.

Since I had a modified php.ini it asked me to check over any new options. There were a few but I fixed anything that looked like it might break things. I saved the php.ini and let the upgrade go on.

Clearing up bugs

Some time later I saw odd notices in the PHP error log. Usually it referred to wp-comments-post.php but files outside of WordPress raised the warning too:

PHP Notice: Undefined variable: _SERVER in ..

It turns out the fix is rather easy. Jacques Marneweck on his blog posted a solution. Simply switch off “auto_globals_jit” in your php.ini and restart Apache (if required).

From the PHP manual entry for auto_globals_jit:

When enabled, the SERVER and ENV variables are created when they’re first used (Just In Time) instead of when the script starts. If these variables are not used within a script, having this directive on will result in a performance gain.

The PHP directives register_globals, register_long_arrays, and register_argc_argv must be disabled for this directive to have any affect. Since PHP 5.1.3 it is not necessary to have register_argc_argv disabled.

A bug

It looks like the bug is ancient although I’m not using APC, and the JIT compiler can be fooled if you access the super globals like _SERVER through variable variables. Sneaky!

The default for auto_globals_jit is “On” so next time you upgrade PHP keep an eye on the error log.

Go on back to Linux will ya!

I’m back in the world of Linux on my desktop machine again. Well, mostly.


Desktop Linux has been a “thing” for so long now it’s a cliche but I used it as such for well over a decade and it wasn’t until I was lured away by the shiny games offered by Steam that I installed Windows on a machine. Well, time passes and Linux support for games improves. Many fabulous indie games now have Linux versions. I’m glad I can play Kerbal Space Program, Prison Architect, Papers Please, Luftrausers and more without booting into Windows!

I’m mostly back in the Linux fold. There are still apps I use regularly that don’t work in Linux. Lightroom and Ynab are the main offenders. Both run to a certain degree in Wine, and the latter runs quite well, but I’m afraid I’ll be cheating on Linux. I have a Macbook laptop here too that runs Lightroom just fine. My 1TB of photos (and some videos) resides on an external drive in my Linux box but with the catalog copied over to the laptop, Lightroom runs reasonably well.

It hasn’t been plain sailing either. I corrupted one external drive when I let Ubuntu try to resize and partition it. It was probably my own fault for not defragging it first. I thought I had lost everything as Windows couldn’t see anything on it. Luckily, after booting into Linux on a USB flash drive I could see everything I wanted copied off.

I have an Nvidia graphics card and I noticed ugly tearing in web pages in Chrome. I found a page that suggested enabling “Override software rendering list” in chrome://flags/ but while that worked it also stopped my cursor changing when hovering over links and hover actions on menus didn’t register. Luckily I found this thread that suggested disabling the “Composite” module in the X server. (That’s the program that displays things in Unix)
I couldn’t find the file, /etc/X11/xorg.conf in my Ubuntu 14.04 install but I found Composite was mentioned in /etc/compizconfig/unity.ini and when I removed it, restarted X and logged in again Chrome scrolled like melted butter on hot scones. (yum)

Unity is a lot nicer than I remember it, or maybe it’s because I have a better machine now. I have no doubt I’ll get bored of it and start installing Gnome, KDE, Xfce and everything else to play with, before coming back to it again. I fondly remember the days of Windowmaker.

So, Linux is back.

Linux: when the /boot is all full

I tried to install fdupes this morning on my Ubuntu Linux server but the install bombed out with this error, followed by a string of other warnings before dpkg rolled back everything:

gzip: stdout: No space left on device

What? I’d installed a 500GB drive in that machine recently. It was /boot/. A quick look in there revealed a number of old Linux kernels but luckily there’s an easy way to get rid of them.

This showed me a list of all my installed kernels, and “uname” told me the name of the current kernel which I shouldn’t remove.

dpkg -l linux-image-\* | grep ^ii

Removing them was as easy as this:

apt-get purge linux-image-3.8.0-29-generic linux-image-3.8.0-31-generic linux-image-3.8.0-32-generic linux-image-3.8.0-33-generic linux-image-3.8.0-34-generic linux-image-3.8.0-35-generic linux-image-3.8.0-36-generic

When I finally installed fdupes it kindly removed all the kernel headers saving me a further 505MB of space. I’m pretty sure this is the first time /boot has filled up on me.

fdupes is pretty nice too. It finds duplicate files by comparing file sizes first and then does MD5 checks.