https://github.com/hrsh7th/vim-minx
Extended insert-mode mapping manager.
https://github.com/hrsh7th/vim-minx
Last synced: 8 months ago
JSON representation
Extended insert-mode mapping manager.
- Host: GitHub
- URL: https://github.com/hrsh7th/vim-minx
- Owner: hrsh7th
- Created: 2022-01-01T18:46:49.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-02-17T04:59:37.000Z (over 3 years ago)
- Last Synced: 2025-01-03T08:13:58.469Z (9 months ago)
- Language: Vim script
- Size: 17.6 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Example
```
let s:pairs = { '(': ')', '[': ']', '{': '}', '<': '>' }
let s:quotes = { '"': '"', "'": "'", '`': '`' }" Semicolon
call minx#add('', {
\ 'at': '\%#\%(;\|`\)',
\ 'keys': '',
\ })" Auto.
for [s:o, s:c] in items(extend(copy(s:pairs), s:quotes))
call minx#add(s:o, s:o .. s:c .. '')
endfor" Leave.
for [s:o, s:c] in items(extend(copy(s:pairs), s:quotes))
call minx#add('', {
\ 'at': '\%#\s*' .. minx#u#e(s:c),
\ 'keys': [minx#x#search('\V' .. s:c .. '\m\zs')],
\ })
endfor" Space.
for [s:o, s:c] in items(extend(copy(s:pairs), s:quotes))
call minx#add('', {
\ 'at': minx#u#e(s:o) .. '\s*\%#\s*' .. minx#u#e(s:c),
\ 'keys': ''
\ })
endfor" Remove.
for [s:o, s:c] in items(extend(copy(s:pairs), s:quotes))
call minx#add('', {
\ 'at': minx#u#e(s:o) .. '\s*\%#\s*' .. minx#u#e(s:c),
\ 'keys': ''
\ })
endfor" Enter.
for [s:o, s:c] in items(copy(s:pairs))
call minx#add('', {
\ 'at': minx#u#e(s:o) .. '\%#' .. minx#u#e(s:c),
\ 'keys': [minx#x#enterpair()]
\ })
endfor
call minx#add('', {
\ 'priority': -1,
\ 'at': '<\w\+\%(\s\+.\{-}\)\?>\%#$',
\ 'keys': ['', minx#x#capture('<\(\w\+\)\%(\s\+.\{-}\)\?>\%#'), '>', minx#x#search('<\w\+\%(\s\+.\{-}\)\?>\zs\w\+>\%#'), minx#x#enterpair()]
\ })
call minx#add('', {
\ 'at': '>\%#<',
\ 'keys': [minx#x#enterpair()]
\ })" Wrap contents.
for [s:o, s:c] in items(copy(s:pairs))
" quotes.
for [s:target_o, s:target_c] in items(s:quotes)
call minx#add(s:c, {
\ 'priority': 3,
\ 'at': '\%#' .. minx#u#e(s:c) .. '\s*' .. minx#u#e(s:target_o),
\ 'keys': ['', minx#x#search(minx#u#e(s:target_o) .. '\zs'), minx#x#search('\\\@']
\ })
endfor" pairs.
for [s:target_o, s:target_c] in items(s:pairs)
call minx#add(s:c, {
\ 'priority': 2,
\ 'at': '\%#' .. minx#u#e(s:c) .. '\s*[^[:blank:]]*' .. minx#u#e(s:target_o),
\ 'keys': ['', minx#x#search(minx#u#e(s:target_o) .. '\zs'), minx#x#searchpair(minx#u#e(s:target_o), '', minx#u#e(s:target_c)), '', s:c, '']
\ })
endfor" keywords.
call minx#add(s:c, {
\ 'priority': 1,
\ 'at': '\%#' .. minx#u#e(s:c) .. '\s*[^[:blank:]]\+',
\ 'keys': ['', minx#x#search('\s*[^[:blank:]]\+\zs'), s:c, '']
\ })
endfor```