vim-keymaps


Ⅰ. 插件描述

keymap switcher for vim

Ⅱ. 基本信息

创建日期:  2017-03-18
使用用户:  1
Github星:  3
插件作者:  nonylene

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'nonylene/vim-keymaps-today-cannot-touch'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'nonylene/vim-keymaps-today-cannot-touch'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'nonylene/vim-keymaps-today-cannot-touch'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/nonylene/vim-keymaps

Ⅳ. 文档说明

# 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.md).

添加新评论