Switch branches/tags
Clone or download
wincent vim: Maintain VISUAL selection while indenting/dedenting
I can't remember if I've tried this before. My previous rationale for
not bothering with this is that you can easily repeat and indent or
dedent by just hitting `.` and you can undo it by hitting `u`. But one
thing you can't do is undo past the initial starting point, so these
mappings might be useful after all.
Latest commit 96580a5 Aug 19, 2018

"dotfiles" and system configuration

  • Target platforms: macOS and Red Hat-like Linuxes (eg. CentOS).
  • Set-up method: Beautiful and intricate snowflake incredibly over-engineered Ansible orchestration.
  • Visible in the screenshot:



A set of dotfiles that I've been tweaking and twiddling since the early 2000s (under version control since 2009). Characteristics include:

  • Sane Vim pasting via bracketed paste mode.
  • Write access to local clipboard from local and remote hosts, inside and outside of tmux (via Clipper).
  • Full mouse support (pane/split resizing, scrolling, text selection) in Vim and tmux.
  • Focus/lost events for Vim inside tmux.
  • Cursor shape toggles on entering Vim.
  • Italics in the terminal.
  • Bundles a (not-excessive) number of useful Vim plug-ins.
  • Conservative Vim configuration (very few overrides of core functionality; most changes are unobtrusive enhancements; some additional functionality exposed via <Leader> and <LocalLeader> mappings.
  • Relatively restrained Zsh config, Bash-like but with a few Zsh perks, such as right-side prompt, auto-cd hooks, command elapsed time printing and such.
  • Unified color-handling (across iTerm2 and Vim) via Base16 Shell.
  • Encrypted versioning of files with sensitive content (via git-cipher).
  • Comprehensive Hammerspoon config.


On macOS, the homebrew role installs a bunch of useful software.

Keyboard customization

On macOS, Karabiner-Elements is used for the following:

  • Make Caps Lock serve as Backspace (when tapped) and Left Control (when chorded with another key). When held down alone, Caps Lock fires repeated Backspace events.
  • Make Return serve as Return (when tapped) and Right Control (when chorded with another key). When held down alone, Return fires repeated Return events.
  • Maps Control-I to F6 (only in MacVim and the terminal) so that it can be mapped independently from Tab in Vim.
  • Toggle Caps Lock on by tapping both Shift keys simultaneously.
  • Makes the function keys on my external Realforce keyboard behave like the "media" keys on Apple's keyboards.
  • Swap Option and Command keys on my external Realforce keyboard.
  • Make the "application" key (extra modifier key on right-hand side) behave as "fn" on Realforce keyboard.
  • Make "pause" (at far-right of function key row) behave as "power" (effectively, sleep) on Realforce keyboard.
  • Adds a "SpaceFN" layer that can be activated by holding down Space while hitting other keys; I use this to make the cursor keys available on or near the home row in any app.


A number of tools are used to provide command-line access to Gmail and Office IMAP accounts.

  • mutt: For reading email.
  • isync: For maintaining a local cache of messages for offline access.
  • notmuch: For fast search.
  • msmtp: For sending email.
  • elinks: For viewing HTML emails.
  • urlview: For opening URLs from inside mutt.
  • terminal-notifier: For notifications.
  • lbdb: Contact autocompletion drawing from a number of sources, such as previous messages, aliases, and macOS Contacts (which can be configured to synchronize Google contacts as well).
  • imapfilter: For filtering.
  • passage: For mediating interaction with the macOS keychain.

In order for all this to work, a few items have to be stored in the macOS keychain:

  • A "generic" (A.K.A. "application") keychain items (that is, without protocols, only hostnames):
    • "Keychain Item Name": (corresponds to the "host" field in ~/.msmtprc, and "Host" field in ~/.mbsyncrc).
    • "Account Name": (corresponds to the "user" field in ~/.msmtprc, and "PassCmd" field in ~/.mbsynrc).

The following Gmail-like/Vim-like bindings are configured:

  • e: Archive (but note: leaves copy of mail in mailbox until next sync; force an immediate sync with $).
  • #: Trash mail.
  • !: Mark as spam.
  • gi: Go to inbox.
  • ga: Go to archive.
  • gt: Go to sent mail.
  • gd: Go to drafts.
  • gs: Go to starred mail.
  • gl: Go to a label (folder).
  • x: Toggle selection on entry (see also t).
  • c: Compose new message.
  • s: Toggle star.
  • *a: Select all.
  • *n: Deselect all (mnemonic: "select none").
  • *r: Select read messages.
  • *u: Select unread messages.
  • Shift-U: Mark as unread.
  • Shift-I: Mark as read.

Standard mutt stuff:

  • v: View attachments (including alternate parts for a multipart message).

Non-Gmail extensions:

  • t: Toggle selection on entire thread (see also x).
  • A: Show alternate MIME-type in MIME-multipart messages.
  • O: Save original message.
  • S: Search all using Xapian query syntax (notmuch-specific reference documentation):
    • +foo: Must include "foo".
    • -bar: Must not include "bar".
    • AND, OR, NOT, XOR: Self-evident.
    • foo NEAR bar: "foo" within 10 words of "bar" (order-independent).
    • foo ADJ bar: Like NEAR, but "foo" must appear earlier than "bar".
    • "foo bar": Match entire phrase.
    • foo*: Match "foo", "food", "foobar" etc.
    • subject:this, subject:"one two" (two consecutive words), subject:(one two) (two words anywhere in subject), subject:one AND subject:two (two words anywhere in subject).
    • subject:/some regex.*/
    • from:john,
    • to:john,
    • folder:Sent (prefix search)
    • date:today
    • date:yesterday
    • date:3d (exactly 3 days ago)
    • date:14d..7d (a week ago)
    • date:10d.. (since 10 days ago)
    • date:..3d (until 3 days ago)
    • date:"last week" (preceding Monday through Sunday)
    • date:"this week" or date:this_week or date:this-week (Monday to present day)
    • date:"last year" (also works with years, months, hours/hrs, minutes/mins, seconds/secs etc).
    • date:june
    • date:2018-06-01
    • is:unread
  • l: Limit listed messages:
    • ~f bob (from bob)
    • ~s foo (subject contains "foo"; "Foo" would search case-sensitively)
    • ~s foo.+bar (subject contains pattern)
    • !~s foo (subject does not contain "foo")
    • ~d >1m (messages more than 1 month old)
  • \u: Open list of URLs in message (via urlview).
  • b: Toggle (mailboxes) sidebar.
  • m: Move message(s).

Other stuff:

  • <Tab> autocompletes addresses from the lbdb database.
  • <C-t> autocompletes aliases.

Attachment menu bindings:

  • S: Save all attachments.

To have mailto links open up in mutt in iTerm:

  1. In iTerm2PreferencesProfilesGeneral, select the "Mutt" profile.
  2. Under URL SchemesSchemes handled:, select mailto.


  • $$URL$$ is documented here.
  • The convoluted use of env and zsh is required to get terminal colors working correctly.


  • tmux 2.3 or later.
  • Neovim or Vim 8.0 or later with Ruby and Python support (although there's a reasonable amount of feature detection in order to degrade gracefully).
  • Relatively recent Zsh.
  • Relatively recent Git.
  • Clipper for transparent access to the local system clipboard.
  • On macOS, iTerm2. Additionally, only the latest version of macOS (currently Sierra) gets actively tested.
  • Python to perform setup via the included install command.
  • Ruby.
  • Adobe Source Code Pro or any other fixed-width font that includes the Powerline glyphs.



git clone --recursive

Note that if you're behind a firewall you may need to set up a temporary ~/.gitconfig with appropriate proxy configuration with a format such as:

	proxy = fwdproxy:8080

Or alternatively:

env http_proxy=http://fwdproxy:8080 https_proxy=http://fwdproxy:8080 git clone --recursive


./install          # Installs everything on the local machine.
./install --help   # Info on installing specific roles, force-installing etc.
./install dotfiles # Just install dotfiles.

This sets up a local Python environment using the bundled virtualenv, bootstraps Ansible, and then uses Ansible to copy the dotfiles and configure the machine.

Again, if you're behind a firewall, you may need to make use of a proxy during the initial run:

env http_proxy=http://fwdproxy:8080 https_proxy=http://fwdproxy:8080 ./install

As a fallback strategy, in case the install script fails, you can symlink the dotfiles by hand with a command like the following:

for DOTFILE in $(find roles/dotfiles/files -maxdepth 1 -name '.*' | tail -n +2); do
  ln -sf $PWD/$DOTFILE ~

Note: The ln -sf command will overwrite existing files, but will fail to overwrite existing directories.

Warning: Beware of the .gitconfig, you need to change for your user name and email address:

$ git config --global "John Doe"
$ git config --global


pycrypto install fails with "'gmp.h' file not found"

If pycrypto causes the install to fail at:

src/_fastmath.c:36:11: fatal error: 'gmp.h' file not found

due to a missing GMP dependency, try:

brew install gmp
env "CFLAGS=-I/usr/local/include -L/usr/local/lib" pip install pycrypto

And then installing again:

./install --force

Broken Unicode in Vim (Linux)

If Unicode symbols appear missing or corrupted in Vim, first ensure that your terminal emulator supports UTF-8. Then, check to see if you've properly configured your system-wide UTF-8 support.

Issue this test command:

export LC_ALL=en_US.UTF-8

Then run vim. Unicode in the statusline should be working.

To persist this LC_* variable binding, edit your locale accordingly:



See also


Unless otherwise noted, the contents of this repo are in the public domain. See the LICENSE for details.


The repo is written and maintained by Greg Hurrell <> Other contributors that have submitted patches include, in alphabetical order:

  • Joe Lencioni
  • Mark Stenglein
  • Victor Igor
  • Zac Collier

This list produced with:

:read !git shortlog -s | grep -v 'Greg Hurrell' | cut -f 2-3 | sed -e 's/^/- /'