Skip to content

nonylene/vim-keymaps

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vim-keymaps

Keymap switcher for Vim

ScreenCast

( Using lightline for statusline. )

Install

  • VimPlug
Plug 'nonylene/vim-keymaps'

Configuration

First, map keys to this plugin as you like.

" map any key to <Plug>KeyMapRotate

map <C-k> <Plug>KeyMapRotate
imap <C-k> <Plug>KeyMapRotate

" Call function in order to switch to explicit keymap

" noremap <silent> <script> <C-p> :call keymaps#set_keymap("US")<CR>
" noremap! <expr> <C-p> keymaps#set_keymap("US")

" If you will use paste mode, this is recommended

" set pastetoggle=<C-k>

Keymaps are configured as array of dictionaries.

let g:keymaps =  [
      \  {
      \    'name': 'first',
      \    'keymap': {
      \      'noremap': {
      \        '1': '!',
      \        '!': '1',
      \      },
      \      'inoremap': {
      \        "'": '"',
      \        '¥': '\',
      \      },
      \    },
      \  },
      \  {
      \    'name': 'second',
      \    'keymap': {
      \      'cnoremap': {
      \        '1': '@',
      \        ':': ';',
      \        ';': ':',
      \      },
      \      'inoremap <unique>': {
      \        '¥': '\|',
      \      },
      \    },
      \  },
      \  {
      \    'name': 'paste_mode',
      \    'paste': 1
      \  },
      \]

You can use <Plug>, <SID>, etc .

  • IMPORTANT:

<SID> refers this plugin's scope because mappings are executed with plugin's scope. For that, functions used for <expr> mappings must be global.

let g:keymaps =  [
      \  {
      \    'name': 'first',
      \    'keymap': {
      \      'imap': {
      \        '2': '<Plug>delimitMate"',
      \        '7': "<Plug>delimitMate'",
      \      },
      \    },
      \  },
      \  {
      \    'name': 'second',
      \    'keymap': {
      \      'inoremap': {
      \        '<SID>parenthese': '()<Esc>i',
      \      },
      \      'noremap! <script>': {
      \        '8': '<SID>parenthese',
      \      },
      \      'imap <expr>': {
      \        '1': 'Foo()',
      \      },
      \    },
      \  },
      \]

Other options

  • g:keymaps_unmap_keys (default: 1)

Unmap prev keymaps before do mapping.

  • g:keymaps_paste_auto_rotate (default: 1 (if 'paste': 1 exists) / 0)

Rotate keymap after exit paste mode (using hook OptionChange).

"7.4.786" patch is required to enable this feature.

  • g:keymaps_default

First used keymap name. If not set, first keymap in array will be used.

Commands

  • KeyMapRotate

Switch to next keymap.

  • KeyMapSet <keymap_name>

Switch to explicit keymap.

Tips

  • Get current keymap name

:call keymaps#get_current_keymap_name

License

MIT License (see LICENSE).

About

keymap switcher for vim

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published