Crazy Escape Key Mappings

One of my colleagues asked me about whether jk is a good mapping for escape. I've always used <Esc> for leaving Insert mode, but I don't think it's unreasonable to want to use a key combination that's easier to press.

If you want to try jk, then you need to imap it:

:imap jk <Esc>

Avoid the escape key on the Vim Wiki has lots more examples, including <Space> for entering Insert mode.

Read More →

A Vim-inspired Mac Window Manager

In Mac OS X, window management is pretty horrible. If you switch between a laptop and external monitor display, then the windows seem to get squashed and you have to manually resize them. Also, maximise is purely advisory and rarely does what you might expect. I just pressed maximise in Finder and it made the window thinner, so who knows how it's supposed to work.

That means power users install "window managers". They're not window managers like the X11 type, they're utilities for making window positioning more bearable. I use Spectacle so I can quickly maximise iTerm, and occasionally fill two windows across the left and right portions of the screen. Spectacle is open source, and it's customisable as well.

Spectacle

Read More →

Script Roundup: a_pair

a_pair

a_pair by Colin Cai combines the brackets {}, [], and () into a text object called ap. That means if you've got sets of nested brackets you can operate on multiple levels at once.

I thought this might be useful if you're working with JSON documents, where you can often find arrays nested inside objects.

Read More →

Flat Vim Icons

Flat Vim icons

When you've carefully curated your desktop wallpaper, terminal colours, and system icons, it's a little bit annoying when one of your icons stands out. So if your gVim or MacVim icon looks too retro, then just switch to terminal Vim for everything!

Or, try one of these new flat icon designs:

Read More →

Vim and TypeScript

TypeScript has a rich type system that can be used by compilers and IDEs to infer things about method and object usage. If you write TypeScript in Visual Studio, then you get IntelliSense completion and hints as you work. Due to the design of the language, the hints can actually help you how to use and navigate around code.

Vim's Omni completion supports several languages, including C and JavaScript, but it can't do deeper IntelliSense-like completion and documentation.

The way people usually solve this is to run a "server" that can index your code, providing language-specific features that Vim doesn't support. Then a Vim script is used to send queries to the server. typescript-tools by Claus Reinke does exactly that, with its TypeScript server (tss).

Read More →

Script Roundup: textobj-delimited

textobj-delimited

textobj-delimited (GitHub: machakann / vim-textobj-delimited, License: NYSL) by Masaaki Nakamura makes textobjects work better with delimited strings. The default mappings are id, ad, iD, and aD. Visual mode is supported as well.

By passing a change command, like d for example, you can manipulate text based on the recognised separators. Given a string like foo_bar_baz, d3id would move the cursor to the last separator and delete the remaining text, resulting in foo_bar_.

Given the same string, vid would select the "inner" text between two separators. So in the case of foo_bar_baz, with the cursor on b, bar would be selected.

Read More →

Peer to Peer

Peer to Peer

Peer to Peer has launched! This is a service by Drew Neil of Vimcasts. The idea is that an expert demonstrates how they solve problems using their preferred tools, while they're filmed both in-person and on-screen.

The first episode is Counting Tree Nodes with Tom Stuart. Tom uses Vim, and you can see him using it to write a Ruby project that uses Cucumber, Rspec, and immutable data structure APIs.

Read More →

Flappyvird

Flappyvird

Flappyvird by Yasuhiro Matsumoto is a version of Flappy Bird for Vim. To play it, type :FlappyVird, and then press space to jump.

It's an exquisite work of ASCII art, complete with a Japanese-style emoticon for the bird.

Read More →

Script Roundup: glowshi-ft.vim, Clighter

glowshi-ft.vim

glowshi-ft.vim (GitHub: saihoooooooo / glowshi-ft.vim) by Shinya Saiho is a cool visualisation plugin for the f and t motions. When a line has multiple targets, it display highlights and allows you to jump between them.

There are settings for changing the mapping behaviour, case handling, and timeout length.

Clighter

Clighter (GitHub: bbchung / clighter) by BB Chung is a semantic source highlighting plugin based on Clang. It can do things like highlight occurrences of matching words under the cursor. It doesn't replace the built-in C syntax handling, but instead enhances it.

Read More →

So, You Just Got A Mechanical Keyboard...

There's definitely a correlation between Vim fans and mechanical keyboard users. The speed, accuracy, and feel of mechanical keyboards is great, and the choice of keyboards can even help you improve your Vim skills.

I have a tenkeyless keyboard with Topre switches and while it feels completely gorgeous, I had to change a few things to make it work really well. I set my Mac's key repeat speed to 'fast', and the delay to 'short':

Mac key repeat speed

Read More →