-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
129 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# matchit [![Say Thanks!](https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg)](https://saythanks.io/to/chrisbra) | ||
Vim matchit plugin (upstream repository) | ||
|
||
The upstream maintained matchit plugin. The original has been created and | ||
maintained by [Benji Fisher](https://github.com/benjifisher/matchit.zip), | ||
however that looks now unmaintained. | ||
|
||
Once in a while, a snapshot from here will be send to Bram for inclusion and | ||
distribution with [Vim][1] | ||
|
||
### Installation | ||
The plugin is distributed as package and should be cloned below `pack/dist/opt` | ||
in your runtime path (e.g. `~/.vim/pack/dist/opt/matchit`). Then it can be | ||
activated in your .vimrc using the command: | ||
|
||
:packadd! matchit | ||
|
||
### Documentation | ||
|
||
- The latest matchit documentation is available here | ||
[doc/matchit.txt](https://github.com/chrisbra/matchit/blob/master/doc/matchit.txt) | ||
- The matchit documentation distributed with Vim is available at | ||
[:h matchit](https://github.com/vim/vim/blob/master/runtime/pack/dist/opt/matchit/doc/matchit.txt) | ||
(The help command only works after the plugin has been activated using the `:packadd` command) | ||
|
||
### License & Copyright | ||
|
||
The Vim license (see `:h license`) applies to the Vim plugin. | ||
|
||
__NO WARRANTY, EXPRESS OR IMPLIED. USE AT-YOUR-OWN-RISK__ | ||
|
||
[1]: https://www.github.com/vim/vim |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
" matchit.vim: (global plugin) Extended "%" matching | ||
" Maintainer: Christian Brabandt | ||
" Version: 1.18 | ||
" Last Change: 2020 Dec 23 | ||
" Version: 1.19 | ||
" Last Change: 2023, June 28th | ||
" Repository: https://github.com/chrisbra/matchit | ||
" Previous URL:http://www.vim.org/script.php?script_id=39 | ||
" Previous Maintainer: Benji Fisher PhD <[email protected]> | ||
|
@@ -46,51 +46,80 @@ let g:loaded_matchit = 1 | |
let s:save_cpo = &cpo | ||
set cpo&vim | ||
|
||
nnoremap <silent> <Plug>(MatchitNormalForward) :<C-U>call matchit#Match_wrapper('',1,'n')<CR> | ||
nnoremap <silent> <Plug>(MatchitNormalBackward) :<C-U>call matchit#Match_wrapper('',0,'n')<CR> | ||
xnoremap <silent> <Plug>(MatchitVisualForward) :<C-U>call matchit#Match_wrapper('',1,'v')<CR> | ||
\:if col("''") != col("$") \| exe ":normal! m'" \| endif<cr>gv`` | ||
xnoremap <silent> <Plug>(MatchitVisualBackward) :<C-U>call matchit#Match_wrapper('',0,'v')<CR>m'gv`` | ||
onoremap <silent> <Plug>(MatchitOperationForward) :<C-U>call matchit#Match_wrapper('',1,'o')<CR> | ||
onoremap <silent> <Plug>(MatchitOperationBackward) :<C-U>call matchit#Match_wrapper('',0,'o')<CR> | ||
" Analogues of [{ and ]} using matching patterns: | ||
nnoremap <silent> <Plug>(MatchitNormalMultiBackward) :<C-U>call matchit#MultiMatch("bW", "n")<CR> | ||
nnoremap <silent> <Plug>(MatchitNormalMultiForward) :<C-U>call matchit#MultiMatch("W", "n")<CR> | ||
xnoremap <silent> <Plug>(MatchitVisualMultiBackward) :<C-U>call matchit#MultiMatch("bW", "n")<CR>m'gv`` | ||
xnoremap <silent> <Plug>(MatchitVisualMultiForward) :<C-U>call matchit#MultiMatch("W", "n")<CR>m'gv`` | ||
onoremap <silent> <Plug>(MatchitOperationMultiBackward) :<C-U>call matchit#MultiMatch("bW", "o")<CR> | ||
onoremap <silent> <Plug>(MatchitOperationMultiForward) :<C-U>call matchit#MultiMatch("W", "o")<CR> | ||
" text object: | ||
xmap <silent> <Plug>(MatchitVisualTextObject) <Plug>(MatchitVisualMultiBackward)o<Plug>(MatchitVisualMultiForward) | ||
if !exists("g:no_plugin_maps") | ||
nmap <silent> % <Plug>(MatchitNormalForward) | ||
nmap <silent> g% <Plug>(MatchitNormalBackward) | ||
xmap <silent> % <Plug>(MatchitVisualForward) | ||
xmap <silent> g% <Plug>(MatchitVisualBackward) | ||
omap <silent> % <Plug>(MatchitOperationForward) | ||
omap <silent> g% <Plug>(MatchitOperationBackward) | ||
fun MatchEnable() | ||
nnoremap <silent> <Plug>(MatchitNormalForward) :<C-U>call matchit#Match_wrapper('',1,'n')<CR> | ||
nnoremap <silent> <Plug>(MatchitNormalBackward) :<C-U>call matchit#Match_wrapper('',0,'n')<CR> | ||
xnoremap <silent> <Plug>(MatchitVisualForward) :<C-U>call matchit#Match_wrapper('',1,'v')<CR> | ||
\:if col("''") != col("$") \| exe ":normal! m'" \| endif<cr>gv`` | ||
xnoremap <silent> <Plug>(MatchitVisualBackward) :<C-U>call matchit#Match_wrapper('',0,'v')<CR>m'gv`` | ||
onoremap <silent> <Plug>(MatchitOperationForward) :<C-U>call matchit#Match_wrapper('',1,'o')<CR> | ||
onoremap <silent> <Plug>(MatchitOperationBackward) :<C-U>call matchit#Match_wrapper('',0,'o')<CR> | ||
" Analogues of [{ and ]} using matching patterns: | ||
nmap <silent> [% <Plug>(MatchitNormalMultiBackward) | ||
nmap <silent> ]% <Plug>(MatchitNormalMultiForward) | ||
xmap <silent> [% <Plug>(MatchitVisualMultiBackward) | ||
xmap <silent> ]% <Plug>(MatchitVisualMultiForward) | ||
omap <silent> [% <Plug>(MatchitOperationMultiBackward) | ||
omap <silent> ]% <Plug>(MatchitOperationMultiForward) | ||
" Text object | ||
xmap a% <Plug>(MatchitVisualTextObject) | ||
endif | ||
nnoremap <silent> <Plug>(MatchitNormalMultiBackward) :<C-U>call matchit#MultiMatch("bW", "n")<CR> | ||
nnoremap <silent> <Plug>(MatchitNormalMultiForward) :<C-U>call matchit#MultiMatch("W", "n")<CR> | ||
xnoremap <silent> <Plug>(MatchitVisualMultiBackward) :<C-U>call matchit#MultiMatch("bW", "n")<CR>m'gv`` | ||
xnoremap <silent> <Plug>(MatchitVisualMultiForward) :<C-U>call matchit#MultiMatch("W", "n")<CR>m'gv`` | ||
onoremap <silent> <Plug>(MatchitOperationMultiBackward) :<C-U>call matchit#MultiMatch("bW", "o")<CR> | ||
onoremap <silent> <Plug>(MatchitOperationMultiForward) :<C-U>call matchit#MultiMatch("W", "o")<CR> | ||
" text object: | ||
xmap <silent> <Plug>(MatchitVisualTextObject) <Plug>(MatchitVisualMultiBackward)o<Plug>(MatchitVisualMultiForward) | ||
if !exists("g:no_plugin_maps") | ||
nmap <silent> % <Plug>(MatchitNormalForward) | ||
nmap <silent> g% <Plug>(MatchitNormalBackward) | ||
xmap <silent> % <Plug>(MatchitVisualForward) | ||
xmap <silent> g% <Plug>(MatchitVisualBackward) | ||
omap <silent> % <Plug>(MatchitOperationForward) | ||
omap <silent> g% <Plug>(MatchitOperationBackward) | ||
" Analogues of [{ and ]} using matching patterns: | ||
nmap <silent> [% <Plug>(MatchitNormalMultiBackward) | ||
nmap <silent> ]% <Plug>(MatchitNormalMultiForward) | ||
xmap <silent> [% <Plug>(MatchitVisualMultiBackward) | ||
xmap <silent> ]% <Plug>(MatchitVisualMultiForward) | ||
omap <silent> [% <Plug>(MatchitOperationMultiBackward) | ||
omap <silent> ]% <Plug>(MatchitOperationMultiForward) | ||
" Text object | ||
xmap a% <Plug>(MatchitVisualTextObject) | ||
endif | ||
endfun | ||
|
||
fun MatchDisable() | ||
" remove all the setup keymappings | ||
nunmap % | ||
nunmap g% | ||
xunmap % | ||
xunmap g% | ||
ounmap % | ||
ounmap g% | ||
|
||
nunmap [% | ||
nunmap ]% | ||
xunmap [% | ||
xunmap ]% | ||
ounmap [% | ||
ounmap ]% | ||
|
||
xunmap a% | ||
endfun | ||
|
||
" Call this function to turn on debugging information. Every time the main | ||
" script is run, buffer variables will be saved. These can be used directly | ||
" or viewed using the menu items below. | ||
if !exists(":MatchDebug") | ||
command! -nargs=0 MatchDebug call matchit#Match_debug() | ||
endif | ||
if !exists(":MatchDisable") | ||
command! -nargs=0 MatchDisable :call MatchDisable() | ||
endif | ||
if !exists(":MatchEnable") | ||
command! -nargs=0 MatchEnable :call MatchEnable() | ||
endif | ||
|
||
call MatchEnable() | ||
|
||
let &cpo = s:save_cpo | ||
unlet s:save_cpo | ||
|