autoload/splicelib/util/keys.py @ 0013f7e01b6e

Rename to Splice, and change default prefix.
author Steve Losh <steve@stevelosh.com>
date Fri, 20 Apr 2012 15:16:48 +0100
parents autoload/threesomelib/util/keys.py@b8aab52392ea
children ade86d98b924
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', '-')

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

def unbind(key, options='', leader=None):
    if not leader:
        leader = setting('leader', '-')

    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)