Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nonylene/vim-keymaps
keymap switcher for vim
https://github.com/nonylene/vim-keymaps
vim
Last synced: 2 months ago
JSON representation
keymap switcher for vim
- Host: GitHub
- URL: https://github.com/nonylene/vim-keymaps
- Owner: nonylene
- License: mit
- Created: 2017-03-18T18:10:48.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2020-10-29T19:41:26.000Z (over 4 years ago)
- Last Synced: 2024-08-09T17:30:40.313Z (6 months ago)
- Topics: vim
- Language: Vim script
- Homepage:
- Size: 85.9 KB
- Stars: 6
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# vim-keymaps
Keymap switcher for Vim
![ScreenCast](/doc/screencast.gif)
_( Using [lightline](https://github.com/itchyny/lightline.vim) for statusline. )_
## Install
- VimPlug
```vim
Plug 'nonylene/vim-keymaps'
```## Configuration
First, map keys to this plugin as you like.
```vim
" map any key to KeyMapRotatemap KeyMapRotate
imap KeyMapRotate" Call function in order to switch to explicit keymap
" noremap <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.
```vim
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.
```vim
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](./LICENSE)).