sponsor Vim development Vim logo Vim Book Ad

tinykeymap : Tiny, temporary keymaps

 script karma  Rating 45/12, Downloaded by 2893  Comments, bugs, improvements  Vim wiki

created by
Tom Link
script type
This plugin is a 90% clone of Andy Wokula's tinymode (vimscript #2223).
It takes a different approach that hopefully avoids certain problems
without creating new ones. tinymode actually creates maps to do its job,
tinykeymap only creates maps for the entry sequence and uses the
|getchar()| function to handle further input.

This plugin lets users define "temporary keymaps", a.k.a. tinykeymaps,
with the |tinykeymap#EnterMap()| function. Users can define a map to
activate a tinykeymap. Users can then use single key shortcuts to
trigger commands defined with |tinykeymap#Map()|. Pressing an undefined
key or <Esc>, deactivates the tinykeymap.

tinykeymap comes with some example maps to make it easier to ...

    buffers ... navigate/operate on buffers
    diff    ... navigate/operate on |diff|s
    filter  ... "filter" text in a buffer using folds
    lines   ... navigate/operate on lines (similar to vimscript #4140)
    loc     ... navigate the |location-list|
    qfl     ... navigate the |quickfix| list
    tabs    ... navigate/operate on tabs
    undo    ... navigate/operate on the undo tree (with optional support for
                vimscript #4177)
    windows ... navigate/operate on windows

Example definition for a "tabs" tinykeymap (heavily based on Andy
Wokula's tabs mode for tinymode): >

    call tinykeymap#EnterMap('tabs', 'gt', {'name': 'Tabs mode'})
    call tinykeymap#Map('tabs', 'n', 'tabnew')
    call tinykeymap#Map('tabs', 't', 'norm! gt')
    call tinykeymap#Map('tabs', 'T', 'norm! gT')
    call tinykeymap#Map("tabs", "^", "tabfirst")
    call tinykeymap#Map("tabs", "$", "tablast")
    call tinykeymap#Map("tabs", "c", "tabclose")

Example use of the above tinykeymap: E.g. pressing gt3n^c2t will:

    gt ... Enter tabs mode
    3n ... create 3 new tabs,
    ^  ... select the first one,
    c  ... close it, and
    2t ... move to the second tab on the right.

A tinykeymap is exited (1) by pressing <Esc> or (2) by timeout (see

tinykeymap comes with the following pre-defined tinykeymaps:

    tabs    gt         :: Operate on tabs
    windows <C-W>      :: Operate on windows
    buffers <Leader>mb :: Operate on buffers
    diff    <Leader>md :: Make it easier to work with |diff|s
    filter  <Leader>mf :: Fold lines not matching some pattern (default: word
                         under cursor)
    lines   <Leader>ml :: Operate on lines
    loc     <Leader>mo :: Operate on the |location-list|
    qfl     <Leader>mq :: Operate on the |quickfix| list
    undo    <Leader>mu :: Operate on the |undo| tree

Differences to tinymode:

    - tinykeymaps and maps may have options (optional)
    - tinykeymaps can be buffer-local
    - dealing with [count] is easier (if a map contains "<count>", this
      placeholder is replaced with the current [count], i.e. a
      previously entered number; otherwise the expression is evaluated
      [count] times)
install details
In order to install the vba, open the vba file in VIM and type: >

    :so %

See :help vimball for details.

By default, tinykeymap will load all tinykeymaps in your 'runtimepath'.
If this is not what you want, set |g:tinykeymaps_default| in your
|vimrc| file.

Also available via git: http://github.com/tomtom/tinykeymap_vim/

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
tinykeymap.vba 0.06 2013-10-29 7.0 Tom Link - tinykeymap#Info(): display map arg first (patch by Chr Brabandt)
- tinykeymap#EnterMap(): Ignore conflicts for maps to the same tinykeymap (patch by Chr Brabandt)
- g:tinykeymap#debug: Help debugging
- filter tinykeymap: <cr> ... leave folds intact (patch by Chr Brabandt)
- tabs: up & down: move tab page left/right
- addon-info
- autokey, autokey_msecs options
- Help template
MD5 checksum: 01926a3a2f612acc40569b1b176271be
tinykeymap.vba 0.05 2012-11-12 7.0 Tom Link - g:tinykeymap#mapleader defaults to '<Leader>m' (no need to use mapleader directly)
- :TinykeymapsInfo command: give information on loaded tinykeymaps
- Fix handling of conflicting maps
MD5 checksum: 07833eda99f35110f6d2d527fc088e1c
tinykeymap.vba 0.04 2012-11-10 7.0 Tom Link - If mapleader isn't defined use "\", which is vim's default mapleader
MD5 checksum: b982d342ca7cecce4f3fdde81e9003ae
tinykeymap.vba 0.03 2012-11-09 7.0 Tom Link - fix msg variable name typo
- Merge branch 'a_little_bit_fix' of https://github.com/NagatoPain/tinykeymap_vim
- g:tinykeymap#mapleader: Check whether mapleader is defined (reported by C Brabandt)
MD5 checksum: bbe0b05d5cefcf3d6f9328995762711e
tinykeymap.vba 0.02a 2012-09-29 7.0 Tom Link Re-packaged (forgot some files)
tinykeymap.vba 0.02 2012-09-28 7.0 Tom Link - Misc improvements: multi-key maps, more options etc.
- Improved "buffers" map
- Improved "undo" map
- Improved "windows" map
- New "diff" map
- New "filter" map
- New "lines" map
- New "qfl" map
- Moved maps to autoload/tinykeymap/map
- Make sure a map is loaded upon activation
- lines, qfl: Highlight the current line if tlib is installed
- <count0>: Insert 0 by default
- diff: G, P, u maps; highlight current line if tlib is installed
- qfl: <cr> calls :cc (not c)
- Map for location-list
- Call "norm! zz" after some actions
- filter: use g:tinykeymap#map#filter#rx instead of g:tinykeymap#filter#rx
MD5 checksum: 829fc233090bf9d543c9851d236df60f
tinykeymap.vba 0.1 2012-08-31 7.0 Tom Link Initial upload
ip used for rating:

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.