Archive for November 2016

Good review of AI research and where it might lead

If you’re interested in getting an overview of AI research and possible future trends check out Building Machines That Learn And Think Like People and the previous post on the same blog Artificial Intelligence And Life In 2030.

In fact even if you’re not fussed on AI the whole blog is great if you’re into general CS research. The author, Adrian, takes a new research paper every weekday morning and reviews it.

Sort yourself out! Vim sort

Quick tip

Espresso style tip today. If you have a list, you can easily sort it using Vim using :sort

Copy this into Vim and try it for yourself:
1. list
5. order
2. should
4. in
3. be

It works particularly well with visual mode. Enter visual mode (V) and select the lines above then type :sort

Lovely.

Find Yourself In Vim

Moving on

So, if you’ve used Vim a bit then “hjkl” is hopefully second nature. Moving by objects (w/W/e/etc.) makes things easier but it still lacks finesse. One of the best tools for moving in Vim is f and its variations. When we use f we’re doing a find for a single character on the current line. This allows us to jump straight to (or very close to) the point we next need to be at without using the mouse.

Example

As always, the best way to learn is to see it. In the below sentence, my cursor is on the first character on the line in normal mode (I):
It was the best of times, it was the worst of times.
Now if I wanted to jump to the word best, I could press w a few times. However, fb will find the b with way less effort. As usual, it’s mnemonic so it doesn’t require extra thought to think of the command. It just works:
It was the best of times, it was the worst of times.

F, t, T, “,” and “;”

To make finding extra powerful, here are a few bonus commands:
F – searches backwards on a line.
t – same as lower case f except it stops a character early.
T – same as T except backwards on a line.
, – find next occurrence of character (can repeat until there’s no more).
; – same as “,” except backwards on a line.

Scrabble grandmaster

Ever played Scrabble? If you have then this last tip will make your life a whole lot easier. Luckily, it’s still easy to remember if you haven’t played. Try the above commands in a vim session for a few minutes. Very quickly, you’ll see that it can sometimes be a bit tricky to nail the exact character you’re after and you might find yourself resorting to “hjkl” to get there. One way to solve this is to try to mentally note which “high value” letters are near the place you’re trying to jump to. In Scrabble these letters are the ones with higher points but in English we just mean the letters we see less often (z, x, b, y, etc.). Let me show you an example to get my point across:

Insanity: doing the same thing over and over again and axpecting different results.

Oops! I’ve made a typo. Instead of expecting I’ve written axpecting! What a numpty. My first instinct might be to use f to jump to a right? Notice that high value x right beside it though? Instead of doing 5 or 6 jumps, I can just do one. fx followed by i and backspace once to correct my mistake.

Insanity: doing the same thing over and over again and expecting different results.

Keep an eye out for those high value letters. Don’t forget that capital letters and punctuation can be found too and might be higher value.