autoload/threesomelib/util/keys.py @ eab60b05e2b5

Added modeline (as is common in a lot of help files).
author A. S. Budden <abudden@gmail.com>
date Mon, 19 Sep 2011 13:09:10 +0100
parents b8aab52392ea
children (none)
import vim
from bufferlib import buffers
from ..settings import setting


def bind(key, to, options='', mode=None, leader=None):
    if not leader:
        leader = setting('leader', '<localleader>')

    vim.command('nnoremap %s %s%s %s' % (options, leader, key, to))

def unbind(key, options='', leader=None):
    if not leader:
        leader = setting('leader', '<localleader>')

    vim.command('unmap %s %s%s' % (options, leader, key))

def bind_for_all(key, to, options='', mode=None, leader=None):
    if not leader:
        leader = setting('leader', '<localleader>')

    with buffers.remain():
        for b in buffers.all:
            b.open()
            bind(key, to, options, mode, leader)

def unbind_for_all(key, options='', leader=None):
    if not leader:
        leader = setting('leader', '<localleader>')

    with buffers.remain():
        for b in buffers.all:
            b.open()
            unbind(key, options, leader)