mirror of
https://github.com/Raimondi/delimitMate.git
synced 2025-12-06 20:54:31 +08:00
Compare commits
126 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
860c45ab2a | ||
|
|
8686edfc63 | ||
|
|
5e7a7c4738 | ||
|
|
928cc1146a | ||
|
|
d420afdacd | ||
|
|
f6015300a0 | ||
|
|
e183064744 | ||
|
|
40849c94ef | ||
|
|
4c1424f9bd | ||
|
|
0783f97fc0 | ||
|
|
e551885c24 | ||
|
|
4891a04258 | ||
|
|
ad77a9a75e | ||
|
|
5bf35a6b31 | ||
|
|
49044099dd | ||
|
|
7c423067a8 | ||
|
|
d08fa765b9 | ||
|
|
f47bcd8e3f | ||
|
|
873e79ec37 | ||
|
|
589b2ae85a | ||
|
|
f9f2b5f177 | ||
|
|
4157dc8a88 | ||
|
|
d0fc1456b7 | ||
|
|
86f70a7d9c | ||
|
|
f7b53f045d | ||
|
|
f3d140e363 | ||
|
|
93a1770f37 | ||
|
|
859a732509 | ||
|
|
eb778be64b | ||
|
|
2b2ae65182 | ||
|
|
e1b52d3676 | ||
|
|
ff4745b191 | ||
|
|
2ba694830d | ||
|
|
12c5c96ca2 | ||
|
|
a97af1fb97 | ||
|
|
5bf6a1e30c | ||
|
|
f8883cb700 | ||
|
|
f72ffe3c12 | ||
|
|
d2e896fbe1 | ||
|
|
a0b1799270 | ||
|
|
1d423ab2b9 | ||
|
|
7f5df4bf6e | ||
|
|
9f1fdc418d | ||
|
|
64cf4beb8a | ||
|
|
119174b7dd | ||
|
|
b3a7728299 | ||
|
|
2266a19900 | ||
|
|
1b587bee9a | ||
|
|
31b289adfe | ||
|
|
efadb34c84 | ||
|
|
58d63b4e5b | ||
|
|
0441a03bb9 | ||
|
|
90cb449ada | ||
|
|
a678d7baab | ||
|
|
2911bf33c9 | ||
|
|
221daf6e6a | ||
|
|
8f5a45f9e7 | ||
|
|
6f5fd80e0e | ||
|
|
1caeda0799 | ||
|
|
3fb33b8e47 | ||
|
|
e6288a7313 | ||
|
|
7dd7edff64 | ||
|
|
4b94c38f95 | ||
|
|
217adb3d8e | ||
|
|
e63e373ae1 | ||
|
|
9c11c5cc82 | ||
|
|
8b24f0fd9f | ||
|
|
701e14f72f | ||
|
|
c9c1464075 | ||
|
|
e831d89acf | ||
|
|
133c125f93 | ||
|
|
b9cea6312a | ||
|
|
1b37d60840 | ||
|
|
a70aa5285e | ||
|
|
2eba04961d | ||
|
|
3519f82f79 | ||
|
|
e9491e473c | ||
|
|
9e3075cff5 | ||
|
|
7c9ba95565 | ||
|
|
3ae285424c | ||
|
|
fa1d3b3d6a | ||
|
|
63f8c2af4f | ||
|
|
29eb98d79d | ||
|
|
5b004ca49d | ||
|
|
34df78f8ab | ||
|
|
e234e45846 | ||
|
|
081ec279ed | ||
|
|
4399fa327f | ||
|
|
ceaa6e01ed | ||
|
|
235f0dcbfb | ||
|
|
fadd7fefbc | ||
|
|
193b6027c2 | ||
|
|
a76439a641 | ||
|
|
89cc598217 | ||
|
|
28ce6213fc | ||
|
|
6d1f48c1bf | ||
|
|
0e20bcaff8 | ||
|
|
aae61ad8ba | ||
|
|
4dac6ce6ac | ||
|
|
875a9e450b | ||
|
|
48d2e3b9d1 | ||
|
|
5626a633d5 | ||
|
|
3652ba24e3 | ||
|
|
740fc90ae7 | ||
|
|
e0de2dbf39 | ||
|
|
efcf9eb341 | ||
|
|
2545fa5967 | ||
|
|
c91674eed2 | ||
|
|
542728671e | ||
|
|
d1621b6672 | ||
|
|
6d1cc1187b | ||
|
|
377c3a37e1 | ||
|
|
d03324135c | ||
|
|
edeaff4730 | ||
|
|
c85fee6eb5 | ||
|
|
0ccb143a12 | ||
|
|
941beed3b3 | ||
|
|
739a3e606c | ||
|
|
61cc934b68 | ||
|
|
7aec4532f9 | ||
|
|
6f22aab0b8 | ||
|
|
592cf2fea1 | ||
|
|
3d818560eb | ||
|
|
da66a3f7c9 | ||
|
|
e5ce5b0967 | ||
|
|
03342b8d22 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,6 +1,8 @@
|
|||||||
*.sw?
|
*.sw?
|
||||||
|
*.un?
|
||||||
*.vba
|
*.vba
|
||||||
*.zip
|
*.zip
|
||||||
*.gz
|
*.gz
|
||||||
vimball.txt
|
vimball.txt
|
||||||
*.orig
|
*.orig
|
||||||
|
tags
|
||||||
|
|||||||
33
Makefile
33
Makefile
@@ -4,18 +4,13 @@ SCRIPT=$(wildcard plugin/*.vim)
|
|||||||
AUTOL=autoload/$(PLUGIN).vim
|
AUTOL=autoload/$(PLUGIN).vim
|
||||||
DOC=$(wildcard doc/*.txt)
|
DOC=$(wildcard doc/*.txt)
|
||||||
TESTS=$(wildcard autoload/*Tests.vim)
|
TESTS=$(wildcard autoload/*Tests.vim)
|
||||||
VERSION=$(shell perl -ne 'if (/\*\sCurrent\srelease:/) {s/^\s+(\d+\.\d+).*$$/\1/;print}' $(DOC))
|
VERSION=$(shell perl -ne 'if (/\*\sCurrent\srelease:/) {s/^\s+(\d+\.\S+)\s.*$$/\1/;print}' $(DOC))
|
||||||
VIMFOLDER=~/.vim
|
VIMFOLDER=~/.vim/
|
||||||
VIM=/usr/bin/vim
|
VIM=/usr/bin/vim
|
||||||
|
|
||||||
.PHONY: $(PLUGIN).vba README
|
.PHONY: $(PLUGIN).vba README
|
||||||
|
|
||||||
install: vimball
|
all: vimball README zip gzip
|
||||||
@echo install
|
|
||||||
$(VIM) -N -c ':so %' -c':q!' $(PLUGIN)-$(VERSION).vba
|
|
||||||
cp -f autoload/$(PLUGIN)Tests.vim $(VIMFOLDER)/autoload/$(PLUGIN)Tests.vim
|
|
||||||
|
|
||||||
all: uninstall vimball install README zip gzip
|
|
||||||
|
|
||||||
vimball: $(PLUGIN).vba
|
vimball: $(PLUGIN).vba
|
||||||
|
|
||||||
@@ -25,11 +20,6 @@ clean:
|
|||||||
|
|
||||||
dist-clean: clean
|
dist-clean: clean
|
||||||
|
|
||||||
uninstall:
|
|
||||||
@echo uninstall
|
|
||||||
$(VIM) -N -c':RmVimball' -c':q!' $(PLUGIN)-$(VERSION).vba
|
|
||||||
rm -f $(VIMFOLDER)/autoload/$(PLUGIN)Tests.txt
|
|
||||||
|
|
||||||
undo:
|
undo:
|
||||||
for i in */*.orig; do mv -f "$$i" "$${i%.*}"; done
|
for i in */*.orig; do mv -f "$$i" "$${i%.*}"; done
|
||||||
|
|
||||||
@@ -45,9 +35,14 @@ $(PLUGIN).vba:
|
|||||||
|
|
||||||
zip:
|
zip:
|
||||||
@echo zip
|
@echo zip
|
||||||
|
rm -f *.zip
|
||||||
zip -r $(PLUGIN).zip doc plugin autoload
|
zip -r $(PLUGIN).zip doc plugin autoload
|
||||||
zip $(PLUGIN).zip -d \*.sw\?
|
zip $(PLUGIN).zip -d \*.sw\? || echo 1
|
||||||
zip $(PLUGIN).zip -d autoload/$(PLUGIN)Tests.vim
|
zip $(PLUGIN).zip -d \*.un\? || echo 1
|
||||||
|
zip $(PLUGIN).zip -d \*.orig || echo 1
|
||||||
|
zip $(PLUGIN).zip -d \*tags || echo 1
|
||||||
|
zip $(PLUGIN).zip -d $(TESTS)
|
||||||
|
ln -f $(PLUGIN).zip $(PLUGIN)-$(VERSION).zip
|
||||||
|
|
||||||
gzip: vimball
|
gzip: vimball
|
||||||
@echo vimball
|
@echo vimball
|
||||||
@@ -57,11 +52,11 @@ release: version all
|
|||||||
|
|
||||||
version:
|
version:
|
||||||
@echo version: $(VERSION)
|
@echo version: $(VERSION)
|
||||||
perl -i.orig -pne 'if (/^"\sVersion:/) {s/(\d+\.\d+)/$(VERSION)/e}' $(SCRIPT) $(AUTOL)
|
perl -i.orig -pne 'if (/^"\sVersion:/) {s/(\d+\.\S+)/$(VERSION)/}' $(SCRIPT) $(AUTOL)
|
||||||
perl -i.orig -pne 'if (/let\sdelimitMate_version/) {s/(\d+\.\d+)/$(VERSION)/e}' $(SCRIPT)
|
perl -i.orig -pne 'if (/let\sdelimitMate_version/) {s/"(\d+\.\S+)"/"$(VERSION)"/}' $(SCRIPT)
|
||||||
perl -i.orig -pne 'if (/beasts/) {s/(v\d+\.\d+)/v.$(VERSION)/e}' $(DOC)
|
perl -i.orig -pne 'if (/beasts/) {s/(v\d+\.\S+)/v$(VERSION)/}' $(DOC)
|
||||||
perl -i.orig -MPOSIX -pne 'if (/^"\sModified:/) {$$now_string = strftime "%F", localtime; s/(\d+-\d+-\d+)/$$now_string/e}' $(SCRIPT) $(AUTOL)
|
perl -i.orig -MPOSIX -pne 'if (/^"\sModified:/) {$$now_string = strftime "%F", localtime; s/(\d+-\d+-\d+)/$$now_string/e}' $(SCRIPT) $(AUTOL)
|
||||||
perl -i.orig -MPOSIX -pne 'if (/^\s+$(VERSION)\s+\d+-\d+-\d+\s+\*/) {$$now_string = strftime "%F", localtime; s/(\d+-\d+-\d+)/$$now_string/e}' $(DOC)
|
perl -i.orig -MPOSIX -pne 'if (/^\s+$(VERSION)\s+\d+-\d+-\d+\s+\*/) {$$now_string = strftime "%F", localtime; s/(\d+-\d+-\d+)/$$now_string/}' $(DOC)
|
||||||
@echo Version: $(VERSION)
|
@echo Version: $(VERSION)
|
||||||
|
|
||||||
echo:
|
echo:
|
||||||
|
|||||||
665
README
665
README
@@ -1,56 +1,269 @@
|
|||||||
*delimitMate* Trying to keep those beasts at bay! v2.2 *delimitMate.txt*
|
*delimitMate.txt* Trying to keep those beasts at bay! v2.5.1 *delimitMate*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
|
||||||
|
MMMM MMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMM MMMMM MMMMMMMMMMMMMMMMMMMMM ~
|
||||||
|
MMMM MMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMM MMM MMMMMMMMMMMMMMMMMMMMM
|
||||||
|
MMMM MMMMMMMMM MMMMMMMMMMMMMMMMMMMMM MMM M M MMMMMMMMMM MMMMMMMMM ~
|
||||||
|
MMMM MMM MMM MM MM M M MMM MM MM MM MM MMM MMM MMM MM
|
||||||
|
MM MM M MM MMMMMM MMMMMMM MMM MMMMM MM M MMM MMM M M ~
|
||||||
|
M M MM MM MM MM M M MM MMM MMM MMMMM MMMMM MMM MMM M
|
||||||
|
M M MM MMMMM MM MM M M MM MMM MMM MMMMM MMM MMM MMM MMMM ~
|
||||||
|
M M MM M MM MM MM M M MM MMM MMM MMMMM MM M MMM MMM M M
|
||||||
|
MM MMM MMM MM MM M M MM MMM MM MMMMM MMM MMM MMM MM ~
|
||||||
|
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
|
||||||
|
|
||||||
========================================================================= ~
|
|
||||||
==== ========= ========================== ===== ===================== ~
|
|
||||||
==== ========= ========================== === ===================== ~
|
|
||||||
==== ========= ===================== === = = ========== ========= ~
|
|
||||||
==== === === == == = = === == == == == === === === == ~
|
|
||||||
== == = == ====== ======= === ===== == = === === = = ~
|
|
||||||
= = == == == == = = == === === ===== ===== === === = ~
|
|
||||||
= = == ===== == == = = == === === ===== === === === ==== ~
|
|
||||||
= = == = == == == = = == === === ===== == = === === = = ~
|
|
||||||
== === === == == = = == === == ===== === === === == ~
|
|
||||||
========================================================================= ~
|
|
||||||
|
|
||||||
REFERENCE MANUAL *
|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
0.- CONTENTS *delimitMate-contents*
|
0.- CONTENTS *delimitMate-contents*
|
||||||
|
|
||||||
1. Introduction____________________________|delimitMateIntro|
|
1. Introduction____________________________|delimitMateIntro|
|
||||||
2. Functionality___________________________|delimitMateFunctionality|
|
2. Customization___________________________|delimitMateOptions|
|
||||||
2.1 Automatic closing & exiting________|delimitMateAutoClose|
|
2.1 Options summary____________________|delimitMateOptionSummary|
|
||||||
2.2 Expansion of space and CR__________|delimitMateExpansion|
|
2.2 Options details____________________|delimitMateOptionDetails|
|
||||||
2.3 Backspace__________________________|delimitMateBackspace|
|
3. Functionality___________________________|delimitMateFunctionality|
|
||||||
2.4 Visual wrapping____________________|delimitMateVisualWrapping|
|
3.1 Automatic closing & exiting________|delimitMateAutoClose|
|
||||||
2.5 Smart Quotes_______________________|delimitMateSmartQuotes|
|
3.2 Expansion of space and CR__________|delimitMateExpansion|
|
||||||
2.6 FileType based configuration_______|delimitMateFileType|
|
3.3 Backspace__________________________|delimitMateBackspace|
|
||||||
3. Customization___________________________|delimitMateOptions|
|
3.4 Smart Quotes_______________________|delimitMateSmartQuotes|
|
||||||
3.1 Options summary____________________|delimitMateOptionSummary|
|
3.5 Balancing matching pairs___________|delimitMateBalance|
|
||||||
3.2 Options details____________________|delimitMateOptionDetails|
|
3.6 FileType based configuration_______|delimitMateFileType|
|
||||||
|
3.7 Syntax awareness___________________|delimitMateSyntax|
|
||||||
4. Commands________________________________|delimitMateCommands|
|
4. Commands________________________________|delimitMateCommands|
|
||||||
5. Functions_______________________________|delimitMateFunctions|
|
5. Mappings________________________________|delimitMateMappings|
|
||||||
6. TODO list_______________________________|delimitMateTodo|
|
6. Functions_______________________________|delimitMateFunctions|
|
||||||
7. Maintainer______________________________|delimitMateMaintainer|
|
7. TODO list_______________________________|delimitMateTodo|
|
||||||
8. Credits_________________________________|delimitMateCredits|
|
8. Maintainer______________________________|delimitMateMaintainer|
|
||||||
9. History_________________________________|delimitMateHistory|
|
9. Credits_________________________________|delimitMateCredits|
|
||||||
|
10. History_________________________________|delimitMateHistory|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
1.- INTRODUCTION *delimitMateIntro*
|
1.- INTRODUCTION *delimitMateIntro*
|
||||||
|
|
||||||
This plug-in provides automatic closing of quotes, parenthesis, brackets,
|
This plug-in provides automatic closing of quotes, parenthesis, brackets,
|
||||||
etc., besides some other related features that should make your time in insert
|
etc.; besides some other related features that should make your time in insert
|
||||||
mode a little bit easier.
|
mode a little bit easier.
|
||||||
|
|
||||||
Most of the features can be modified or disabled permanently, using global
|
Most of the features can be modified or disabled permanently, using global
|
||||||
variables, or on a FileType basis, using autocommands. With a couple of
|
variables, or on a FileType basis, using autocommands. With a couple of
|
||||||
exceptions and limitations, this features don't brake undo, redo or history.
|
exceptions and limitations, this features don't brake undo, redo or history.
|
||||||
|
|
||||||
|
NOTE 1: If you have any trouble with this plugin, please run |:DelimitMateTest|
|
||||||
|
in a new buffer to see what is not working.
|
||||||
|
|
||||||
|
NOTE 2: |'timeout'| needs to be set when working in the terminal, otherwise you
|
||||||
|
might find weird behaviour with mappings including <Esc> or arrow keys.
|
||||||
|
|
||||||
|
NOTE 3: Abbreiations set with |:iabbrev| will not be expanded by delimiters
|
||||||
|
used on delimitMate, you should use <C-]> (read |i_CTRL-]|) to expand them on
|
||||||
|
the go.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
2. FUNCTIONALITY *delimitMateFunctionality*
|
2. CUSTOMIZATION *delimitMateOptions*
|
||||||
|
|
||||||
|
You can create your own mappings for some features using the global functions.
|
||||||
|
Read |DelimitMateFunctions| for more info.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
2.1 AUTOMATIC CLOSING AND EXITING *delimitMateAutoClose*
|
2.1 OPTIONS SUMMARY *delimitMateOptionSummary*
|
||||||
|
|
||||||
|
The behaviour of this script can be customized setting the following options
|
||||||
|
in your vimrc file. You can use local options to set the configuration for
|
||||||
|
specific file types, see |delimitMateOptionDetails| for examples.
|
||||||
|
|
||||||
|
|'loaded_delimitMate'| Turns off the script.
|
||||||
|
|
||||||
|
|'delimitMate_autoclose'| Tells delimitMate whether to automagically
|
||||||
|
insert the closing delimiter.
|
||||||
|
|
||||||
|
|'delimitMate_matchpairs'| Tells delimitMate which characters are
|
||||||
|
matching pairs.
|
||||||
|
|
||||||
|
|'delimitMate_quotes'| Tells delimitMate which quotes should be
|
||||||
|
used.
|
||||||
|
|
||||||
|
|'delimitMate_nesting_quotes'| Tells delimitMate which quotes should be
|
||||||
|
allowed to be nested.
|
||||||
|
|
||||||
|
|'delimitMate_expand_cr'| Turns on/off the expansion of <CR>.
|
||||||
|
|
||||||
|
|'delimitMate_expand_space'| Turns on/off the expansion of <Space>.
|
||||||
|
|
||||||
|
|'delimitMate_smart_quotes'| Turns on/off the "smart quotes" feature.
|
||||||
|
|
||||||
|
|'delimitMate_balance_matchpairs'|Turns on/off the "balance matching pairs"
|
||||||
|
feature.
|
||||||
|
|
||||||
|
|'delimitMate_excluded_regions'| Turns off the script for the given regions or
|
||||||
|
syntax group names.
|
||||||
|
|
||||||
|
|'delimitMate_excluded_ft'| Turns off the script for the given file types.
|
||||||
|
|
||||||
|
|'delimitMate_apostrophes'| Tells delimitMate how it should "fix"
|
||||||
|
balancing of single quotes when used as
|
||||||
|
apostrophes. NOTE: Not needed any more, kept
|
||||||
|
for compatibility with older versions.
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
2.2 OPTIONS DETAILS *delimitMateOptionDetails*
|
||||||
|
|
||||||
|
Add the shown lines to your vimrc file in order to set the below options.
|
||||||
|
Buffer variables take precedence over global ones and can be used along with
|
||||||
|
autocmd to modify delimitMate's behavior for specific file types, read more in
|
||||||
|
|delimitMateFileType|.
|
||||||
|
|
||||||
|
Note: Use buffer variables only to set options for specific file types using
|
||||||
|
:autocmd, use global variables to set options for every buffer. Read more in
|
||||||
|
|g:var| and |b:var|.
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
*'loaded_delimitMate'*
|
||||||
|
*'b:loaded_delimitMate'*
|
||||||
|
This option prevents delimitMate from loading.
|
||||||
|
e.g.: >
|
||||||
|
let loaded_delimitMate = 1
|
||||||
|
au FileType mail let b:loaded_delimitMate = 1
|
||||||
|
<
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
*'delimitMate_autoclose'*
|
||||||
|
*'b:delimitMate_autoclose'*
|
||||||
|
Values: 0 or 1. ~
|
||||||
|
Default: 1 ~
|
||||||
|
|
||||||
|
If this option is set to 0, delimitMate will not add a closing delimiter
|
||||||
|
automagically. See |delimitMateAutoClose| for details.
|
||||||
|
e.g.: >
|
||||||
|
let delimitMate_autoclose = 0
|
||||||
|
au FileType mail let b:delimitMate_autoclose = 0
|
||||||
|
<
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
*'delimitMate_matchpairs'*
|
||||||
|
*'b:delimitMate_matchpairs'*
|
||||||
|
Values: A string with |'matchpairs'| syntax, plus support for multi-byte~
|
||||||
|
characters.~
|
||||||
|
Default: &matchpairs ~
|
||||||
|
|
||||||
|
Use this option to tell delimitMate which characters should be considered
|
||||||
|
matching pairs. Read |delimitMateAutoClose| for details.
|
||||||
|
e.g: >
|
||||||
|
let delimitMate_matchpairs = "(:),[:],{:},<:>"
|
||||||
|
au FileType vim,html let b:delimitMate_matchpairs = "(:),[:],{:},<:>"
|
||||||
|
<
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
*'delimitMate_quotes'*
|
||||||
|
*'b:delimitMate_quotes'*
|
||||||
|
Values: A string of characters separated by spaces. ~
|
||||||
|
Default: "\" ' `" ~
|
||||||
|
|
||||||
|
Use this option to tell delimitMate which characters should be considered as
|
||||||
|
quotes. Read |delimitMateAutoClose| for details.
|
||||||
|
e.g.: >
|
||||||
|
let delimitMate_quotes = "\" ' ` *"
|
||||||
|
au FileType html let b:delimitMate_quotes = "\" '"
|
||||||
|
<
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
*'delimitMate_nesting_quotes'*
|
||||||
|
*'b:delimitMate_nesting_quotes'*
|
||||||
|
Values: A list of quotes. ~
|
||||||
|
Default: [] ~
|
||||||
|
|
||||||
|
Quotes listed here will not be able to jump out of the empty pair, thus
|
||||||
|
allowing the autoclosed quotes to be nested.
|
||||||
|
e.g.: >
|
||||||
|
let delimitMate_nesting_quotes = ['"','`']
|
||||||
|
au FileType python let b:delimitMate_nesting_quotes = ['"']
|
||||||
|
<
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
*'delimitMate_expand_cr'*
|
||||||
|
*'b:delimitMate_expand_cr'*
|
||||||
|
Values: 1 or 0 ~
|
||||||
|
Default: 0 ~
|
||||||
|
|
||||||
|
This option turns on/off the expansion of <CR>. Read |delimitMateExpansion|
|
||||||
|
for details.
|
||||||
|
e.g.: >
|
||||||
|
let delimitMate_expand_cr = 1
|
||||||
|
au FileType mail let b:delimitMate_expand_cr = 1
|
||||||
|
<
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
*'delimitMate_expand_space'*
|
||||||
|
*'b:delimitMate_expand_space'*
|
||||||
|
Values: 1 or 0 ~
|
||||||
|
Default: 0 ~
|
||||||
|
|
||||||
|
This option turns on/off the expansion of <Space>. Read |delimitMateExpansion|
|
||||||
|
for details.
|
||||||
|
e.g.: >
|
||||||
|
let delimitMate_expand_space = 1
|
||||||
|
au FileType tcl let b:delimitMate_expand_space = 1
|
||||||
|
<
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
*'delimitMate_smart_quotes'*
|
||||||
|
*'b:delimitMate_smart_quotes'*
|
||||||
|
Values: 1 or 0 ~
|
||||||
|
Default: 1 ~
|
||||||
|
|
||||||
|
This option turns on/off the smart quotes feature. Read
|
||||||
|
|delimitMateSmartQuotes| for details.
|
||||||
|
e.g.: >
|
||||||
|
let delimitMate_smart_quotes = 0
|
||||||
|
au FileType tcl let b:delimitMate_smart_quotes = 0
|
||||||
|
<
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
*'delimitMate_balance_matchpairs'*
|
||||||
|
*'b:delimitMate_balance_matchpairs'*
|
||||||
|
Values: 1 or 0 ~
|
||||||
|
Default: 0 ~
|
||||||
|
|
||||||
|
This option turns on/off the balancing of matching pairs. Read
|
||||||
|
|delimitMateBalance| for details.
|
||||||
|
e.g.: >
|
||||||
|
let delimitMate_balance_matchpairs = 1
|
||||||
|
au FileType tcl let b:delimitMate_balance_matchpairs = 1
|
||||||
|
<
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
*'delimitMate_excluded_regions'*
|
||||||
|
Values: A string of syntax group names names separated by single commas. ~
|
||||||
|
Default: Comment ~
|
||||||
|
|
||||||
|
This options turns delimitMate off for the listed regions, read |group-name|
|
||||||
|
for more info about what is a region.
|
||||||
|
e.g.: >
|
||||||
|
let delimitMate_excluded_regions = "Comments,String"
|
||||||
|
<
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
*'delimitMate_excluded_ft'*
|
||||||
|
Values: A string of file type names separated by single commas. ~
|
||||||
|
Default: Empty. ~
|
||||||
|
|
||||||
|
This options turns delimitMate off for the listed file types, use this option
|
||||||
|
only if you don't want any of the features it provides on those file types.
|
||||||
|
e.g.: >
|
||||||
|
let delimitMate_excluded_ft = "mail,txt"
|
||||||
|
<
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
*'delimitMate_apostrophes'*
|
||||||
|
Values: Strings separated by ":". ~
|
||||||
|
Default: No longer used. ~
|
||||||
|
|
||||||
|
NOTE: This feature is turned off by default, it's been kept for compatibility
|
||||||
|
with older version, read |delimitMateSmartQuotes| for details.
|
||||||
|
If auto-close is enabled, this option tells delimitMate how to try to fix the
|
||||||
|
balancing of single quotes when used as apostrophes. The values of this option
|
||||||
|
are strings of text where a single quote would be used as an apostrophe (e.g.:
|
||||||
|
the "n't" of wouldn't or can't) separated by ":". Set it to an empty string to
|
||||||
|
disable this feature.
|
||||||
|
e.g.: >
|
||||||
|
let delimitMate_apostrophes = ""
|
||||||
|
au FileType tcl let delimitMate_apostrophes = ""
|
||||||
|
<
|
||||||
|
==============================================================================
|
||||||
|
3. FUNCTIONALITY *delimitMateFunctionality*
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
3.1 AUTOMATIC CLOSING AND EXITING *delimitMateAutoClose*
|
||||||
|
|
||||||
With automatic closing enabled, if an opening delimiter is inserted the plugin
|
With automatic closing enabled, if an opening delimiter is inserted the plugin
|
||||||
inserts the closing delimiter and places the cursor between the pair. With
|
inserts the closing delimiter and places the cursor between the pair. With
|
||||||
@@ -87,8 +300,11 @@ Without auto-close: >
|
|||||||
–––––––––-|––––––––––
|
–––––––––-|––––––––––
|
||||||
()<S-Tab> | ()|
|
()<S-Tab> | ()|
|
||||||
<
|
<
|
||||||
|
NOTE: Abbreviations will not be expanded by delimiters used on delimitMate,
|
||||||
|
you should use <C-]> (read |i_CTRL-]|) to expand them on the go.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
2.2 EXPANSION OF SPACE AND CAR RETURN *delimitMateExpansion*
|
3.2 EXPANSION OF SPACE AND CAR RETURN *delimitMateExpansion*
|
||||||
|
|
||||||
When the cursor is inside an empty pair of delimiters, <Space> and <CR> can be
|
When the cursor is inside an empty pair of delimiters, <Space> and <CR> can be
|
||||||
expanded, see |'delimitMate_expand_space'| and
|
expanded, see |'delimitMate_expand_space'| and
|
||||||
@@ -116,14 +332,15 @@ in expansions global, so they can be used to make custom mappings. Read
|
|||||||
|delimitMateFunctions| for more details.
|
|delimitMateFunctions| for more details.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
2.3 BACKSPACE *delimitMateBackspace*
|
3.3 BACKSPACE *delimitMateBackspace*
|
||||||
|
|
||||||
If you press backspace inside an empty pair, both delimiters are deleted. When
|
If you press backspace inside an empty pair, both delimiters are deleted. When
|
||||||
expansions are enabled, <BS> will also delete the expansions. NOTE that
|
expansions are enabled, <BS> will also delete the expansions. NOTE that
|
||||||
deleting <CR> expansions will brake the redo command.
|
deleting <CR> expansions will brake the redo command.
|
||||||
|
|
||||||
If you type shift + backspace instead, only the closing delimiter will be
|
If you type <S-BS> (shift + backspace) instead, only the closing delimiter
|
||||||
deleted.
|
will be deleted. NOTE that this will not usually work when using Vim from the
|
||||||
|
terminal, see 'delimitMate#JumpAny()' below to see how to fix it.
|
||||||
|
|
||||||
e.g. typing at the "|": >
|
e.g. typing at the "|": >
|
||||||
|
|
||||||
@@ -141,39 +358,40 @@ e.g. typing at the "|": >
|
|||||||
<
|
<
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
2.4 WRAPPING OF VISUAL SELECTION *delimitMateVisualWrapping*
|
3.4 SMART QUOTES *delimitMateSmartQuotes*
|
||||||
|
|
||||||
When visual mode is active this script allows for the selection to be enclosed
|
Only one quote will be inserted following a quote, a "\" or, following or
|
||||||
with delimiters. But, since brackets have special meaning in visual mode, a
|
preceding an alphanumeric character. This should cover closing quotes after a
|
||||||
leader (the value of 'mapleader' by default) should precede the delimiter.
|
string, opening quotes before a string, escaped quotes and apostrophes. Except
|
||||||
NOTE that this feature brakes the redo command and doesn't currently work on
|
for apostrophes, this feature can be disabled setting the option
|
||||||
blockwise visual mode, any suggestions will be welcome.
|
|
||||||
|
|
||||||
e.g. (selection represented between square brackets): >
|
|
||||||
|
|
||||||
Selected text | After \"
|
|
||||||
=============================================
|
|
||||||
An [absurd] example! | An "absurd" example!
|
|
||||||
<
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
2.5 SMART QUOTES *delimitMateSmartQuotes*
|
|
||||||
|
|
||||||
Only one quote will be inserted following a quote, a "\" or an alphanumeric
|
|
||||||
character. This should cover closing quotes, escaped quotes and apostrophes.
|
|
||||||
Except for apostrophes, this feature can be disabled setting the option
|
|
||||||
|'delimitMate_smart_quotes'| to 0.
|
|'delimitMate_smart_quotes'| to 0.
|
||||||
|
|
||||||
e.g. typing at the "|": >
|
e.g. typing at the "|": >
|
||||||
|
|
||||||
What | Before | After
|
What | Before | After
|
||||||
=======================================
|
=======================================
|
||||||
|
" | Text | | Text "|"
|
||||||
" | "String| | "String"|
|
" | "String| | "String"|
|
||||||
" | let i = "| | let i = "|"
|
" | let i = "| | let i = "|"
|
||||||
' | I| | I'|
|
'm | I| | I'm|
|
||||||
<
|
<
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
2.6 FILE TYPE BASED CONFIGURATION *delimitMateFileType*
|
3.5 BALANCING MATCHING PAIRS *delimitMateBalance*
|
||||||
|
|
||||||
|
When inserting an opening paren and |'delimitMate_balance_matchpairs'| is
|
||||||
|
enabled, delimitMate will try to balance the closing pairs in the current
|
||||||
|
line.
|
||||||
|
|
||||||
|
e.g. typing at the "|": >
|
||||||
|
|
||||||
|
What | Before | After
|
||||||
|
=======================================
|
||||||
|
( | |) | (|)
|
||||||
|
( | | | (|)
|
||||||
|
( | (|) | ((|))
|
||||||
|
<
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
3.6 FILE TYPE BASED CONFIGURATION *delimitMateFileType*
|
||||||
|
|
||||||
delimitMate options can be set globally for all buffers using global
|
delimitMate options can be set globally for all buffers using global
|
||||||
("regular") variables in your |vimrc| file. But |:autocmd| can be used to set
|
("regular") variables in your |vimrc| file. But |:autocmd| can be used to set
|
||||||
@@ -189,166 +407,23 @@ the following way: >
|
|||||||
| - File types for which the option will be set.
|
| - File types for which the option will be set.
|
||||||
- Don't forget to put this event.
|
- Don't forget to put this event.
|
||||||
<
|
<
|
||||||
NOTE that if you use buffer variables (|b:vars|) to set global settings in
|
NOTE that you should use buffer variables (|b:var|) only to set options with
|
||||||
your vimrc, those settings will be set for the first buffer, but they'll be
|
|:autocmd|, for global options use regular variables (|g:var|) in your vimrc.
|
||||||
ignored for new buffers and default values will be set.
|
|
||||||
==============================================================================
|
|
||||||
3. CUSTOMIZATION *delimitMateOptions*
|
|
||||||
|
|
||||||
You can create your own mappings for some features using the global functions.
|
|
||||||
Read |DelimitMateFunctions| for more info.
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
3.1 OPTIONS SUMMARY *delimitMateOptionSummary*
|
3.7 SYNTAX AWARENESS *delimitMateSyntax*
|
||||||
|
|
||||||
The behaviour of this script can be customized setting the following options
|
The features of this plug-in might not be always helpful, comments and strings
|
||||||
in your vimrc file. You can use local options to set the configuration for
|
usualy don't need auto-completion. delimitMate monitors which region is being
|
||||||
specific file types, see |delimitMateOptionDetails| for examples.
|
edited and if it detects that the cursor is in a comment it'll turn itself off
|
||||||
|
until the cursor leaves the comment. The excluded regions can be set using the
|
||||||
|
option |'delimitMate_excluded_regions'|. Read |group-name| for a list of
|
||||||
|
regions or syntax group names.
|
||||||
|
|
||||||
|'loaded_delimitMate'| Turns off the script.
|
NOTE that this feature relies on a proper syntax file for the current file
|
||||||
|
type, if the appropiate syntax file doesn't define a region, delimitMate won't
|
||||||
|
know about it.
|
||||||
|
|
||||||
|'delimitMate_autoclose'| Tells delimitMate whether to automagically
|
|
||||||
insert the closing delimiter.
|
|
||||||
|
|
||||||
|'delimitMate_matchpairs'| Tells delimitMate which characters are
|
|
||||||
matching pairs.
|
|
||||||
|
|
||||||
|'delimitMate_quotes'| Tells delimitMate which quotes should be
|
|
||||||
used.
|
|
||||||
|
|
||||||
|'delimitMate_visual_leader'| Sets the leader to be used in visual mode.
|
|
||||||
|
|
||||||
|'delimitMate_expand_cr'| Turns on/off the expansion of <CR>.
|
|
||||||
|
|
||||||
|'delimitMate_expand_space'| Turns on/off the expansion of <Space>.
|
|
||||||
|
|
||||||
|'delimitMate_excluded_ft'| Turns off the script for the given file types.
|
|
||||||
|
|
||||||
|'delimitMate_apostrophes'| Tells delimitMate how it should "fix"
|
|
||||||
balancing of single quotes when used as
|
|
||||||
apostrophes. NOTE: Not needed any more, kept
|
|
||||||
for compatibility with older versions.
|
|
||||||
|
|
||||||
|'delimitMate_smart_quotes'| Turns on/off the "smart quotes" feature.
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
3.2 OPTIONS DETAILS *delimitMateOptionDetails*
|
|
||||||
|
|
||||||
Add the shown lines to your vimrc file in order to set the below options.
|
|
||||||
Buffer variables take precedence over global ones and can be used along with
|
|
||||||
autocmd to modify delimitMate's behavior for specific file types, read more in
|
|
||||||
|delimitMateFileType|.
|
|
||||||
|
|
||||||
Note: Use buffer variables only to set options for specific file types using
|
|
||||||
:autocmd, use global variables to set options for every buffer. Read more in
|
|
||||||
|g:var| and |b:var|.
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
*'loaded_delimitMate'*
|
|
||||||
*'b:loaded_delimitMate'*
|
|
||||||
This option prevents delimitMate from loading.
|
|
||||||
e.g.: >
|
|
||||||
let loaded_delimitMate = 1
|
|
||||||
au FileType mail let b:loaded_delimitMate = 1
|
|
||||||
<
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
*'delimitMate_autoclose'*
|
|
||||||
*'b:delimitMate_autoclose'*
|
|
||||||
Values: 0 or 1. ~
|
|
||||||
Default: 1 ~
|
|
||||||
|
|
||||||
If this option is set to 0, delimitMate will not add a closing delimiter
|
|
||||||
automagically. See |delimitMateAutoClose| for details.
|
|
||||||
e.g.: >
|
|
||||||
let delimitMate_autoclose = 0
|
|
||||||
au FileType mail let b:delimitMate_autoclose = 0
|
|
||||||
<
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
*'delimitMate_matchpairs'*
|
|
||||||
*'b:delimitMate_matchpairs'*
|
|
||||||
Values: A string with |matchpairs| syntax. ~
|
|
||||||
Default: &matchpairs ~
|
|
||||||
|
|
||||||
Use this option to tell delimitMate which characters should be considered
|
|
||||||
matching pairs. Read |delimitMateAutoClose| for details.
|
|
||||||
e.g: >
|
|
||||||
let delimitMate_matchpairs = "(:),[:],{:},<:>"
|
|
||||||
au FileType vim,html let b:delimitMate_matchpairs = "(:),[:],{:},<:>"
|
|
||||||
<
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
*'delimitMate_quotes'*
|
|
||||||
*'b:delimitMate_quotes'*
|
|
||||||
Values: A string of characters separated by spaces. ~
|
|
||||||
Default: "\" ' `" ~
|
|
||||||
|
|
||||||
Use this option to tell delimitMate which characters should be considered as
|
|
||||||
quotes. Read |delimitMateAutoClose| for details.
|
|
||||||
e.g.: >
|
|
||||||
let b:delimitMate_quotes = "\" ' ` *"
|
|
||||||
au FileType html let b:delimitMate_quotes = "\" '"
|
|
||||||
<
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
*'delimitMate_visual_leader'*
|
|
||||||
*'b:delimitMate_visual_leader'*
|
|
||||||
Values: Any character. ~
|
|
||||||
Default: q ~
|
|
||||||
|
|
||||||
The value of this option will be used to wrap the selection in visual mode
|
|
||||||
when followed by a delimiter. Read |delimitMateVisualWrap| for details.
|
|
||||||
e.g: >
|
|
||||||
let delimitMate_visual_leader = "f"
|
|
||||||
au FileType html let b:delimitMate_visual_leader = "f"
|
|
||||||
<
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
*'delimitMate_expand_cr'*
|
|
||||||
*'b:delimitMate_expand_cr'*
|
|
||||||
Values: 1 or 0 ~
|
|
||||||
Default: 0 ~
|
|
||||||
|
|
||||||
This option turns on/off the expansion of <CR>. Read |delimitMateExpansion|
|
|
||||||
for details.
|
|
||||||
e.g.: >
|
|
||||||
let b:delimitMate_expand_cr = "\<CR>\<CR>\<Up>"
|
|
||||||
au FileType mail let b:delimitMate_expand_cr = "\<CR>"
|
|
||||||
<
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
*'delimitMate_expand_space'*
|
|
||||||
*'b:delimitMate_expand_space'*
|
|
||||||
Values: A key mapping. ~
|
|
||||||
Default: "\<Space>" ~
|
|
||||||
|
|
||||||
This option turns on/off the expansion of <Space>. Read |delimitMateExpansion|
|
|
||||||
for details.
|
|
||||||
e.g.: >
|
|
||||||
let delimitMate_expand_space = "\<Space>\<Space>\<Left>"
|
|
||||||
au FileType tcl let b:delimitMate_expand_space = "\<Space>"
|
|
||||||
<
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
*'delimitMate_excluded_ft'*
|
|
||||||
Values: A string of file type names separated by single commas. ~
|
|
||||||
Default: Empty. ~
|
|
||||||
|
|
||||||
This options turns delimitMate off for the listed file types, use this option
|
|
||||||
only if you don't want any of the features it provides on those file types.
|
|
||||||
e.g.: >
|
|
||||||
let delimitMate_excluded_ft = "mail,txt"
|
|
||||||
<
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
*'delimitMate_apostrophes'*
|
|
||||||
Values: Strings separated by ":". ~
|
|
||||||
Default: No longer used. ~
|
|
||||||
|
|
||||||
NOTE: This feature is turned off by default, it's been kept for compatibility
|
|
||||||
with older version, read |delimitMateSmartQuotes| for details.
|
|
||||||
If auto-close is enabled, this option tells delimitMate how to try to fix the
|
|
||||||
balancing of single quotes when used as apostrophes. The values of this option
|
|
||||||
are strings of text where a single quote would be used as an apostrophe (e.g.:
|
|
||||||
the "n't" of wouldn't or can't) separated by ":". Set it to an empty string to
|
|
||||||
disable this feature.
|
|
||||||
e.g.: >
|
|
||||||
let delimitMate_apostrophes = ""
|
|
||||||
au FileType tcl let delimitMate_apostrophes = ""
|
|
||||||
<
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
4. COMMANDS *delimitMateCommands*
|
4. COMMANDS *delimitMateCommands*
|
||||||
|
|
||||||
@@ -435,34 +510,68 @@ represented by an "|": >
|
|||||||
<
|
<
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
5. FUNCTIONS *delimitMateFunctions*
|
5. MAPPINGS *delimitMateMappings*
|
||||||
|
|
||||||
|
delimitMate doesn't override any existing map, so you may encounter that it
|
||||||
|
doesn't work as expected because a mapping is missing. In that case, the
|
||||||
|
conflicting mappings should be resolved by either disabling the conflicting
|
||||||
|
mapping or creating a custom mappings.
|
||||||
|
|
||||||
|
In order to make custom mappings easier and prevent overwritting existing
|
||||||
|
ones, delimitMate uses the |<Plug>| + |hasmapto()| (|usr_41.txt|) construct
|
||||||
|
for its mappings.
|
||||||
|
|
||||||
|
The following are the mappings alway set by delimitMate:
|
||||||
|
|
||||||
|
<BS> is mapped to <Plug>delimitMateBS
|
||||||
|
<S-BS> is mapped to <Plug>delimitMateS-BS
|
||||||
|
<S-Tab> is mapped to <Plug>delimitMateS-Tab
|
||||||
|
<Del> is mapped to <Plug>delimitMateDel
|
||||||
|
<Esc> is mapped to <Plug>delimitMateEsc
|
||||||
|
<Left> is mapped to <Plug>delimitMateLeft
|
||||||
|
<Right> is mapped to <Plug>delimitMateRight
|
||||||
|
<Home> is mapped to <Plug>delimitMateHome
|
||||||
|
<End> is mapped to <Plug>delimitMateEnd
|
||||||
|
<Up> is mapped to <Plug>delimitMateUp
|
||||||
|
<Down> is mapped to <Plug>delimitMateDown
|
||||||
|
<PageUp> is mapped to <Plug>delimitMatePageUp
|
||||||
|
<PageDown> is mapped to <Plug>delimitMatePageDown
|
||||||
|
<S-Down> is mapped to <Plug>delimitMateS-Down
|
||||||
|
<S-Up> is mapped to <Plug>delimitMateS-Up
|
||||||
|
<LeftMouse> is mapped to <Plug>delimitMateMLeftMouse
|
||||||
|
<RightMouse> is mapped to <Plug>delimitMateMRightMouse
|
||||||
|
|
||||||
|
The rest of the mappings correspond to parens, quotes, CR, Space, etc. and they
|
||||||
|
depend on the values of the delimitMate options, they have the following form:
|
||||||
|
|
||||||
|
<Plug>delimitMate + char
|
||||||
|
|
||||||
|
e.g.: for "(":
|
||||||
|
|
||||||
|
( is mapped to <Plug>delimitMate(
|
||||||
|
|
||||||
|
e.g.: If you have <CR> expansion enabled, you might want to skip it on pop-up
|
||||||
|
menus:
|
||||||
|
|
||||||
|
imap <expr> <CR> pumvisible() ?
|
||||||
|
\"\<c-y>" :
|
||||||
|
\ "<Plug>delimitMateCR"
|
||||||
|
|
||||||
|
|
||||||
|
==============================================================================
|
||||||
|
6. FUNCTIONS *delimitMateFunctions*
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
delimitMate#WithinEmptyPair() *delimitMate_WithinEmptyPair*
|
delimitMate#WithinEmptyPair() *delimitMate_WithinEmptyPair()*
|
||||||
|
|
||||||
Returns 1 if the cursor is inside an empty pair, 0 otherwise.
|
Returns 1 if the cursor is inside an empty pair, 0 otherwise.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
delimitMate#ExpandReturn() *delimitMate#ExpandReturn()*
|
|
||||||
|
|
||||||
Returns the expansion for <CR>.
|
|
||||||
|
|
||||||
e.g.: This mapping could be used to select an item on a pop-up menu or expand
|
|
||||||
<CR> inside an empty pair: >
|
|
||||||
|
|
||||||
inoremap <expr> <CR> pumvisible() ? "\<c-y>" :
|
|
||||||
\ delimitMate#WithinEmptyPair() ?
|
|
||||||
\ delimitMate#ExpandReturn() : "\<CR>"
|
|
||||||
<
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
delimitMate#ExpandSpace() *delimitMate#ExpandSpace()*
|
|
||||||
|
|
||||||
Returns the expansion for <Space>.
|
|
||||||
e.g.: >
|
e.g.: >
|
||||||
|
|
||||||
inoremap <expr> <Space> delimitMate#WithinEmptyPair() ?
|
inoremap <expr> <CR> delimitMate#WithinEmptyPair() ?
|
||||||
\ delimitMate#ExpandSpace() : "\<Space>"
|
\ "\<C-R>=delimitMate#ExpandReturn()\<CR>" :
|
||||||
|
\ "external_mapping"
|
||||||
<
|
<
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
delimitMate#ShouldJump() *delimitMate#ShouldJump()*
|
delimitMate#ShouldJump() *delimitMate#ShouldJump()*
|
||||||
|
|
||||||
@@ -470,24 +579,23 @@ Returns 1 if there is a closing delimiter or a quote to the right of the
|
|||||||
cursor, 0 otherwise.
|
cursor, 0 otherwise.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
delimitMate#JumpAny() *delimitMate#JumpAny()*
|
delimitMate#JumpAny(key) *delimitMate#JumpAny()*
|
||||||
|
|
||||||
This function returns a mapping that will make the cursor jump to the right.
|
This function returns a mapping that will make the cursor jump to the right
|
||||||
|
when delimitMate#ShouldJump() returns 1, returns the argument "key" otherwise.
|
||||||
e.g.: You can use this to create your own mapping to jump over any delimiter.
|
e.g.: You can use this to create your own mapping to jump over any delimiter.
|
||||||
>
|
>
|
||||||
inoremap <expr> <C-Tab> delimitMate#ShouldJump() ?
|
inoremap <C-Tab> <C-R>=delimitMate#JumpAny("\<C-Tab>")<CR>
|
||||||
\ delimitMate#JumpAny() : "\<C-Tab>"
|
|
||||||
<
|
<
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
6. TODO LIST *delimitMateTodo*
|
7. TODO LIST *delimitMateTodo*
|
||||||
|
|
||||||
- Automatic set-up by file type.
|
- Automatic set-up by file type.
|
||||||
- Make visual wrapping work on blockwise visual mode.
|
- Make block-wise visual wrapping work on un-even regions.
|
||||||
- Limit behaviour by region.
|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
7. MAINTAINER *delimitMateMaintainer*
|
8. MAINTAINER *delimitMateMaintainer*
|
||||||
|
|
||||||
Hi there! My name is Israel Chauca F. and I can be reached at:
|
Hi there! My name is Israel Chauca F. and I can be reached at:
|
||||||
mailto:israelchauca@gmail.com
|
mailto:israelchauca@gmail.com
|
||||||
@@ -496,7 +604,7 @@ Feel free to send me any suggestions and/or comments about this plugin, I'll
|
|||||||
be very pleased to read them.
|
be very pleased to read them.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
8. CREDITS *delimitMateCredits*
|
9. CREDITS *delimitMateCredits*
|
||||||
|
|
||||||
Some of the code that make this script is modified or just shamelessly copied
|
Some of the code that make this script is modified or just shamelessly copied
|
||||||
from the following sources:
|
from the following sources:
|
||||||
@@ -509,26 +617,74 @@ from the following sources:
|
|||||||
From the comments on the previous blog post and from:
|
From the comments on the previous blog post and from:
|
||||||
http://gist.github.com/144619
|
http://gist.github.com/144619
|
||||||
|
|
||||||
- Vim Scripts:
|
- Karl Guertin
|
||||||
http://www.vim.org/scripts
|
AutoClose:
|
||||||
|
http://www.vim.org/scripts/script.php?script_id=1849
|
||||||
|
|
||||||
This script was inspired by the auto-completion of delimiters of TextMate.
|
- Thiago Alves
|
||||||
|
AutoClose:
|
||||||
|
http://www.vim.org/scripts/script.php?script_id=2009
|
||||||
|
|
||||||
|
- Edoardo Vacchi
|
||||||
|
ClosePairs:
|
||||||
|
http://www.vim.org/scripts/script.php?script_id=2373
|
||||||
|
|
||||||
|
This script was inspired by the auto-completion of delimiters on TextMate.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
9. HISTORY *delimitMateHistory*
|
10. HISTORY *delimitMateHistory*
|
||||||
|
|
||||||
Version Date Release notes ~
|
Version Date Release notes ~
|
||||||
|---------|------------|-----------------------------------------------------|
|
|---------|------------|-----------------------------------------------------|
|
||||||
2.2 2010-05-16 * Current release:
|
2.5.1 2010-09-30 * Current release:
|
||||||
- Added command to switch the plug-in on and off.
|
- Remove visual wrapping. Surround.vim offers a much
|
||||||
|
better implementation.
|
||||||
|
- Minor mods to DelimitMateTest.
|
||||||
|
|---------|------------|-----------------------------------------------------|
|
||||||
|
2.5 2010-09-22 * - Better handling of mappings.
|
||||||
|
- Add report for mappings in |:DelimitMateTest|.
|
||||||
|
- Allow the use of "|" and multi-byte characters in
|
||||||
|
|'delimitMate_quotes'| and |'delimitMate_matchpairs'|.
|
||||||
|
- Allow commands to be concatenated using |.
|
||||||
|
|---------|------------|-----------------------------------------------------|
|
||||||
|
2.4.1 2010-07-31 * - Fix problem with <Home> and <End>.
|
||||||
|
- Add missing doc on |'delimitMate_smart_quotes'|,
|
||||||
|
|delimitMateBalance| and
|
||||||
|
|'delimitMate_balance_matchpairs'|.
|
||||||
|
|---------|------------|-----------------------------------------------------|
|
||||||
|
2.4 2010-07-29 * - Unbalanced parens: see :help delimitMateBalance.
|
||||||
|
- Visual wrapping now works on block-wise visual
|
||||||
|
with some limitations.
|
||||||
|
- Arrow keys didn't work on terminal.
|
||||||
|
- Added option to allow nested quotes.
|
||||||
|
- Expand Smart Quotes to look for a string on the
|
||||||
|
right of the cursor.
|
||||||
|
|
||||||
|
|---------|------------|-----------------------------------------------------|
|
||||||
|
2.3.1 2010-06-06 * - Fix: an extra <Space> is inserted after <Space>
|
||||||
|
expansion.
|
||||||
|
|
||||||
|
|---------|------------|-----------------------------------------------------|
|
||||||
|
2.3 2010-06-06 * - Syntax aware: Will turn off when editing comments
|
||||||
|
or other regions, customizable.
|
||||||
|
- Changed format of most mappings.
|
||||||
|
- Fix: <CR> expansion doesn't brake automatic
|
||||||
|
indentation adjustments anymore.
|
||||||
|
- Fix: Arrow keys would insert A, B, C or D instead
|
||||||
|
of moving the cursor when using Vim on a terminal.
|
||||||
|
|
||||||
|
|---------|------------|-----------------------------------------------------|
|
||||||
|
2.2 2010-05-16 * - Added command to switch the plug-in on and off.
|
||||||
- Fix: some problems with <Left>, <Right> and <CR>.
|
- Fix: some problems with <Left>, <Right> and <CR>.
|
||||||
- Fix: A small problem when inserting a delimiter at
|
- Fix: A small problem when inserting a delimiter at
|
||||||
the beginning of the line.
|
the beginning of the line.
|
||||||
|
|
||||||
|---------|------------|-----------------------------------------------------|
|
|---------|------------|-----------------------------------------------------|
|
||||||
2.1 2010-05-10 * - Most of the functions have been moved to an
|
2.1 2010-05-10 * - Most of the functions have been moved to an
|
||||||
autoload script to avoid loading unnecessary ones.
|
autoload script to avoid loading unnecessary ones.
|
||||||
- Fixed a problem with the redo command.
|
- Fixed a problem with the redo command.
|
||||||
- Many small fixes.
|
- Many small fixes.
|
||||||
|
|
||||||
|---------|------------|-----------------------------------------------------|
|
|---------|------------|-----------------------------------------------------|
|
||||||
2.0 2010-04-01 * New features:
|
2.0 2010-04-01 * New features:
|
||||||
- All features are redo/undo-wise safe.
|
- All features are redo/undo-wise safe.
|
||||||
@@ -544,7 +700,6 @@ This script was inspired by the auto-completion of delimiters of TextMate.
|
|||||||
active if you have any of the expansion options
|
active if you have any of the expansion options
|
||||||
set.
|
set.
|
||||||
- <S-Backspace> deletes the closing delimiter.
|
- <S-Backspace> deletes the closing delimiter.
|
||||||
|
|
||||||
* Fixed bug:
|
* Fixed bug:
|
||||||
- s:vars were being used to store buffer options.
|
- s:vars were being used to store buffer options.
|
||||||
|
|
||||||
@@ -596,9 +751,11 @@ This script was inspired by the auto-completion of delimiters of TextMate.
|
|||||||
|---------|------------|-----------------------------------------------------|
|
|---------|------------|-----------------------------------------------------|
|
||||||
|
|
||||||
|
|
||||||
... |"| _ _ . . ___ ~
|
`\|||/´ MMM \|/ www __^__ ~
|
||||||
o,*,(o o) _|_|_ o' \,=./ `o . .:::. /_\ `* ~
|
(o o) (o o) @ @ (O-O) /(o o)\\ ~
|
||||||
8(o o)(_)Ooo (o o) (o o) :(o o): . (o o) ~
|
ooO_(_)_Ooo__ ooO_(_)_Ooo___oOO_(_)_OOo___oOO__(_)__OOo___oOO__(_)__OOo_____ ~
|
||||||
---ooO-(_)---Ooo----ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo- ~
|
_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|____ ~
|
||||||
|
__|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_ ~
|
||||||
|
_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|____ ~
|
||||||
|
|
||||||
vim:tw=78:ts=8:ft=help:norl:formatoptions+=tcroqn:autoindent:
|
vim:tw=78:et:ts=2:sw=2:ft=help:norl:formatoptions+=tcroqn:autoindent:
|
||||||
|
|||||||
@@ -1,156 +1,43 @@
|
|||||||
" ============================================================================
|
|
||||||
" File: autoload/delimitMate.vim
|
" File: autoload/delimitMate.vim
|
||||||
" Version: 2.2
|
" Version: 2.6
|
||||||
" Modified: 2010-05-16
|
" Modified: 2011-01-14
|
||||||
" Description: This plugin provides auto-completion for quotes, parens, etc.
|
" Description: This plugin provides auto-completion for quotes, parens, etc.
|
||||||
" Maintainer: Israel Chauca F. <israelchauca@gmail.com>
|
" Maintainer: Israel Chauca F. <israelchauca@gmail.com>
|
||||||
" Manual: Read ":help delimitMate".
|
" Manual: Read ":help delimitMate".
|
||||||
|
" ============================================================================
|
||||||
|
|
||||||
" Utilities {{{
|
" Utilities {{{
|
||||||
function! delimitMate#Init() "{{{
|
|
||||||
|
|
||||||
" delimitMate_autoclose {{{
|
let delimitMate_loaded = 1
|
||||||
if !exists("b:delimitMate_autoclose") && !exists("g:delimitMate_autoclose")
|
|
||||||
let b:delimitMate_autoclose = 1
|
|
||||||
elseif !exists("b:delimitMate_autoclose") && exists("g:delimitMate_autoclose")
|
|
||||||
let b:delimitMate_autoclose = g:delimitMate_autoclose
|
|
||||||
else
|
|
||||||
" Nothing to do.
|
|
||||||
endif " }}}
|
|
||||||
|
|
||||||
" delimitMate_matchpairs {{{
|
|
||||||
if !exists("b:delimitMate_matchpairs") && !exists("g:delimitMate_matchpairs")
|
|
||||||
let s:matchpairs_temp = &matchpairs
|
|
||||||
elseif exists("b:delimitMate_matchpairs")
|
|
||||||
let s:matchpairs_temp = b:delimitMate_matchpairs
|
|
||||||
else
|
|
||||||
let s:matchpairs_temp = g:delimitMate_matchpairs
|
|
||||||
endif " }}}
|
|
||||||
|
|
||||||
" delimitMate_quotes {{{
|
|
||||||
if exists("b:delimitMate_quotes")
|
|
||||||
let s:quotes = split(b:delimitMate_quotes)
|
|
||||||
elseif exists("g:delimitMate_quotes")
|
|
||||||
let s:quotes = split(g:delimitMate_quotes)
|
|
||||||
else
|
|
||||||
let s:quotes = split("\" ' `")
|
|
||||||
endif
|
|
||||||
let b:delimitMate_quotes_list = s:quotes " }}}
|
|
||||||
|
|
||||||
" delimitMate_excluded_regions {{{
|
|
||||||
if exists("b:delimitMate_excluded_regions")
|
|
||||||
let s:excluded_regions = b:delimitMate_excluded_regions
|
|
||||||
elseif exists("g:delimitMate_excluded_regions")
|
|
||||||
let s:excluded_regions = g:delimitMate_excluded_regions
|
|
||||||
else
|
|
||||||
let s:excluded_regions = "Comment"
|
|
||||||
endif
|
|
||||||
let b:delimitMate_excluded_regions_list = split(s:excluded_regions, ',\s*')
|
|
||||||
let b:delimitMate_excluded_regions_enabled = len(b:delimitMate_excluded_regions_list) " }}}
|
|
||||||
|
|
||||||
" delimitMate_visual_leader {{{
|
|
||||||
if !exists("b:delimitMate_visual_leader") && !exists("g:delimitMate_visual_leader")
|
|
||||||
let b:delimitMate_visual_leader = exists('b:maplocalleader') ? b:maplocalleader :
|
|
||||||
\ exists('g:mapleader') ? g:mapleader : "\\"
|
|
||||||
elseif !exists("b:delimitMate_visual_leader") && exists("g:delimitMate_visual_leader")
|
|
||||||
let b:delimitMate_visual_leader = g:delimitMate_visual_leader
|
|
||||||
else
|
|
||||||
" Nothing to do.
|
|
||||||
endif " }}}
|
|
||||||
|
|
||||||
" delimitMate_expand_space {{{
|
|
||||||
if !exists("b:delimitMate_expand_space") && !exists("g:delimitMate_expand_space")
|
|
||||||
let b:delimitMate_expand_space = 0
|
|
||||||
elseif !exists("b:delimitMate_expand_space") && exists("g:delimitMate_expand_space")
|
|
||||||
let b:delimitMate_expand_space = g:delimitMate_expand_space
|
|
||||||
else
|
|
||||||
" Nothing to do.
|
|
||||||
endif " }}}
|
|
||||||
|
|
||||||
" delimitMate_expand_cr {{{
|
|
||||||
if !exists("b:delimitMate_expand_cr") && !exists("g:delimitMate_expand_cr")
|
|
||||||
let b:delimitMate_expand_cr = 0
|
|
||||||
elseif !exists("b:delimitMate_expand_cr") && exists("g:delimitMate_expand_cr")
|
|
||||||
let b:delimitMate_expand_cr = g:delimitMate_expand_cr
|
|
||||||
else
|
|
||||||
" Nothing to do.
|
|
||||||
endif " }}}
|
|
||||||
|
|
||||||
" delimitMate_smart_quotes {{{
|
|
||||||
if !exists("b:delimitMate_smart_quotes") && !exists("g:delimitMate_smart_quotes")
|
|
||||||
let b:delimitMate_smart_quotes = 1
|
|
||||||
elseif !exists("b:delimitMate_smart_quotes") && exists("g:delimitMate_smart_quotes")
|
|
||||||
let b:delimitMate_smart_quotes = split(g:delimitMate_smart_quotes)
|
|
||||||
else
|
|
||||||
" Nothing to do.
|
|
||||||
endif " }}}
|
|
||||||
|
|
||||||
" delimitMate_apostrophes {{{
|
|
||||||
if !exists("b:delimitMate_apostrophes") && !exists("g:delimitMate_apostrophes")
|
|
||||||
"let s:apostrophes = split("n't:'s:'re:'m:'d:'ll:'ve:s'",':')
|
|
||||||
let s:apostrophes = []
|
|
||||||
elseif !exists("b:delimitMate_apostrophes") && exists("g:delimitMate_apostrophes")
|
|
||||||
let s:apostrophes = split(g:delimitMate_apostrophes)
|
|
||||||
else
|
|
||||||
let s:apostrophes = split(b:delimitMate_apostrophes)
|
|
||||||
endif
|
|
||||||
let b:delimitMate_apostrophes_list = s:apostrophes " }}}
|
|
||||||
|
|
||||||
" delimitMate_tab2exit {{{
|
|
||||||
if !exists("b:delimitMate_tab2exit") && !exists("g:delimitMate_tab2exit")
|
|
||||||
let b:delimitMate_tab2exit = 1
|
|
||||||
elseif !exists("b:delimitMate_tab2exit") && exists("g:delimitMate_tab2exit")
|
|
||||||
let b:delimitMate_tab2exit = g:delimitMate_tab2exit
|
|
||||||
else
|
|
||||||
" Nothing to do.
|
|
||||||
endif " }}}
|
|
||||||
|
|
||||||
let b:delimitMate_matchpairs_list = split(s:matchpairs_temp, ',')
|
|
||||||
let b:delimitMate_left_delims = split(s:matchpairs_temp, ':.,\=')
|
|
||||||
let b:delimitMate_right_delims = split(s:matchpairs_temp, ',\=.:')
|
|
||||||
|
|
||||||
let b:delimitMate_buffer = []
|
|
||||||
|
|
||||||
call delimitMate#UnMap()
|
|
||||||
if b:delimitMate_autoclose
|
|
||||||
call delimitMate#AutoClose()
|
|
||||||
else
|
|
||||||
call delimitMate#NoAutoClose()
|
|
||||||
endif
|
|
||||||
call delimitMate#VisualMaps()
|
|
||||||
call delimitMate#ExtraMappings()
|
|
||||||
|
|
||||||
let b:loaded_delimitMate = 1
|
|
||||||
let b:delimitMate_enabled = 1
|
|
||||||
endfunction "}}} Init()
|
|
||||||
|
|
||||||
function! delimitMate#ShouldJump() "{{{
|
function! delimitMate#ShouldJump() "{{{
|
||||||
|
" Returns 1 if the next character is a closing delimiter.
|
||||||
let col = col('.')
|
let col = col('.')
|
||||||
let lcol = col('$')
|
let lcol = col('$')
|
||||||
let char = getline('.')[col - 1]
|
let char = getline('.')[col - 1]
|
||||||
let nchar = getline('.')[col]
|
|
||||||
let uchar = getline(line('.') + 1)[0]
|
|
||||||
|
|
||||||
for cdel in b:delimitMate_right_delims + b:delimitMate_quotes_list
|
" Closing delimiter on the right.
|
||||||
|
for cdel in b:_l_delimitMate_right_delims + b:_l_delimitMate_quotes_list
|
||||||
if char == cdel
|
if char == cdel
|
||||||
" Closing delimiter on the right.
|
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
if b:delimitMate_expand_space && char == " "
|
" Closing delimiter with space expansion.
|
||||||
for cdel in b:delimitMate_right_delims + b:delimitMate_quotes_list
|
let nchar = getline('.')[col]
|
||||||
|
if b:_l_delimitMate_expand_space && char == " "
|
||||||
|
for cdel in b:_l_delimitMate_right_delims + b:_l_delimitMate_quotes_list
|
||||||
if nchar == cdel
|
if nchar == cdel
|
||||||
" Closing delimiter with space expansion.
|
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if b:delimitMate_expand_cr && char == ""
|
" Closing delimiter with CR expansion.
|
||||||
for cdel in b:delimitMate_right_delims + b:delimitMate_quotes_list
|
let uchar = getline(line('.') + 1)[0]
|
||||||
|
if b:_l_delimitMate_expand_cr && char == ""
|
||||||
|
for cdel in b:_l_delimitMate_right_delims + b:_l_delimitMate_quotes_list
|
||||||
if uchar == cdel
|
if uchar == cdel
|
||||||
" Closing delimiter with CR expansion.
|
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
@@ -159,71 +46,13 @@ function! delimitMate#ShouldJump() "{{{
|
|||||||
return 0
|
return 0
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! delimitMate#IsBlockVisual() " {{{
|
|
||||||
if mode() == "\<C-V>"
|
|
||||||
return 1
|
|
||||||
endif
|
|
||||||
" Store unnamed register values for later use in delimitMate#RestoreRegister().
|
|
||||||
let b:save_reg = getreg('"')
|
|
||||||
let b:save_reg_mode = getregtype('"')
|
|
||||||
|
|
||||||
if len(getline('.')) == 0
|
|
||||||
" This for proper wrap of empty lines.
|
|
||||||
let @" = "\n"
|
|
||||||
endif
|
|
||||||
return 0
|
|
||||||
endfunction " }}}
|
|
||||||
|
|
||||||
function! delimitMate#Visual(del) " {{{
|
|
||||||
let mode = mode()
|
|
||||||
if mode == "\<C-V>"
|
|
||||||
redraw
|
|
||||||
echom "delimitMate: delimitMate is disabled on blockwise visual mode."
|
|
||||||
return ""
|
|
||||||
endif
|
|
||||||
" Store unnamed register values for later use in delimitMate#RestoreRegister().
|
|
||||||
let b:save_reg = getreg('"')
|
|
||||||
let b:save_reg_mode = getregtype('"')
|
|
||||||
|
|
||||||
if len(getline('.')) == 0
|
|
||||||
" This for proper wrap of empty lines.
|
|
||||||
let @" = "\n"
|
|
||||||
endif
|
|
||||||
|
|
||||||
if mode ==# "V"
|
|
||||||
let dchar = "\<BS>"
|
|
||||||
else
|
|
||||||
let dchar = ""
|
|
||||||
endif
|
|
||||||
|
|
||||||
let index = index(b:delimitMate_left_delims, a:del)
|
|
||||||
if index >= 0
|
|
||||||
let ld = a:del
|
|
||||||
let rd = b:delimitMate_right_delims[index]
|
|
||||||
endif
|
|
||||||
|
|
||||||
let index = index(b:delimitMate_right_delims, a:del)
|
|
||||||
if index >= 0
|
|
||||||
let ld = b:delimitMate_left_delims[index]
|
|
||||||
let rd = a:del
|
|
||||||
endif
|
|
||||||
|
|
||||||
let index = index(b:delimitMate_quotes_list, a:del)
|
|
||||||
if index >= 0
|
|
||||||
let ld = a:del
|
|
||||||
let rd = ld
|
|
||||||
endif
|
|
||||||
|
|
||||||
return "s" . ld . "\<C-R>\"" . dchar . rd . "\<Esc>:call delimitMate#RestoreRegister()\<CR>"
|
|
||||||
endfunction " }}}
|
|
||||||
|
|
||||||
function! delimitMate#IsEmptyPair(str) "{{{
|
function! delimitMate#IsEmptyPair(str) "{{{
|
||||||
for pair in b:delimitMate_matchpairs_list
|
for pair in b:_l_delimitMate_matchpairs_list
|
||||||
if a:str == join( split( pair, ':' ),'' )
|
if a:str == join( split( pair, ':' ),'' )
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
for quote in b:delimitMate_quotes_list
|
for quote in b:_l_delimitMate_quotes_list
|
||||||
if a:str == quote . quote
|
if a:str == quote . quote
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
@@ -235,12 +64,12 @@ function! delimitMate#IsCRExpansion() " {{{
|
|||||||
let nchar = getline(line('.')-1)[-1:]
|
let nchar = getline(line('.')-1)[-1:]
|
||||||
let schar = getline(line('.')+1)[:0]
|
let schar = getline(line('.')+1)[:0]
|
||||||
let isEmpty = getline('.') == ""
|
let isEmpty = getline('.') == ""
|
||||||
if index(b:delimitMate_left_delims, nchar) > -1 &&
|
if index(b:_l_delimitMate_left_delims, nchar) > -1 &&
|
||||||
\ index(b:delimitMate_left_delims, nchar) == index(b:delimitMate_right_delims, schar) &&
|
\ index(b:_l_delimitMate_left_delims, nchar) == index(b:_l_delimitMate_right_delims, schar) &&
|
||||||
\ isEmpty
|
\ isEmpty
|
||||||
return 1
|
return 1
|
||||||
elseif index(b:delimitMate_quotes_list, nchar) > -1 &&
|
elseif index(b:_l_delimitMate_quotes_list, nchar) > -1 &&
|
||||||
\ index(b:delimitMate_quotes_list, nchar) == index(b:delimitMate_quotes_list, schar) &&
|
\ index(b:_l_delimitMate_quotes_list, nchar) == index(b:_l_delimitMate_quotes_list, schar) &&
|
||||||
\ isEmpty
|
\ isEmpty
|
||||||
return 1
|
return 1
|
||||||
else
|
else
|
||||||
@@ -256,12 +85,12 @@ function! delimitMate#IsSpaceExpansion() " {{{
|
|||||||
let nchar = line[col + 2]
|
let nchar = line[col + 2]
|
||||||
let isSpaces = (line[col] == line[col+1] && line[col] == " ")
|
let isSpaces = (line[col] == line[col+1] && line[col] == " ")
|
||||||
|
|
||||||
if index(b:delimitMate_left_delims, pchar) > -1 &&
|
if index(b:_l_delimitMate_left_delims, pchar) > -1 &&
|
||||||
\ index(b:delimitMate_left_delims, pchar) == index(b:delimitMate_right_delims, nchar) &&
|
\ index(b:_l_delimitMate_left_delims, pchar) == index(b:_l_delimitMate_right_delims, nchar) &&
|
||||||
\ isSpaces
|
\ isSpaces
|
||||||
return 1
|
return 1
|
||||||
elseif index(b:delimitMate_quotes_list, pchar) > -1 &&
|
elseif index(b:_l_delimitMate_quotes_list, pchar) > -1 &&
|
||||||
\ index(b:delimitMate_quotes_list, pchar) == index(b:delimitMate_quotes_list, nchar) &&
|
\ index(b:_l_delimitMate_quotes_list, pchar) == index(b:_l_delimitMate_quotes_list, nchar) &&
|
||||||
\ isSpaces
|
\ isSpaces
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
@@ -298,14 +127,16 @@ function! delimitMate#WriteAfter(str) "{{{
|
|||||||
return ''
|
return ''
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
|
|
||||||
function! delimitMate#RestoreRegister() " {{{
|
function! delimitMate#GetSyntaxRegion(line, col) "{{{
|
||||||
" Restore unnamed register values store in delimitMate#IsBlockVisual().
|
return synIDattr(synIDtrans(synID(a:line, a:col, 1)), 'name')
|
||||||
call setreg('"', b:save_reg, b:save_reg_mode)
|
|
||||||
echo ""
|
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
|
|
||||||
function! delimitMate#GetCurrentSyntaxRegion() "{{{
|
function! delimitMate#GetCurrentSyntaxRegion() "{{{
|
||||||
return synIDattr(synIDtrans(synID(line('.'), col('.'), 1)), 'name')
|
let col = col('.')
|
||||||
|
if col == col('$')
|
||||||
|
let col = col - 1
|
||||||
|
endif
|
||||||
|
return delimitMate#GetSyntaxRegion(line('.'), col)
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
|
|
||||||
function! delimitMate#GetCurrentSyntaxRegionIf(char) "{{{
|
function! delimitMate#GetCurrentSyntaxRegionIf(char) "{{{
|
||||||
@@ -313,76 +144,91 @@ function! delimitMate#GetCurrentSyntaxRegionIf(char) "{{{
|
|||||||
let origin_line = getline('.')
|
let origin_line = getline('.')
|
||||||
let changed_line = strpart(origin_line, 0, col - 1) . a:char . strpart(origin_line, col - 1)
|
let changed_line = strpart(origin_line, 0, col - 1) . a:char . strpart(origin_line, col - 1)
|
||||||
call setline('.', changed_line)
|
call setline('.', changed_line)
|
||||||
let region = synIDattr(synIDtrans(synID(line('.'), col, 1)), 'name')
|
let region = delimitMate#GetSyntaxRegion(line('.'), col)
|
||||||
call setline('.', origin_line)
|
call setline('.', origin_line)
|
||||||
return region
|
return region
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! delimitMate#IsForbidden(char) "{{{
|
function! delimitMate#IsForbidden(char) "{{{
|
||||||
if b:delimitMate_excluded_regions_enabled = 0
|
if b:_l_delimitMate_excluded_regions_enabled == 0
|
||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
let result = index(b:delimitMate_excluded_regions_list, delimitMate#GetCurrentSyntaxRegion()) >= 0
|
"let result = index(b:_l_delimitMate_excluded_regions_list, delimitMate#GetCurrentSyntaxRegion()) >= 0
|
||||||
if result >= 0
|
if index(b:_l_delimitMate_excluded_regions_list, delimitMate#GetCurrentSyntaxRegion()) >= 0
|
||||||
return result + 1
|
"echom "Forbidden 1!"
|
||||||
|
return 1
|
||||||
endif
|
endif
|
||||||
let region = delimitMate#GetCurrentSyntaxRegionIf(a:char)
|
let region = delimitMate#GetCurrentSyntaxRegionIf(a:char)
|
||||||
let result = index(b:delimitMate_excluded_regions_list, region) >= 0
|
"let result = index(b:_l_delimitMate_excluded_regions_list, region) >= 0
|
||||||
"return result || region == 'Comment'
|
"return result || region == 'Comment'
|
||||||
return result + 1
|
"echom "Forbidden 2!"
|
||||||
|
return index(b:_l_delimitMate_excluded_regions_list, region) >= 0
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! delimitMate#FlushBuffer() " {{{
|
function! delimitMate#FlushBuffer() " {{{
|
||||||
let b:delimitMate_buffer = []
|
let b:_l_delimitMate_buffer = []
|
||||||
return ''
|
return ''
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
|
|
||||||
|
function! delimitMate#BalancedParens(char) "{{{
|
||||||
|
" Returns:
|
||||||
|
" = 0 => Parens balanced.
|
||||||
|
" > 0 => More opening parens.
|
||||||
|
" < 0 => More closing parens.
|
||||||
|
|
||||||
|
let line = getline('.')
|
||||||
|
let col = col('.') - 2
|
||||||
|
let col = col >= 0 ? col : 0
|
||||||
|
let list = split(line, '\zs')
|
||||||
|
let left = b:_l_delimitMate_left_delims[index(b:_l_delimitMate_right_delims, a:char)]
|
||||||
|
let right = a:char
|
||||||
|
let opening = 0
|
||||||
|
let closing = 0
|
||||||
|
|
||||||
|
" If the cursor is not at the beginning, count what's behind it.
|
||||||
|
if col > 0
|
||||||
|
" Find the first opening paren:
|
||||||
|
let start = index(list, left)
|
||||||
|
" Must be before cursor:
|
||||||
|
let start = start < col ? start : col - 1
|
||||||
|
" Now count from the first opening until the cursor, this will prevent
|
||||||
|
" extra closing parens from being counted.
|
||||||
|
let opening = count(list[start : col - 1], left)
|
||||||
|
let closing = count(list[start : col - 1], right)
|
||||||
|
" I don't care if there are more closing parens than opening parens.
|
||||||
|
let closing = closing > opening ? opening : closing
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Evaluate parens from the cursor to the end:
|
||||||
|
let opening += count(list[col :], left)
|
||||||
|
let closing += count(list[col :], right)
|
||||||
|
|
||||||
|
"echom "–––––––––"
|
||||||
|
"echom line
|
||||||
|
"echom col
|
||||||
|
""echom left.":".a:char
|
||||||
|
"echom string(list)
|
||||||
|
"echom string(list[start : col - 1]) . " : " . string(list[col :])
|
||||||
|
"echom opening . " - " . closing . " = " . (opening - closing)
|
||||||
|
|
||||||
|
" Return the found balance:
|
||||||
|
return opening - closing
|
||||||
|
endfunction "}}}
|
||||||
|
|
||||||
|
function! delimitMate#RmBuffer(num) " {{{
|
||||||
|
if len(b:_l_delimitMate_buffer) > 0
|
||||||
|
call remove(b:_l_delimitMate_buffer, 0, (a:num-1))
|
||||||
|
endif
|
||||||
|
return ""
|
||||||
|
endfunction " }}}
|
||||||
|
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
" Doers {{{
|
" Doers {{{
|
||||||
function! delimitMate#JumpIn(char) " {{{
|
function! delimitMate#SkipDelim(char) "{{{
|
||||||
let line = getline('.')
|
if delimitMate#IsForbidden(a:char)
|
||||||
let col = col('.')-2
|
|
||||||
if (col) < 0
|
|
||||||
call setline('.',a:char.line)
|
|
||||||
call insert(b:delimitMate_buffer, a:char)
|
|
||||||
else
|
|
||||||
"echom string(col).':'.line[:(col)].'|'.line[(col+1):]
|
|
||||||
call setline('.',line[:(col)].a:char.line[(col+1):])
|
|
||||||
call insert(b:delimitMate_buffer, a:char)
|
|
||||||
endif
|
|
||||||
return ''
|
|
||||||
endfunction " }}}
|
|
||||||
|
|
||||||
function! delimitMate#JumpOut(char) "{{{
|
|
||||||
let line = getline('.')
|
|
||||||
let col = col('.')-2
|
|
||||||
if line[col+1] == a:char
|
|
||||||
return a:char . delimitMate#Del()
|
|
||||||
else
|
|
||||||
return a:char
|
return a:char
|
||||||
endif
|
endif
|
||||||
endfunction " }}}
|
|
||||||
|
|
||||||
function! delimitMate#JumpAny() " {{{
|
|
||||||
" Let's get the character on the right.
|
|
||||||
let char = getline('.')[col('.')-1]
|
|
||||||
if char == " "
|
|
||||||
" Space expansion.
|
|
||||||
"let char = char . getline('.')[col('.')] . delimitMate#Del()
|
|
||||||
return char . getline('.')[col('.')] . delimitMate#Del() . delimitMate#Del()
|
|
||||||
"call delimitMate#RmBuffer(1)
|
|
||||||
elseif char == ""
|
|
||||||
" CR expansion.
|
|
||||||
"let char = "\<CR>" . getline(line('.') + 1)[0] . "\<Del>"
|
|
||||||
let b:delimitMate_buffer = []
|
|
||||||
return "\<CR>" . getline(line('.') + 1)[0] . "\<Del>"
|
|
||||||
else
|
|
||||||
"call delimitMate#RmBuffer(1)
|
|
||||||
return char . delimitMate#Del()
|
|
||||||
endif
|
|
||||||
endfunction " delimitMate#JumpAny() }}}
|
|
||||||
|
|
||||||
function! delimitMate#SkipDelim(char) "{{{
|
|
||||||
let col = col('.') - 1
|
let col = col('.') - 1
|
||||||
let line = getline('.')
|
let line = getline('.')
|
||||||
if col > 0
|
if col > 0
|
||||||
@@ -401,7 +247,7 @@ function! delimitMate#SkipDelim(char) "{{{
|
|||||||
return a:char . delimitMate#Del()
|
return a:char . delimitMate#Del()
|
||||||
elseif delimitMate#IsEmptyPair( pre . a:char )
|
elseif delimitMate#IsEmptyPair( pre . a:char )
|
||||||
" Add closing delimiter and jump back to the middle.
|
" Add closing delimiter and jump back to the middle.
|
||||||
call insert(b:delimitMate_buffer, a:char)
|
call insert(b:_l_delimitMate_buffer, a:char)
|
||||||
return delimitMate#WriteAfter(a:char)
|
return delimitMate#WriteAfter(a:char)
|
||||||
else
|
else
|
||||||
" Nothing special here, return the same character.
|
" Nothing special here, return the same character.
|
||||||
@@ -409,54 +255,151 @@ function! delimitMate#SkipDelim(char) "{{{
|
|||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
|
function! delimitMate#ParenDelim(char) " {{{
|
||||||
|
if delimitMate#IsForbidden(a:char)
|
||||||
|
return ''
|
||||||
|
endif
|
||||||
|
" Try to balance matchpairs
|
||||||
|
if b:_l_delimitMate_balance_matchpairs &&
|
||||||
|
\ delimitMate#BalancedParens(a:char) <= 0
|
||||||
|
return ''
|
||||||
|
endif
|
||||||
|
let line = getline('.')
|
||||||
|
let col = col('.')-2
|
||||||
|
let left = b:_l_delimitMate_left_delims[index(b:_l_delimitMate_right_delims,a:char)]
|
||||||
|
let smart_matchpairs = substitute(b:_l_delimitMate_smart_matchpairs, '\\!', left, 'g')
|
||||||
|
let smart_matchpairs = substitute(smart_matchpairs, '\\#', a:char, 'g')
|
||||||
|
"echom left.':'.smart_matchpairs . ':' . matchstr(line[col+1], smart_matchpairs)
|
||||||
|
if b:_l_delimitMate_smart_matchpairs != '' &&
|
||||||
|
\ line[col+1:] =~ smart_matchpairs
|
||||||
|
return ''
|
||||||
|
elseif (col) < 0
|
||||||
|
call setline('.',a:char.line)
|
||||||
|
call insert(b:_l_delimitMate_buffer, a:char)
|
||||||
|
else
|
||||||
|
"echom string(col).':'.line[:(col)].'|'.line[(col+1):]
|
||||||
|
call setline('.',line[:(col)].a:char.line[(col+1):])
|
||||||
|
call insert(b:_l_delimitMate_buffer, a:char)
|
||||||
|
endif
|
||||||
|
return ''
|
||||||
|
endfunction " }}}
|
||||||
|
|
||||||
function! delimitMate#QuoteDelim(char) "{{{
|
function! delimitMate#QuoteDelim(char) "{{{
|
||||||
|
if delimitMate#IsForbidden(a:char)
|
||||||
|
return a:char
|
||||||
|
endif
|
||||||
let line = getline('.')
|
let line = getline('.')
|
||||||
let col = col('.') - 2
|
let col = col('.') - 2
|
||||||
if line[col] == "\\"
|
if line[col] == "\\"
|
||||||
" Seems like a escaped character, insert one quotation mark.
|
" Seems like a escaped character, insert one quotation mark.
|
||||||
return a:char
|
return a:char
|
||||||
elseif line[col + 1] == a:char
|
elseif line[col + 1] == a:char &&
|
||||||
|
\ index(b:_l_delimitMate_nesting_quotes, a:char) < 0
|
||||||
" Get out of the string.
|
" Get out of the string.
|
||||||
"return delimitMate#WriteBefore(a:char)
|
|
||||||
return a:char . delimitMate#Del()
|
return a:char . delimitMate#Del()
|
||||||
elseif (line[col] =~ '[a-zA-Z0-9]' && a:char == "'") ||
|
elseif (line[col] =~ '\w' && a:char == "'") ||
|
||||||
\(line[col] =~ '[a-zA-Z0-9]' && b:delimitMate_smart_quotes)
|
\ (b:_l_delimitMate_smart_quotes &&
|
||||||
" Seems like an apostrophe or a closing, insert a single quote.
|
\ (line[col] =~ '\w' ||
|
||||||
|
\ line[col + 1] =~ '\w'))
|
||||||
|
" Seems like an apostrophe or a smart quote case, insert a single quote.
|
||||||
return a:char
|
return a:char
|
||||||
elseif (line[col] == a:char && line[col + 1 ] != a:char) && b:delimitMate_smart_quotes
|
elseif (line[col] == a:char && line[col + 1 ] != a:char) && b:_l_delimitMate_smart_quotes
|
||||||
" Seems like we have an unbalanced quote, insert one quotation mark and jump to the middle.
|
" Seems like we have an unbalanced quote, insert one quotation mark and jump to the middle.
|
||||||
call insert(b:delimitMate_buffer, a:char)
|
call insert(b:_l_delimitMate_buffer, a:char)
|
||||||
return delimitMate#WriteAfter(a:char)
|
return delimitMate#WriteAfter(a:char)
|
||||||
else
|
else
|
||||||
" Insert a pair and jump to the middle.
|
" Insert a pair and jump to the middle.
|
||||||
call insert(b:delimitMate_buffer, a:char)
|
call insert(b:_l_delimitMate_buffer, a:char)
|
||||||
call delimitMate#WriteAfter(a:char)
|
call delimitMate#WriteAfter(a:char)
|
||||||
return a:char
|
return a:char
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! delimitMate#MapMsg(msg) "{{{
|
function! delimitMate#JumpOut(char) "{{{
|
||||||
redraw
|
if delimitMate#IsForbidden(a:char)
|
||||||
echomsg a:msg
|
return a:char
|
||||||
return ""
|
endif
|
||||||
endfunction "}}}
|
let line = getline('.')
|
||||||
|
let col = col('.')-2
|
||||||
|
if line[col+1] == a:char
|
||||||
|
return a:char . delimitMate#Del()
|
||||||
|
else
|
||||||
|
return a:char
|
||||||
|
endif
|
||||||
|
endfunction " }}}
|
||||||
|
|
||||||
|
function! delimitMate#JumpAny(key) " {{{
|
||||||
|
if delimitMate#IsForbidden('')
|
||||||
|
return a:key
|
||||||
|
endif
|
||||||
|
if !delimitMate#ShouldJump()
|
||||||
|
return a:key
|
||||||
|
endif
|
||||||
|
" Let's get the character on the right.
|
||||||
|
let char = getline('.')[col('.')-1]
|
||||||
|
if char == " "
|
||||||
|
" Space expansion.
|
||||||
|
"let char = char . getline('.')[col('.')] . delimitMate#Del()
|
||||||
|
return char . getline('.')[col('.')] . delimitMate#Del() . delimitMate#Del()
|
||||||
|
"call delimitMate#RmBuffer(1)
|
||||||
|
elseif char == ""
|
||||||
|
" CR expansion.
|
||||||
|
"let char = "\<CR>" . getline(line('.') + 1)[0] . "\<Del>"
|
||||||
|
let b:_l_delimitMate_buffer = []
|
||||||
|
return "\<CR>" . getline(line('.') + 1)[0] . "\<Del>"
|
||||||
|
else
|
||||||
|
"call delimitMate#RmBuffer(1)
|
||||||
|
return char . delimitMate#Del()
|
||||||
|
endif
|
||||||
|
endfunction " delimitMate#JumpAny() }}}
|
||||||
|
|
||||||
|
function! delimitMate#JumpMany() " {{{
|
||||||
|
let line = getline('.')[col('.') - 1 : ]
|
||||||
|
let len = len(line)
|
||||||
|
let rights = ""
|
||||||
|
let found = 0
|
||||||
|
let i = 0
|
||||||
|
while i < len
|
||||||
|
let char = line[i]
|
||||||
|
if index(b:_l_delimitMate_quotes_list, char) >= 0 ||
|
||||||
|
\ index(b:_l_delimitMate_right_delims, char) >= 0
|
||||||
|
let rights .= "\<Right>"
|
||||||
|
let found = 1
|
||||||
|
elseif found == 0
|
||||||
|
let rights .= "\<Right>"
|
||||||
|
else
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
let i += 1
|
||||||
|
endwhile
|
||||||
|
if found == 1
|
||||||
|
return rights
|
||||||
|
else
|
||||||
|
return ''
|
||||||
|
endif
|
||||||
|
endfunction " delimitMate#JumpMany() }}}
|
||||||
|
|
||||||
function! delimitMate#ExpandReturn() "{{{
|
function! delimitMate#ExpandReturn() "{{{
|
||||||
if delimitMate#WithinEmptyPair() &&
|
if delimitMate#IsForbidden("")
|
||||||
\ b:delimitMate_expand_cr
|
return "\<CR>"
|
||||||
|
endif
|
||||||
|
if delimitMate#WithinEmptyPair()
|
||||||
" Expand:
|
" Expand:
|
||||||
call delimitMate#FlushBuffer()
|
call delimitMate#FlushBuffer()
|
||||||
return "\<Esc>a\<CR>x\<CR>\<Esc>k$\"_xa"
|
"return "\<Esc>a\<CR>x\<CR>\<Esc>k$\"_xa"
|
||||||
|
return "\<CR>\<UP>\<Esc>o"
|
||||||
else
|
else
|
||||||
return "\<CR>"
|
return "\<CR>"
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! delimitMate#ExpandSpace() "{{{
|
function! delimitMate#ExpandSpace() "{{{
|
||||||
if delimitMate#WithinEmptyPair() &&
|
if delimitMate#IsForbidden("\<Space>")
|
||||||
\ b:delimitMate_expand_space
|
return "\<Space>"
|
||||||
|
endif
|
||||||
|
if delimitMate#WithinEmptyPair()
|
||||||
" Expand:
|
" Expand:
|
||||||
call insert(b:delimitMate_buffer, 's')
|
call insert(b:_l_delimitMate_buffer, 's')
|
||||||
return delimitMate#WriteAfter(' ') . "\<Space>"
|
return delimitMate#WriteAfter(' ') . "\<Space>"
|
||||||
else
|
else
|
||||||
return "\<Space>"
|
return "\<Space>"
|
||||||
@@ -464,16 +407,17 @@ function! delimitMate#ExpandSpace() "{{{
|
|||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! delimitMate#BS() " {{{
|
function! delimitMate#BS() " {{{
|
||||||
|
if delimitMate#IsForbidden("")
|
||||||
|
return "\<BS>"
|
||||||
|
endif
|
||||||
if delimitMate#WithinEmptyPair()
|
if delimitMate#WithinEmptyPair()
|
||||||
"call delimitMate#RmBuffer(1)
|
"call delimitMate#RmBuffer(1)
|
||||||
return "\<BS>" . delimitMate#Del()
|
return "\<BS>" . delimitMate#Del()
|
||||||
" return "\<Right>\<BS>\<BS>"
|
" return "\<Right>\<BS>\<BS>"
|
||||||
elseif b:delimitMate_expand_space &&
|
elseif delimitMate#IsSpaceExpansion()
|
||||||
\ delimitMate#IsSpaceExpansion()
|
|
||||||
"call delimitMate#RmBuffer(1)
|
"call delimitMate#RmBuffer(1)
|
||||||
return "\<BS>" . delimitMate#Del()
|
return "\<BS>" . delimitMate#Del()
|
||||||
elseif b:delimitMate_expand_cr &&
|
elseif delimitMate#IsCRExpansion()
|
||||||
\ delimitMate#IsCRExpansion()
|
|
||||||
return "\<BS>\<Del>"
|
return "\<BS>\<Del>"
|
||||||
else
|
else
|
||||||
return "\<BS>"
|
return "\<BS>"
|
||||||
@@ -481,7 +425,7 @@ function! delimitMate#BS() " {{{
|
|||||||
endfunction " }}} delimitMate#BS()
|
endfunction " }}} delimitMate#BS()
|
||||||
|
|
||||||
function! delimitMate#Del() " {{{
|
function! delimitMate#Del() " {{{
|
||||||
if len(b:delimitMate_buffer) > 0
|
if len(b:_l_delimitMate_buffer) > 0
|
||||||
let line = getline('.')
|
let line = getline('.')
|
||||||
let col = col('.') - 2
|
let col = col('.') - 2
|
||||||
call delimitMate#RmBuffer(1)
|
call delimitMate#RmBuffer(1)
|
||||||
@@ -492,23 +436,24 @@ function! delimitMate#Del() " {{{
|
|||||||
endif
|
endif
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
|
|
||||||
function! delimitMate#Finish() " {{{
|
function! delimitMate#Finish(move_back) " {{{
|
||||||
let len = len(b:delimitMate_buffer)
|
let len = len(b:_l_delimitMate_buffer)
|
||||||
if len > 0
|
if len > 0
|
||||||
let buffer = join(b:delimitMate_buffer, '')
|
let buffer = join(b:_l_delimitMate_buffer, '')
|
||||||
|
let len2 = len(buffer)
|
||||||
" Reset buffer:
|
" Reset buffer:
|
||||||
let b:delimitMate_buffer = []
|
let b:_l_delimitMate_buffer = []
|
||||||
let line = getline('.')
|
let line = getline('.')
|
||||||
let col = col('.') -2
|
let col = col('.') -2
|
||||||
echom 'col: ' . col . '-' . line[:col] . "|" . line[col+len+1:] . '%' . buffer
|
"echom 'col: ' . col . '-' . line[:col] . "|" . line[col+len+1:] . '%' . buffer
|
||||||
if col < 0
|
if col < 0
|
||||||
call setline('.', line[col+len+1:])
|
call setline('.', line[col+len2+1:])
|
||||||
else
|
else
|
||||||
call setline('.', line[:col] . line[col+len+1:])
|
call setline('.', line[:col] . line[col+len2+1:])
|
||||||
endif
|
endif
|
||||||
let i = 1
|
let i = 1
|
||||||
let lefts = "\<Left>"
|
let lefts = ""
|
||||||
while i < len
|
while i <= len && a:move_back
|
||||||
let lefts = lefts . "\<Left>"
|
let lefts = lefts . "\<Left>"
|
||||||
let i += 1
|
let i += 1
|
||||||
endwhile
|
endwhile
|
||||||
@@ -517,192 +462,125 @@ function! delimitMate#Finish() " {{{
|
|||||||
return ''
|
return ''
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
|
|
||||||
function! delimitMate#RmBuffer(num) " {{{
|
|
||||||
if len(b:delimitMate_buffer) > 0
|
|
||||||
call remove(b:delimitMate_buffer, 0, (a:num-1))
|
|
||||||
endif
|
|
||||||
return ""
|
|
||||||
endfunction " }}}
|
|
||||||
|
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
" Mappers: {{{
|
|
||||||
function! delimitMate#NoAutoClose() "{{{
|
|
||||||
" inoremap <buffer> ) <C-R>=delimitMate#SkipDelim('\)')<CR>
|
|
||||||
for delim in b:delimitMate_right_delims + b:delimitMate_quotes_list
|
|
||||||
exec 'inoremap <buffer> ' . delim . ' <C-R>=delimitMate#SkipDelim("' . escape(delim,'"') . '")<CR>'
|
|
||||||
endfor
|
|
||||||
endfunction "}}}
|
|
||||||
|
|
||||||
function! delimitMate#AutoClose() "{{{
|
|
||||||
" Add matching pair and jump to the midle:
|
|
||||||
" inoremap <buffer> ( ()<Left>
|
|
||||||
let i = 0
|
|
||||||
while i < len(b:delimitMate_matchpairs_list)
|
|
||||||
let ld = b:delimitMate_left_delims[i]
|
|
||||||
let rd = b:delimitMate_right_delims[i]
|
|
||||||
exec 'inoremap <buffer> ' . ld . ' ' . ld . '<C-R>=delimitMate#JumpIn("' . rd . '")<CR>'
|
|
||||||
let i += 1
|
|
||||||
endwhile
|
|
||||||
|
|
||||||
" Exit from inside the matching pair:
|
|
||||||
for delim in b:delimitMate_right_delims
|
|
||||||
exec 'inoremap <buffer> ' . delim . ' <C-R>=delimitMate#JumpOut("\' . delim . '")<CR>'
|
|
||||||
endfor
|
|
||||||
|
|
||||||
" Add matching quote and jump to the midle, or exit if inside a pair of matching quotes:
|
|
||||||
" inoremap <buffer> " <C-R>=delimitMate#QuoteDelim("\"")<CR>
|
|
||||||
for delim in b:delimitMate_quotes_list
|
|
||||||
exec 'inoremap <buffer> ' . delim . ' <C-R>=delimitMate#QuoteDelim("\' . delim . '")<CR>'
|
|
||||||
endfor
|
|
||||||
|
|
||||||
" Try to fix the use of apostrophes (de-activated by default):
|
|
||||||
" inoremap <buffer> n't n't
|
|
||||||
for map in b:delimitMate_apostrophes_list
|
|
||||||
exec "inoremap <buffer> " . map . " " . map
|
|
||||||
endfor
|
|
||||||
endfunction "}}}
|
|
||||||
|
|
||||||
function! delimitMate#VisualMaps() " {{{
|
|
||||||
let VMapMsg = "delimitMate: delimitMate is disabled on blockwise visual mode."
|
|
||||||
let vleader = b:delimitMate_visual_leader
|
|
||||||
" Wrap the selection with matching pairs, but do nothing if blockwise visual mode is active:
|
|
||||||
for del in b:delimitMate_right_delims + b:delimitMate_left_delims + b:delimitMate_quotes_list
|
|
||||||
exec "vnoremap <buffer> <expr> " . vleader . del . ' delimitMate#Visual("' . escape(del, '")') . '")'
|
|
||||||
endfor
|
|
||||||
endfunction "}}}
|
|
||||||
|
|
||||||
function! delimitMate#ExtraMappings() "{{{
|
|
||||||
" If pair is empty, delete both delimiters:
|
|
||||||
inoremap <buffer> <BS> <C-R>=delimitMate#BS()<CR>
|
|
||||||
|
|
||||||
" If pair is empty, delete closing delimiter:
|
|
||||||
inoremap <buffer> <expr> <S-BS> delimitMate#WithinEmptyPair() ? "\<Del>" : "\<S-BS>"
|
|
||||||
|
|
||||||
" Expand return if inside an empty pair:
|
|
||||||
if b:delimitMate_expand_cr != 0
|
|
||||||
inoremap <buffer> <expr> <CR> delimitMate#WithinEmptyPair() ? "\<C-R>=delimitMate#ExpandReturn()\<CR>" : "\<CR>"
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Expand space if inside an empty pair:
|
|
||||||
if b:delimitMate_expand_space != 0
|
|
||||||
inoremap <buffer> <expr> <Space> delimitMate#WithinEmptyPair() ? "\<C-R>=delimitMate#ExpandSpace()\<CR>" : "\<Space>"
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Jump out ot any empty pair:
|
|
||||||
if b:delimitMate_tab2exit
|
|
||||||
inoremap <buffer> <expr> <S-Tab> delimitMate#ShouldJump() ? "\<C-R>=delimitMate#JumpAny()\<CR>" : "\<S-Tab>"
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Fix the re-do feature:
|
|
||||||
inoremap <buffer> <Esc> <C-R>=delimitMate#Finish()<CR><Esc>
|
|
||||||
|
|
||||||
" Flush the char buffer on mouse click:
|
|
||||||
inoremap <buffer> <LeftMouse> <C-R>=delimitMate#Finish()<CR><LeftMouse>
|
|
||||||
inoremap <buffer> <RightMouse> <C-R>=delimitMate#Finish()<CR><RightMouse>
|
|
||||||
|
|
||||||
" Flush the char buffer on key movements:
|
|
||||||
inoremap <buffer> <Left> <C-R>=delimitMate#Finish()<CR><Left>
|
|
||||||
inoremap <buffer> <Right> <C-R>=delimitMate#Finish()<CR><Right>
|
|
||||||
inoremap <buffer> <Up> <C-R>=delimitMate#Finish()<CR><Up>
|
|
||||||
inoremap <buffer> <Down> <C-R>=delimitMate#Finish()<CR><Down>
|
|
||||||
|
|
||||||
inoremap <buffer> <Del> <C-R>=delimitMate#Del()<CR>
|
|
||||||
|
|
||||||
endfunction "}}}
|
|
||||||
|
|
||||||
function! delimitMate#UnMap() " {{{
|
|
||||||
let imaps =
|
|
||||||
\ b:delimitMate_right_delims +
|
|
||||||
\ b:delimitMate_left_delims +
|
|
||||||
\ b:delimitMate_quotes_list +
|
|
||||||
\ b:delimitMate_apostrophes_list +
|
|
||||||
\ ['<BS>', '<S-BS>', '<Del>', '<CR>', '<Space>', '<S-Tab>', '<Esc>'] +
|
|
||||||
\ ['<Up>', '<Down>', '<Left>', '<Right>', '<LeftMouse>', '<RightMouse>']
|
|
||||||
|
|
||||||
let vmaps =
|
|
||||||
\ b:delimitMate_right_delims +
|
|
||||||
\ b:delimitMate_left_delims +
|
|
||||||
\ b:delimitMate_quotes_list
|
|
||||||
|
|
||||||
for map in imaps
|
|
||||||
if maparg(map, "i") =~? 'delimitMate'
|
|
||||||
exec 'silent! iunmap <buffer> ' . map
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
|
|
||||||
if !exists("b:delimitMate_visual_leader")
|
|
||||||
let vleader = ""
|
|
||||||
else
|
|
||||||
let vleader = b:delimitMate_visual_leader
|
|
||||||
endif
|
|
||||||
for map in vmaps
|
|
||||||
if maparg(vleader . map, "v") =~? "delimitMate"
|
|
||||||
exec 'silent! vunmap <buffer> ' . vleader . map
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
|
|
||||||
let b:delimitMate_enabled = 0
|
|
||||||
endfunction " }}} delimitMate#UnMap()
|
|
||||||
|
|
||||||
"}}}
|
|
||||||
|
|
||||||
" Tools: {{{
|
" Tools: {{{
|
||||||
function! delimitMate#TestMappings() "{{{
|
function! delimitMate#TestMappings() "{{{
|
||||||
exec "normal i*b:delimitMate_autoclose = " . b:delimitMate_autoclose . "\<CR>"
|
let options = sort(keys(delimitMate#OptionsList()))
|
||||||
exec "normal i*b:delimitMate_expand_space = " . b:delimitMate_expand_space . "\<CR>"
|
let optoutput = ['delimitMate Report', '==================', '', '* Options: ( ) default, (g) global, (b) buffer','']
|
||||||
exec "normal i*b:delimitMate_expand_cr = " . b:delimitMate_expand_cr . "\<CR>\<CR>"
|
for option in options
|
||||||
|
exec 'call add(optoutput, ''('.(exists('b:delimitMate_'.option) ? 'b' : exists('g:delimitMate_'.option) ? 'g' : ' ').') delimitMate_''.option.'' = ''.string(b:_l_delimitMate_'.option.'))'
|
||||||
|
endfor
|
||||||
|
call append(line('$'), optoutput + ['--------------------',''])
|
||||||
|
|
||||||
if b:delimitMate_autoclose
|
" Check if mappings were set. {{{
|
||||||
for i in range(len(b:delimitMate_left_delims))
|
let imaps = b:_l_delimitMate_right_delims
|
||||||
exec "normal GGAOpen & close: " . b:delimitMate_left_delims[i]. "|"
|
let imaps = imaps + ( b:_l_delimitMate_autoclose ? b:_l_delimitMate_left_delims : [] )
|
||||||
exec "normal A\<CR>Delete: " . b:delimitMate_left_delims[i] . "\<BS>|"
|
let imaps = imaps +
|
||||||
exec "normal A\<CR>Exit: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . "|"
|
\ b:_l_delimitMate_quotes_list +
|
||||||
exec "normal A\<CR>Space: " . b:delimitMate_left_delims[i] . " |"
|
\ b:_l_delimitMate_apostrophes_list +
|
||||||
exec "normal A\<CR>Delete space: " . b:delimitMate_left_delims[i] . " \<BS>|"
|
\ ['<BS>', '<S-BS>', '<Del>', '<S-Tab>', '<Esc>'] +
|
||||||
exec "normal GGA\<CR>Visual-L: v\<Esc>v" . b:delimitMate_visual_leader . b:delimitMate_left_delims[i]
|
\ ['<Up>', '<Down>', '<Left>', '<Right>', '<LeftMouse>', '<RightMouse>'] +
|
||||||
exec "normal A\<CR>Visual-R: v\<Esc>v" . b:delimitMate_visual_leader . b:delimitMate_right_delims[i]
|
\ ['<Home>', '<End>', '<PageUp>', '<PageDown>', '<S-Down>', '<S-Up>', '<C-G>g']
|
||||||
exec "normal A\<CR>Car return: " . b:delimitMate_left_delims[i] . "\<CR>|"
|
let imaps = imaps + ( b:_l_delimitMate_expand_cr ? ['<CR>'] : [] )
|
||||||
exec "normal GGA\<CR>Delete car return: " . b:delimitMate_left_delims[i] . "\<CR>\<BS>|\<Esc>GGA\<CR>\<CR>"
|
let imaps = imaps + ( b:_l_delimitMate_expand_space ? ['<Space>'] : [] )
|
||||||
endfor
|
|
||||||
for i in range(len(b:delimitMate_quotes_list))
|
let vmaps =
|
||||||
exec "normal GGAOpen & close: " . b:delimitMate_quotes_list[i] . "|"
|
\ b:_l_delimitMate_right_delims +
|
||||||
exec "normal A\<CR>Delete: "
|
\ b:_l_delimitMate_left_delims +
|
||||||
exec "normal A". b:delimitMate_quotes_list[i]
|
\ b:_l_delimitMate_quotes_list
|
||||||
exec "normal a\<BS>|"
|
|
||||||
exec "normal A\<CR>Exit: " . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . "|"
|
let ibroken = []
|
||||||
exec "normal A\<CR>Space: " . b:delimitMate_quotes_list[i] . " |"
|
for map in imaps
|
||||||
exec "normal A\<CR>Delete space: " . b:delimitMate_quotes_list[i] . " \<BS>|"
|
if maparg(map, "i") !~? 'delimitMate'
|
||||||
exec "normal GGA\<CR>Visual: v\<Esc>v" . b:delimitMate_visual_leader . b:delimitMate_quotes_list[i]
|
let output = ''
|
||||||
exec "normal A\<CR>Car return: " . b:delimitMate_quotes_list[i] . "\<CR>|"
|
if map == '|'
|
||||||
exec "normal GGA\<CR>Delete car return: " . b:delimitMate_quotes_list[i] . "\<CR>\<BS>|\<Esc>GGA\<CR>\<CR>"
|
let map = '<Bar>'
|
||||||
endfor
|
endif
|
||||||
|
redir => output | execute "verbose imap ".map | redir END
|
||||||
|
let ibroken = ibroken + [map.": is not set:"] + split(output, '\n')
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
|
||||||
|
unlet! output
|
||||||
|
if ibroken == []
|
||||||
|
let output = ['* Mappings:', '', 'All mappings were set-up.', '--------------------', '', '']
|
||||||
else
|
else
|
||||||
for i in range(len(b:delimitMate_left_delims))
|
let output = ['* Mappings:', ''] + ibroken + ['--------------------', '']
|
||||||
exec "normal GGAOpen & close: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . "|"
|
|
||||||
exec "normal A\<CR>Delete: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . "\<BS>|"
|
|
||||||
exec "normal A\<CR>Exit: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . b:delimitMate_right_delims[i] . "|"
|
|
||||||
exec "normal A\<CR>Space: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . " |"
|
|
||||||
exec "normal A\<CR>Delete space: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . " \<BS>|"
|
|
||||||
exec "normal GGA\<CR>Visual-L: v\<Esc>v" . b:delimitMate_visual_leader . b:delimitMate_left_delims[i]
|
|
||||||
exec "normal A\<CR>Visual-R: v\<Esc>v" . b:delimitMate_visual_leader . b:delimitMate_right_delims[i]
|
|
||||||
exec "normal A\<CR>Car return: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . "\<CR>|"
|
|
||||||
exec "normal GGA\<CR>Delete car return: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . "\<CR>\<BS>|\<Esc>GGA\<CR>\<CR>"
|
|
||||||
endfor
|
|
||||||
for i in range(len(b:delimitMate_quotes_list))
|
|
||||||
exec "normal GGAOpen & close: " . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . "|"
|
|
||||||
exec "normal A\<CR>Delete: " . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . "\<BS>|"
|
|
||||||
exec "normal A\<CR>Exit: " . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . "|"
|
|
||||||
exec "normal A\<CR>Space: " . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . " |"
|
|
||||||
exec "normal A\<CR>Delete space: " . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . " \<BS>|"
|
|
||||||
exec "normal GGA\<CR>Visual: v\<Esc>v" . b:delimitMate_visual_leader . b:delimitMate_quotes_list[i]
|
|
||||||
exec "normal A\<CR>Car return: " . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . "\<CR>|"
|
|
||||||
exec "normal GGA\<CR>Delete car return: " . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . "\<CR>\<BS>|\<Esc>GGA\<CR>\<CR>"
|
|
||||||
endfor
|
|
||||||
endif
|
endif
|
||||||
exec "normal \<Esc>i"
|
call append('$', output+['* Showcase:', ''])
|
||||||
|
" }}}
|
||||||
|
if b:_l_delimitMate_autoclose
|
||||||
|
" {{{
|
||||||
|
for i in range(len(b:_l_delimitMate_left_delims))
|
||||||
|
exec "normal Go0\<C-D>Open: " . b:_l_delimitMate_left_delims[i]. "|"
|
||||||
|
exec "normal o0\<C-D>Delete: " . b:_l_delimitMate_left_delims[i] . "\<BS>|"
|
||||||
|
exec "normal o0\<C-D>Exit: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . "|"
|
||||||
|
if b:_l_delimitMate_expand_space == 1
|
||||||
|
exec "normal o0\<C-D>Space: " . b:_l_delimitMate_left_delims[i] . " |"
|
||||||
|
exec "normal o0\<C-D>Delete space: " . b:_l_delimitMate_left_delims[i] . " \<BS>|"
|
||||||
|
endif
|
||||||
|
if b:_l_delimitMate_expand_cr == 1
|
||||||
|
exec "normal o0\<C-D>Car return: " . b:_l_delimitMate_left_delims[i] . "\<CR>|"
|
||||||
|
exec "normal Go0\<C-D>Delete car return: " . b:_l_delimitMate_left_delims[i] . "\<CR>0\<C-D>\<BS>|"
|
||||||
|
endif
|
||||||
|
call append(line('$'), '')
|
||||||
|
endfor
|
||||||
|
for i in range(len(b:_l_delimitMate_quotes_list))
|
||||||
|
exec "normal Go0\<C-D>Open: " . b:_l_delimitMate_quotes_list[i] . "|"
|
||||||
|
exec "normal o0\<C-D>Delete: " . b:_l_delimitMate_quotes_list[i] . "\<BS>|"
|
||||||
|
exec "normal o0\<C-D>Exit: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "|"
|
||||||
|
if b:_l_delimitMate_expand_space == 1
|
||||||
|
exec "normal o0\<C-D>Space: " . b:_l_delimitMate_quotes_list[i] . " |"
|
||||||
|
exec "normal o0\<C-D>Delete space: " . b:_l_delimitMate_quotes_list[i] . " \<BS>|"
|
||||||
|
endif
|
||||||
|
if b:_l_delimitMate_expand_cr == 1
|
||||||
|
exec "normal o0\<C-D>Car return: " . b:_l_delimitMate_quotes_list[i] . "\<CR>|"
|
||||||
|
exec "normal Go0\<C-D>Delete car return: " . b:_l_delimitMate_quotes_list[i] . "\<CR>\<BS>|"
|
||||||
|
endif
|
||||||
|
call append(line('$'), '')
|
||||||
|
endfor
|
||||||
|
"}}}
|
||||||
|
else
|
||||||
|
"{{{
|
||||||
|
for i in range(len(b:_l_delimitMate_left_delims))
|
||||||
|
exec "normal GoOpen & close: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . "|"
|
||||||
|
exec "normal oDelete: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . "\<BS>|"
|
||||||
|
exec "normal oExit: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . b:_l_delimitMate_right_delims[i] . "|"
|
||||||
|
if b:_l_delimitMate_expand_space == 1
|
||||||
|
exec "normal oSpace: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . " |"
|
||||||
|
exec "normal oDelete space: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . " \<BS>|"
|
||||||
|
endif
|
||||||
|
if b:_l_delimitMate_expand_cr == 1
|
||||||
|
exec "normal oCar return: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . "\<CR>|"
|
||||||
|
exec "normal GoDelete car return: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . "\<CR>\<BS>|"
|
||||||
|
endif
|
||||||
|
call append(line('$'), '')
|
||||||
|
endfor
|
||||||
|
for i in range(len(b:_l_delimitMate_quotes_list))
|
||||||
|
exec "normal GoOpen & close: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "|"
|
||||||
|
exec "normal oDelete: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "\<BS>|"
|
||||||
|
exec "normal oExit: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "|"
|
||||||
|
if b:_l_delimitMate_expand_space == 1
|
||||||
|
exec "normal oSpace: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . " |"
|
||||||
|
exec "normal oDelete space: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . " \<BS>|"
|
||||||
|
endif
|
||||||
|
if b:_l_delimitMate_expand_cr == 1
|
||||||
|
exec "normal oCar return: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "\<CR>|"
|
||||||
|
exec "normal GoDelete car return: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "\<CR>\<BS>|"
|
||||||
|
endif
|
||||||
|
call append(line('$'), '')
|
||||||
|
endfor
|
||||||
|
endif "}}}
|
||||||
|
redir => setoptions | set | filetype | redir END
|
||||||
|
call append(line('$'), split(setoptions,"\n")
|
||||||
|
\ + ['--------------------'])
|
||||||
|
setlocal nowrap
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
|
function! delimitMate#OptionsList() "{{{
|
||||||
|
return {'autoclose' : 1,'matchpairs': &matchpairs, 'quotes' : '" '' `', 'nesting_quotes' : [], 'expand_cr' : 0, 'expand_space' : 0, 'smart_quotes' : 1, 'smart_matchpairs' : '\w', 'balance_matchpairs' : 0, 'excluded_regions' : 'Comment', 'excluded_ft' : '', 'apostrophes' : ''}
|
||||||
|
endfunction " delimitMate#OptionsList }}}
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
" vim:foldmethod=marker:foldcolumn=4
|
" vim:foldmethod=marker:foldcolumn=4
|
||||||
|
|||||||
@@ -1,9 +1,14 @@
|
|||||||
function! delimitMateTests#Main() " {{{
|
function! delimitMateTests#Main()
|
||||||
if !exists("g:delimitMate_testing")
|
if !exists("g:delimitMate_testing")
|
||||||
echoerr "delimitMateTests#Main(): If you really want to use me, you must set delimitMate_testing to any value."
|
echoerr "delimitMateTests#Main(): If you really want to use me, you must set delimitMate_testing to any value."
|
||||||
return
|
return
|
||||||
|
elseif g:delimitMate_testing == "fork"
|
||||||
|
!gvim -N -u NONE -U NONE -c "set runtimepath+=~/.vim/bundle/pathogen" -c "call pathogen\#runtime_append_all_bundles('bundle','symlinks')" -c "set backspace=eol,start" -c "set background=light" -c "syntax on" -c "let delimitMate_testing = 1" -c "ru autoload/delimitMate.vim" -c "ru autoload/delimitMateTests.vim" -c "ru plugin/delimitMate.vim" -c "call delimitMateTests\#Main()"
|
||||||
|
return ""
|
||||||
endif
|
endif
|
||||||
nmap <F1> :qall!<CR>
|
nmap <F1> :qall!<CR>
|
||||||
|
let nomore = &more
|
||||||
|
set nomore
|
||||||
let b:test_results = {}
|
let b:test_results = {}
|
||||||
let b:errors = 0
|
let b:errors = 0
|
||||||
let b:corrects = 0
|
let b:corrects = 0
|
||||||
@@ -14,7 +19,6 @@ function! delimitMateTests#Main() " {{{
|
|||||||
let b:delimitMate_matchpairs = &matchpairs
|
let b:delimitMate_matchpairs = &matchpairs
|
||||||
let b:delimitMate_quotes = "\" ' `"
|
let b:delimitMate_quotes = "\" ' `"
|
||||||
let b:delimitMate_excluded_regions = "Comment"
|
let b:delimitMate_excluded_regions = "Comment"
|
||||||
silent! unlet b:delimitMate_visual_leader
|
|
||||||
let b:delimitMate_expand_space = 0
|
let b:delimitMate_expand_space = 0
|
||||||
let b:delimitMate_expand_cr = 0
|
let b:delimitMate_expand_cr = 0
|
||||||
let b:delimitMate_smart_quotes = 1
|
let b:delimitMate_smart_quotes = 1
|
||||||
@@ -22,8 +26,12 @@ function! delimitMateTests#Main() " {{{
|
|||||||
let b:delimitMate_tab2exit = 1
|
let b:delimitMate_tab2exit = 1
|
||||||
" Set current test options:
|
" Set current test options:
|
||||||
for str in a:list
|
for str in a:list
|
||||||
let pair = split(str, ':')
|
"echom '1:'.str
|
||||||
exec "let b:delimitMate_" . pair[0] . " = " . pair[1]
|
let op = strpart(str, 0, stridx(str,':'))
|
||||||
|
"echom op
|
||||||
|
let val = strpart(str, stridx(str, ':' ) + 1)
|
||||||
|
"echom val
|
||||||
|
exec "let b:delimitMate_" . op . " = " . val
|
||||||
endfor
|
endfor
|
||||||
DelimitMateReload
|
DelimitMateReload
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
@@ -45,6 +53,7 @@ function! delimitMateTests#Main() " {{{
|
|||||||
normal gg.
|
normal gg.
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
exec "normal \<Esc>"
|
||||||
call setpos('.', [0, 1, 1, 0])
|
call setpos('.', [0, 1, 1, 0])
|
||||||
let result = len(a:output) != line('$')
|
let result = len(a:output) != line('$')
|
||||||
for line in a:output
|
for line in a:output
|
||||||
@@ -154,36 +163,6 @@ function! delimitMateTests#Main() " {{{
|
|||||||
call Type("BS with CR expansion", "(\<CR>\<BS>", ['(|)'], ['expand_cr:1'])
|
call Type("BS with CR expansion", "(\<CR>\<BS>", ['(|)'], ['expand_cr:1'])
|
||||||
call RepeatLast("BS with CR expansion", ['(|)(|)'], 1)
|
call RepeatLast("BS with CR expansion", ['(|)(|)'], 1)
|
||||||
|
|
||||||
" Visual wrapping
|
|
||||||
call Type("Visual wrapping left paren", "1234\<Esc>v,(", ['123(4)'], ['visual_leader:","'])
|
|
||||||
cal RepeatLast("Visual wrapping left paren", ['(1)23(4)'], 1)
|
|
||||||
|
|
||||||
" Visual line wrapping
|
|
||||||
call Type("Visual line wrapping left paren", "1234\<Esc>V,(", ['(1234)'], ['visual_leader:","'])
|
|
||||||
cal RepeatLast("Visual line wrapping left paren", ['((1234))'], 1)
|
|
||||||
|
|
||||||
" Visual wrapping
|
|
||||||
call Type("Visual wrapping right paren", "1234\<Esc>v,)", ['123(4)'], ['visual_leader:","'])
|
|
||||||
cal RepeatLast("Visual wrapping right paren", ['(1)23(4)'], 1)
|
|
||||||
|
|
||||||
" Visual line wrapping
|
|
||||||
call Type("Visual line wrapping right paren", "1234\<Esc>V,)", ['(1234)'], ['visual_leader:","'])
|
|
||||||
cal RepeatLast("Visual line wrapping right paren", ['((1234))'], 1)
|
|
||||||
|
|
||||||
" Visual wrapping
|
|
||||||
call Type("Visual wrapping quote", "1234\<Esc>v,\"", ['123"4"'], ['visual_leader:","'])
|
|
||||||
cal RepeatLast("Visual wrapping quote", ['"1"23"4"'], 1)
|
|
||||||
|
|
||||||
" Visual line wrapping
|
|
||||||
call Type("Visual line wrapping quote", "1234\<Esc>V,\"", ['"1234"'], ['visual_leader:","'])
|
|
||||||
cal RepeatLast("Visual line wrapping quote", ['""1234""'], 1)
|
|
||||||
|
|
||||||
" Visual line wrapping empty line
|
|
||||||
call Type("Visual line wrapping paren empty line", "\<Esc>V,(", ['()'], ['visual_leader:","'])
|
|
||||||
|
|
||||||
" Visual line wrapping empty line
|
|
||||||
call Type("Visual line wrapping quote empty line", "\<Esc>V,\"", ['""'], ['visual_leader:","'])
|
|
||||||
|
|
||||||
" Smart quotes
|
" Smart quotes
|
||||||
call Type("Smart quote alphanumeric", "a\"4", ['a"4|'], [])
|
call Type("Smart quote alphanumeric", "a\"4", ['a"4|'], [])
|
||||||
call RepeatLast("Smart quote alphanumeric", ['a"4|a"4|'])
|
call RepeatLast("Smart quote alphanumeric", ['a"4|a"4|'])
|
||||||
@@ -226,12 +205,23 @@ function! delimitMateTests#Main() " {{{
|
|||||||
" Deactivate parens on comments: The first call to a closing delimiter
|
" Deactivate parens on comments: The first call to a closing delimiter
|
||||||
" will not work here as expected, but it does in real life tests.
|
" will not work here as expected, but it does in real life tests.
|
||||||
set ft=vim
|
set ft=vim
|
||||||
call Type("Deactivate parens on comments", "\"()", ["\"()"], ["autoclose:0"], 1)
|
call Type("Deactivate parens on comments", "\"()[]", ["\"()[]|"], ["autoclose:0"], 1)
|
||||||
|
set ft=
|
||||||
|
|
||||||
|
" Deactivate quotes on comments: See previous note.
|
||||||
|
set ft=vim
|
||||||
|
call Type("Deactivate parens on comments", "\"(`", ["\"(``|"], [], 1)
|
||||||
set ft=
|
set ft=
|
||||||
|
|
||||||
" Manual close at start of line
|
" Manual close at start of line
|
||||||
call Type("Manual close at start of line", "m)\<Left>\<Left>)", [')|m)'], ["autoclose:0"])
|
call Type("Manual close at start of line", "m)\<Left>\<Left>)", [')|m)'], ["autoclose:0"])
|
||||||
|
|
||||||
|
" Use | in quotes
|
||||||
|
call Type("Use <Bar> in quotes", "\<Bar>bars", ['|bars|'], ["quotes:'|'"])
|
||||||
|
|
||||||
|
" Use | in matchpairs
|
||||||
|
call Type("Use <Bar> in matchpairs", "\<Bar>bars", ['|bars|$$'], ["matchpairs:'|:$'"])
|
||||||
|
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
" Show results: {{{
|
" Show results: {{{
|
||||||
@@ -240,9 +230,10 @@ function! delimitMateTests#Main() " {{{
|
|||||||
call append(0, "*TESTS REPORT: " . b:errors . " failed, " . b:corrects . " passed and " . b:ignores . " ignored.")
|
call append(0, "*TESTS REPORT: " . b:errors . " failed, " . b:corrects . " passed and " . b:ignores . " ignored.")
|
||||||
normal "_ddgg
|
normal "_ddgg
|
||||||
let @/ = ".\\+Failed:.*!="
|
let @/ = ".\\+Failed:.*!="
|
||||||
|
2,$sort /^.\+':/
|
||||||
|
normal gg
|
||||||
|
exec search('Ignored:','nW').",$sort! /^.\\+':/"
|
||||||
set nohlsearch
|
set nohlsearch
|
||||||
"syntax match failedLine "^.*Failed.*$" contains=ALL
|
|
||||||
"syn match passedLine ".*Passed.*"
|
|
||||||
syn match lineIgnored ".*Ignored.*"
|
syn match lineIgnored ".*Ignored.*"
|
||||||
syn match labelPassed "'\@<=.\+\(': 'Passed\)\@="
|
syn match labelPassed "'\@<=.\+\(': 'Passed\)\@="
|
||||||
syn match labelFailed "'\@<=.\+\(': 'Failed\)\@="
|
syn match labelFailed "'\@<=.\+\(': 'Failed\)\@="
|
||||||
@@ -262,6 +253,8 @@ function! delimitMateTests#Main() " {{{
|
|||||||
hi def link resultSummary SpecialComment
|
hi def link resultSummary SpecialComment
|
||||||
hi def link resultSummaryNumber Error
|
hi def link resultSummaryNumber Error
|
||||||
" }}}
|
" }}}
|
||||||
endfunction " }}}
|
|
||||||
|
let &more = nomore
|
||||||
|
endfunction
|
||||||
" vim:foldmethod=marker:foldcolumn=4
|
" vim:foldmethod=marker:foldcolumn=4
|
||||||
|
|
||||||
|
|||||||
@@ -1,238 +1,115 @@
|
|||||||
*delimitMate* Trying to keep those beasts at bay! v2.2 *delimitMate.txt*
|
*delimitMate.txt* Trying to keep those beasts at bay! v2.6 *delimitMate*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
|
||||||
|
MMMM MMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMM MMMMM MMMMMMMMMMMMMMMMMMMMM ~
|
||||||
|
MMMM MMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMM MMM MMMMMMMMMMMMMMMMMMMMM
|
||||||
|
MMMM MMMMMMMMM MMMMMMMMMMMMMMMMMMMMM MMM M M MMMMMMMMMM MMMMMMMMM ~
|
||||||
|
MMMM MMM MMM MM MM M M MMM MM MM MM MM MMM MMM MMM MM
|
||||||
|
MM MM M MM MMMMMM MMMMMMM MMM MMMMM MM M MMM MMM M M ~
|
||||||
|
M M MM MM MM MM M M MM MMM MMM MMMMM MMMMM MMM MMM M
|
||||||
|
M M MM MMMMM MM MM M M MM MMM MMM MMMMM MMM MMM MMM MMMM ~
|
||||||
|
M M MM M MM MM MM M M MM MMM MMM MMMMM MM M MMM MMM M M
|
||||||
|
MM MMM MMM MM MM M M MM MMM MM MMMMM MMM MMM MMM MM ~
|
||||||
|
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
|
||||||
|
|
||||||
========================================================================= ~
|
|
||||||
==== ========= ========================== ===== ===================== ~
|
|
||||||
==== ========= ========================== === ===================== ~
|
|
||||||
==== ========= ===================== === = = ========== ========= ~
|
|
||||||
==== === === == == = = === == == == == === === === == ~
|
|
||||||
== == = == ====== ======= === ===== == = === === = = ~
|
|
||||||
= = == == == == = = == === === ===== ===== === === = ~
|
|
||||||
= = == ===== == == = = == === === ===== === === === ==== ~
|
|
||||||
= = == = == == == = = == === === ===== == = === === = = ~
|
|
||||||
== === === == == = = == === == ===== === === === == ~
|
|
||||||
========================================================================= ~
|
|
||||||
|
|
||||||
REFERENCE MANUAL *
|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
0.- CONTENTS *delimitMate-contents*
|
0.- CONTENTS *delimitMate-contents*
|
||||||
|
|
||||||
1. Introduction____________________________|delimitMateIntro|
|
1. Introduction____________________________|delimitMateIntro|
|
||||||
2. Functionality___________________________|delimitMateFunctionality|
|
2. Customization___________________________|delimitMateOptions|
|
||||||
2.1 Automatic closing & exiting________|delimitMateAutoClose|
|
2.1 Options summary____________________|delimitMateOptionSummary|
|
||||||
2.2 Expansion of space and CR__________|delimitMateExpansion|
|
2.2 Options details____________________|delimitMateOptionDetails|
|
||||||
2.3 Backspace__________________________|delimitMateBackspace|
|
3. Functionality___________________________|delimitMateFunctionality|
|
||||||
2.4 Visual wrapping____________________|delimitMateVisualWrapping|
|
3.1 Automatic closing & exiting________|delimitMateAutoClose|
|
||||||
2.5 Smart Quotes_______________________|delimitMateSmartQuotes|
|
3.2 Expansion of space and CR__________|delimitMateExpansion|
|
||||||
2.6 FileType based configuration_______|delimitMateFileType|
|
3.3 Backspace__________________________|delimitMateBackspace|
|
||||||
3. Customization___________________________|delimitMateOptions|
|
3.4 Smart Quotes_______________________|delimitMateSmartQuotes|
|
||||||
3.1 Options summary____________________|delimitMateOptionSummary|
|
3.5 Balancing matching pairs___________|delimitMateBalance|
|
||||||
3.2 Options details____________________|delimitMateOptionDetails|
|
3.6 FileType based configuration_______|delimitMateFileType|
|
||||||
|
3.7 Syntax awareness___________________|delimitMateSyntax|
|
||||||
4. Commands________________________________|delimitMateCommands|
|
4. Commands________________________________|delimitMateCommands|
|
||||||
5. Functions_______________________________|delimitMateFunctions|
|
5. Mappings________________________________|delimitMateMappings|
|
||||||
6. TODO list_______________________________|delimitMateTodo|
|
6. Functions_______________________________|delimitMateFunctions|
|
||||||
7. Maintainer______________________________|delimitMateMaintainer|
|
7. TODO list_______________________________|delimitMateTodo|
|
||||||
8. Credits_________________________________|delimitMateCredits|
|
8. Maintainer______________________________|delimitMateMaintainer|
|
||||||
9. History_________________________________|delimitMateHistory|
|
9. Credits_________________________________|delimitMateCredits|
|
||||||
|
10. History_________________________________|delimitMateHistory|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
1.- INTRODUCTION *delimitMateIntro*
|
1.- INTRODUCTION *delimitMateIntro*
|
||||||
|
|
||||||
This plug-in provides automatic closing of quotes, parenthesis, brackets,
|
This plug-in provides automatic closing of quotes, parenthesis, brackets,
|
||||||
etc., besides some other related features that should make your time in insert
|
etc.; besides some other related features that should make your time in insert
|
||||||
mode a little bit easier.
|
mode a little bit easier.
|
||||||
|
|
||||||
Most of the features can be modified or disabled permanently, using global
|
Most of the features can be modified or disabled permanently, using global
|
||||||
variables, or on a FileType basis, using autocommands. With a couple of
|
variables, or on a FileType basis, using autocommands. With a couple of
|
||||||
exceptions and limitations, this features don't brake undo, redo or history.
|
exceptions and limitations, this features don't brake undo, redo or history.
|
||||||
|
|
||||||
|
NOTE 1: If you have any trouble with this plugin, please run |:DelimitMateTest|
|
||||||
|
in a new buffer to see what is not working.
|
||||||
|
|
||||||
|
NOTE 2: |'timeout'| needs to be set when working in the terminal, otherwise you
|
||||||
|
might find weird behaviour with mappings including <Esc> or arrow keys.
|
||||||
|
|
||||||
|
NOTE 3: Abbreiations set with |:iabbrev| will not be expanded by delimiters
|
||||||
|
used on delimitMate, you should use <C-]> (read |i_CTRL-]|) to expand them on
|
||||||
|
the go.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
2. FUNCTIONALITY *delimitMateFunctionality*
|
2. CUSTOMIZATION *delimitMateOptions*
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
2.1 AUTOMATIC CLOSING AND EXITING *delimitMateAutoClose*
|
|
||||||
|
|
||||||
With automatic closing enabled, if an opening delimiter is inserted the plugin
|
|
||||||
inserts the closing delimiter and places the cursor between the pair. With
|
|
||||||
automatic closing disabled, no closing delimiters is inserted by delimitMate,
|
|
||||||
but when a pair of delimiters is typed, the cursor is placed in the middle.
|
|
||||||
|
|
||||||
When the cursor is inside an empty pair or located next to the left of a
|
|
||||||
closing delimiter, the cursor is placed outside the pair to the right of the
|
|
||||||
closing delimiter.
|
|
||||||
|
|
||||||
Unless |'delimitMate_matchpairs'| or |'delimitMate_quotes'|are set, this
|
|
||||||
script uses the values in '&matchpairs' to identify the pairs, and ", ' and `
|
|
||||||
for quotes respectively.
|
|
||||||
|
|
||||||
The following table shows the behaviour, this applies to quotes too (the final
|
|
||||||
position of the cursor is represented by a "|"):
|
|
||||||
|
|
||||||
With auto-close: >
|
|
||||||
Type | You get
|
|
||||||
====================
|
|
||||||
( | (|)
|
|
||||||
–––––––––|––––––––––
|
|
||||||
() | ()|
|
|
||||||
–––––––––|––––––––––
|
|
||||||
(<S-Tab> | ()|
|
|
||||||
<
|
|
||||||
Without auto-close: >
|
|
||||||
|
|
||||||
Type | You get
|
|
||||||
=====================
|
|
||||||
() | (|)
|
|
||||||
–––––––––-|––––––––––
|
|
||||||
()) | ()|
|
|
||||||
–––––––––-|––––––––––
|
|
||||||
()<S-Tab> | ()|
|
|
||||||
<
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
2.2 EXPANSION OF SPACE AND CAR RETURN *delimitMateExpansion*
|
|
||||||
|
|
||||||
When the cursor is inside an empty pair of delimiters, <Space> and <CR> can be
|
|
||||||
expanded, see |'delimitMate_expand_space'| and
|
|
||||||
|'delimitMate_expand_cr'|:
|
|
||||||
|
|
||||||
Expand <Space> to: >
|
|
||||||
|
|
||||||
<Space><Space><Left> | You get
|
|
||||||
====================================
|
|
||||||
(|) | ( | )
|
|
||||||
<
|
|
||||||
Expand <CR> to: >
|
|
||||||
|
|
||||||
<CR><CR><Up> | You get
|
|
||||||
============================
|
|
||||||
(|) | (
|
|
||||||
| |
|
|
||||||
| )
|
|
||||||
<
|
|
||||||
|
|
||||||
NOTE that the expansion of <CR> will brake the redo command.
|
|
||||||
|
|
||||||
Since <Space> and <CR> are used everywhere, I have made the functions involved
|
|
||||||
in expansions global, so they can be used to make custom mappings. Read
|
|
||||||
|delimitMateFunctions| for more details.
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
2.3 BACKSPACE *delimitMateBackspace*
|
|
||||||
|
|
||||||
If you press backspace inside an empty pair, both delimiters are deleted. When
|
|
||||||
expansions are enabled, <BS> will also delete the expansions. NOTE that
|
|
||||||
deleting <CR> expansions will brake the redo command.
|
|
||||||
|
|
||||||
If you type shift + backspace instead, only the closing delimiter will be
|
|
||||||
deleted.
|
|
||||||
|
|
||||||
e.g. typing at the "|": >
|
|
||||||
|
|
||||||
What | Before | After
|
|
||||||
==============================================
|
|
||||||
<BS> | call expand(|) | call expand|
|
|
||||||
---------|-------------------|-----------------
|
|
||||||
<BS> | call expand( | ) | call expand(|)
|
|
||||||
---------|-------------------|-----------------
|
|
||||||
<BS> | call expand( | call expand(|)
|
|
||||||
| | |
|
|
||||||
| ) |
|
|
||||||
---------|-------------------|-----------------
|
|
||||||
<S-BS> | call expand(|) | call expand(|
|
|
||||||
<
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
2.4 WRAPPING OF VISUAL SELECTION *delimitMateVisualWrapping*
|
|
||||||
|
|
||||||
When visual mode is active this script allows for the selection to be enclosed
|
|
||||||
with delimiters. But, since brackets have special meaning in visual mode, a
|
|
||||||
leader (the value of 'mapleader' by default) should precede the delimiter.
|
|
||||||
NOTE that this feature brakes the redo command and doesn't currently work on
|
|
||||||
blockwise visual mode, any suggestions will be welcome.
|
|
||||||
|
|
||||||
e.g. (selection represented between square brackets): >
|
|
||||||
|
|
||||||
Selected text | After \"
|
|
||||||
=============================================
|
|
||||||
An [absurd] example! | An "absurd" example!
|
|
||||||
<
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
2.5 SMART QUOTES *delimitMateSmartQuotes*
|
|
||||||
|
|
||||||
Only one quote will be inserted following a quote, a "\" or an alphanumeric
|
|
||||||
character. This should cover closing quotes, escaped quotes and apostrophes.
|
|
||||||
Except for apostrophes, this feature can be disabled setting the option
|
|
||||||
|'delimitMate_smart_quotes'| to 0.
|
|
||||||
|
|
||||||
e.g. typing at the "|": >
|
|
||||||
|
|
||||||
What | Before | After
|
|
||||||
=======================================
|
|
||||||
" | "String| | "String"|
|
|
||||||
" | let i = "| | let i = "|"
|
|
||||||
' | I| | I'|
|
|
||||||
<
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
2.6 FILE TYPE BASED CONFIGURATION *delimitMateFileType*
|
|
||||||
|
|
||||||
delimitMate options can be set globally for all buffers using global
|
|
||||||
("regular") variables in your |vimrc| file. But |:autocmd| can be used to set
|
|
||||||
options for specific file types (see |'filetype'|) using buffer variables in
|
|
||||||
the following way: >
|
|
||||||
|
|
||||||
au FileType mail,text let b:delimitMate_autoclose = 0
|
|
||||||
^ ^ ^ ^ ^
|
|
||||||
| | | | |
|
|
||||||
| | | | - Option value.
|
|
||||||
| | | - Option name.
|
|
||||||
| | - Buffer variable.
|
|
||||||
| - File types for which the option will be set.
|
|
||||||
- Don't forget to put this event.
|
|
||||||
<
|
|
||||||
NOTE that if you use buffer variables (|b:vars|) to set global settings in
|
|
||||||
your vimrc, those settings will be set for the first buffer, but they'll be
|
|
||||||
ignored for new buffers and default values will be set.
|
|
||||||
==============================================================================
|
|
||||||
3. CUSTOMIZATION *delimitMateOptions*
|
|
||||||
|
|
||||||
You can create your own mappings for some features using the global functions.
|
You can create your own mappings for some features using the global functions.
|
||||||
Read |DelimitMateFunctions| for more info.
|
Read |DelimitMateFunctions| for more info.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
3.1 OPTIONS SUMMARY *delimitMateOptionSummary*
|
2.1 OPTIONS SUMMARY *delimitMateOptionSummary*
|
||||||
|
|
||||||
The behaviour of this script can be customized setting the following options
|
The behaviour of this script can be customized setting the following options
|
||||||
in your vimrc file. You can use local options to set the configuration for
|
in your vimrc file. You can use local options to set the configuration for
|
||||||
specific file types, see |delimitMateOptionDetails| for examples.
|
specific file types, see |delimitMateOptionDetails| for examples.
|
||||||
|
|
||||||
|'loaded_delimitMate'| Turns off the script.
|
|'loaded_delimitMate'| Turns off the script.
|
||||||
|
|
||||||
|'delimitMate_autoclose'| Tells delimitMate whether to automagically
|
|'delimitMate_autoclose'| Tells delimitMate whether to automagically
|
||||||
insert the closing delimiter.
|
insert the closing delimiter.
|
||||||
|
|
||||||
|'delimitMate_matchpairs'| Tells delimitMate which characters are
|
|'delimitMate_matchpairs'| Tells delimitMate which characters are
|
||||||
matching pairs.
|
matching pairs.
|
||||||
|
|
||||||
|'delimitMate_quotes'| Tells delimitMate which quotes should be
|
|'delimitMate_quotes'| Tells delimitMate which quotes should be
|
||||||
used.
|
used.
|
||||||
|
|
||||||
|'delimitMate_visual_leader'| Sets the leader to be used in visual mode.
|
|'delimitMate_nesting_quotes'| Tells delimitMate which quotes should be
|
||||||
|
allowed to be nested.
|
||||||
|
|
||||||
|'delimitMate_expand_cr'| Turns on/off the expansion of <CR>.
|
|'delimitMate_expand_cr'| Turns on/off the expansion of <CR>.
|
||||||
|
|
||||||
|'delimitMate_expand_space'| Turns on/off the expansion of <Space>.
|
|'delimitMate_expand_space'| Turns on/off the expansion of <Space>.
|
||||||
|
|
||||||
|'delimitMate_excluded_ft'| Turns off the script for the given file types.
|
|'delimitMate_smart_quotes'| Turns on/off the "smart quotes" feature.
|
||||||
|
|
||||||
|'delimitMate_apostrophes'| Tells delimitMate how it should "fix"
|
|'delimitMate_smart_matchpairs'| Turns on/off the "smart matchpairs" feature.
|
||||||
|
|
||||||
|
|'delimitMate_balance_matchpairs'|Turns on/off the "balance matching pairs"
|
||||||
|
feature.
|
||||||
|
|
||||||
|
|'delimitMate_excluded_regions'| Turns off the script for the given regions or
|
||||||
|
syntax group names.
|
||||||
|
|
||||||
|
|'delimitMate_excluded_ft'| Turns off the script for the given file types.
|
||||||
|
|
||||||
|
|'delimitMate_apostrophes'| Tells delimitMate how it should "fix"
|
||||||
balancing of single quotes when used as
|
balancing of single quotes when used as
|
||||||
apostrophes. NOTE: Not needed any more, kept
|
apostrophes. NOTE: Not needed any more, kept
|
||||||
for compatibility with older versions.
|
for compatibility with older versions.
|
||||||
|
|
||||||
|'delimitMate_smart_quotes'| Turns on/off the "smart quotes" feature.
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
3.2 OPTIONS DETAILS *delimitMateOptionDetails*
|
2.2 OPTIONS DETAILS *delimitMateOptionDetails*
|
||||||
|
|
||||||
Add the shown lines to your vimrc file in order to set the below options.
|
Add the shown lines to your vimrc file in order to set the below options.
|
||||||
Buffer variables take precedence over global ones and can be used along with
|
Buffer variables take precedence over global ones and can be used along with
|
||||||
@@ -266,7 +143,8 @@ e.g.: >
|
|||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*'delimitMate_matchpairs'*
|
*'delimitMate_matchpairs'*
|
||||||
*'b:delimitMate_matchpairs'*
|
*'b:delimitMate_matchpairs'*
|
||||||
Values: A string with |matchpairs| syntax. ~
|
Values: A string with |'matchpairs'| syntax, plus support for multi-byte~
|
||||||
|
characters.~
|
||||||
Default: &matchpairs ~
|
Default: &matchpairs ~
|
||||||
|
|
||||||
Use this option to tell delimitMate which characters should be considered
|
Use this option to tell delimitMate which characters should be considered
|
||||||
@@ -284,20 +162,20 @@ Default: "\" ' `" ~
|
|||||||
Use this option to tell delimitMate which characters should be considered as
|
Use this option to tell delimitMate which characters should be considered as
|
||||||
quotes. Read |delimitMateAutoClose| for details.
|
quotes. Read |delimitMateAutoClose| for details.
|
||||||
e.g.: >
|
e.g.: >
|
||||||
let b:delimitMate_quotes = "\" ' ` *"
|
let delimitMate_quotes = "\" ' ` *"
|
||||||
au FileType html let b:delimitMate_quotes = "\" '"
|
au FileType html let b:delimitMate_quotes = "\" '"
|
||||||
<
|
<
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*'delimitMate_visual_leader'*
|
*'delimitMate_nesting_quotes'*
|
||||||
*'b:delimitMate_visual_leader'*
|
*'b:delimitMate_nesting_quotes'*
|
||||||
Values: Any character. ~
|
Values: A list of quotes. ~
|
||||||
Default: q ~
|
Default: [] ~
|
||||||
|
|
||||||
The value of this option will be used to wrap the selection in visual mode
|
Quotes listed here will not be able to jump out of the empty pair, thus
|
||||||
when followed by a delimiter. Read |delimitMateVisualWrap| for details.
|
allowing the autoclosed quotes to be nested.
|
||||||
e.g: >
|
e.g.: >
|
||||||
let delimitMate_visual_leader = "f"
|
let delimitMate_nesting_quotes = ['"','`']
|
||||||
au FileType html let b:delimitMate_visual_leader = "f"
|
au FileType python let b:delimitMate_nesting_quotes = ['"']
|
||||||
<
|
<
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*'delimitMate_expand_cr'*
|
*'delimitMate_expand_cr'*
|
||||||
@@ -306,22 +184,71 @@ Values: 1 or 0 ~
|
|||||||
Default: 0 ~
|
Default: 0 ~
|
||||||
|
|
||||||
This option turns on/off the expansion of <CR>. Read |delimitMateExpansion|
|
This option turns on/off the expansion of <CR>. Read |delimitMateExpansion|
|
||||||
for details.
|
for details. NOTE This feature requires that 'backspace' is either set to 2 or
|
||||||
|
has "eol" and "start" as part of its value.
|
||||||
e.g.: >
|
e.g.: >
|
||||||
let b:delimitMate_expand_cr = "\<CR>\<CR>\<Up>"
|
let delimitMate_expand_cr = 1
|
||||||
au FileType mail let b:delimitMate_expand_cr = "\<CR>"
|
au FileType mail let b:delimitMate_expand_cr = 1
|
||||||
<
|
<
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*'delimitMate_expand_space'*
|
*'delimitMate_expand_space'*
|
||||||
*'b:delimitMate_expand_space'*
|
*'b:delimitMate_expand_space'*
|
||||||
Values: A key mapping. ~
|
Values: 1 or 0 ~
|
||||||
Default: "\<Space>" ~
|
Default: 0 ~
|
||||||
|
|
||||||
This option turns on/off the expansion of <Space>. Read |delimitMateExpansion|
|
This option turns on/off the expansion of <Space>. Read |delimitMateExpansion|
|
||||||
for details.
|
for details.
|
||||||
e.g.: >
|
e.g.: >
|
||||||
let delimitMate_expand_space = "\<Space>\<Space>\<Left>"
|
let delimitMate_expand_space = 1
|
||||||
au FileType tcl let b:delimitMate_expand_space = "\<Space>"
|
au FileType tcl let b:delimitMate_expand_space = 1
|
||||||
|
<
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
*'delimitMate_smart_quotes'*
|
||||||
|
*'b:delimitMate_smart_quotes'*
|
||||||
|
Values: 1 or 0 ~
|
||||||
|
Default: 1 ~
|
||||||
|
|
||||||
|
This option turns on/off the smart quotes feature. Read
|
||||||
|
|delimitMateSmartQuotes| for details.
|
||||||
|
e.g.: >
|
||||||
|
let delimitMate_smart_quotes = 0
|
||||||
|
au FileType tcl let b:delimitMate_smart_quotes = 1
|
||||||
|
<
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
*'delimitMate_smart_matchpairs'*
|
||||||
|
*'b:delimitMate_smart_matchpairs'*
|
||||||
|
Values: Regexp ~
|
||||||
|
Default: '^\%(\w\|\!\|£\|\$\|_\|["'']\s*\S\)' ~
|
||||||
|
|
||||||
|
This regex is matched against the text to the right of cursor, if it's not
|
||||||
|
empty and there is a match delimitMate will not autoclose the pair. At the
|
||||||
|
moment to match the text, an escaped bang (\!) in the regex will be replaced
|
||||||
|
by the character being inserted, while an escaped number symbol (\#) will be
|
||||||
|
replaced by the closing pair.
|
||||||
|
e.g.: >
|
||||||
|
let delimitMate_smart_matchpairs = ''
|
||||||
|
au FileType tcl let b:delimitMate_smart_matchpairs = '^\%(\w\|\$\)'
|
||||||
|
<
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
*'delimitMate_balance_matchpairs'*
|
||||||
|
*'b:delimitMate_balance_matchpairs'*
|
||||||
|
Values: 1 or 0 ~
|
||||||
|
Default: 0 ~
|
||||||
|
|
||||||
|
This option turns on/off the balancing of matching pairs. Read
|
||||||
|
|delimitMateBalance| for details.
|
||||||
|
e.g.: >
|
||||||
|
let delimitMate_balance_matchpairs = 1
|
||||||
|
au FileType tcl let b:delimitMate_balance_matchpairs = 1
|
||||||
|
<
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
*'delimitMate_excluded_regions'*
|
||||||
|
Values: A string of syntax group names names separated by single commas. ~
|
||||||
|
Default: Comment ~
|
||||||
|
|
||||||
|
This options turns delimitMate off for the listed regions, read |group-name|
|
||||||
|
for more info about what is a region.
|
||||||
|
e.g.: >
|
||||||
|
let delimitMate_excluded_regions = "Comments,String"
|
||||||
<
|
<
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*'delimitMate_excluded_ft'*
|
*'delimitMate_excluded_ft'*
|
||||||
@@ -349,6 +276,198 @@ e.g.: >
|
|||||||
let delimitMate_apostrophes = ""
|
let delimitMate_apostrophes = ""
|
||||||
au FileType tcl let delimitMate_apostrophes = ""
|
au FileType tcl let delimitMate_apostrophes = ""
|
||||||
<
|
<
|
||||||
|
==============================================================================
|
||||||
|
3. FUNCTIONALITY *delimitMateFunctionality*
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
3.1 AUTOMATIC CLOSING AND EXITING *delimitMateAutoClose*
|
||||||
|
|
||||||
|
With automatic closing enabled, if an opening delimiter is inserted the plugin
|
||||||
|
inserts the closing delimiter and places the cursor between the pair. With
|
||||||
|
automatic closing disabled, no closing delimiters is inserted by delimitMate,
|
||||||
|
but when a pair of delimiters is typed, the cursor is placed in the middle.
|
||||||
|
|
||||||
|
When the cursor is inside an empty pair or located next to the left of a
|
||||||
|
closing delimiter, the cursor is placed outside the pair to the right of the
|
||||||
|
closing delimiter.
|
||||||
|
|
||||||
|
When |'delimitMate_smart_matchpairs'| is not empty and it matches the text to
|
||||||
|
the right of the cursor, delimitMate will not automatically insert the closing
|
||||||
|
pair.
|
||||||
|
|
||||||
|
Unless |'delimitMate_matchpairs'| or |'delimitMate_quotes'| are set, this
|
||||||
|
script uses the values in '&matchpairs' to identify the pairs, and ", ' and `
|
||||||
|
for quotes respectively.
|
||||||
|
|
||||||
|
<S-Tab> will jump over a single closing delimiter or quote, <C-G>g will jump
|
||||||
|
over contiguous delimiters and/or quotes.
|
||||||
|
|
||||||
|
The following table shows the behaviour, this applies to quotes too (the final
|
||||||
|
position of the cursor is represented by a "|"):
|
||||||
|
|
||||||
|
With auto-close: >
|
||||||
|
Type | You get
|
||||||
|
=======================
|
||||||
|
( | (|)
|
||||||
|
–––––––––––|–––––––––––
|
||||||
|
() | ()|
|
||||||
|
–––––––––––|–––––––––––
|
||||||
|
(<S-Tab> | ()|
|
||||||
|
–––––––––––|–––––––––––
|
||||||
|
{("<C-G>g | {("")}|
|
||||||
|
<
|
||||||
|
Without auto-close: >
|
||||||
|
|
||||||
|
Type | You get
|
||||||
|
=========================
|
||||||
|
() | (|)
|
||||||
|
–––––––––-----|––––––––––
|
||||||
|
()) | ()|
|
||||||
|
–––––––––-----|––––––––––
|
||||||
|
()<S-Tab> | ()|
|
||||||
|
––––––––––––––|–––––––––––
|
||||||
|
{}()""<C-G>g | {("")}|
|
||||||
|
<
|
||||||
|
NOTE: Abbreviations will not be expanded by delimiters used on delimitMate,
|
||||||
|
you should use <C-]> (read |i_CTRL-]|) to expand them on the go.
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
3.2 EXPANSION OF SPACE AND CAR RETURN *delimitMateExpansion*
|
||||||
|
|
||||||
|
When the cursor is inside an empty pair of delimiters, <Space> and <CR> can be
|
||||||
|
expanded, see |'delimitMate_expand_space'| and
|
||||||
|
|'delimitMate_expand_cr'|:
|
||||||
|
|
||||||
|
Expand <Space> to: >
|
||||||
|
|
||||||
|
<Space><Space><Left> | You get
|
||||||
|
====================================
|
||||||
|
(|) | ( | )
|
||||||
|
<
|
||||||
|
Expand <CR> to: >
|
||||||
|
|
||||||
|
<CR><CR><Up> | You get
|
||||||
|
============================
|
||||||
|
(|) | (
|
||||||
|
| |
|
||||||
|
| )
|
||||||
|
<
|
||||||
|
|
||||||
|
NOTE that the expansion of <CR> will brake the redo command.
|
||||||
|
|
||||||
|
Since <Space> and <CR> are used everywhere, I have made the functions involved
|
||||||
|
in expansions global, so they can be used to make custom mappings. Read
|
||||||
|
|delimitMateFunctions| for more details.
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
3.3 BACKSPACE *delimitMateBackspace*
|
||||||
|
|
||||||
|
If you press backspace inside an empty pair, both delimiters are deleted. When
|
||||||
|
expansions are enabled, <BS> will also delete the expansions. NOTE that
|
||||||
|
deleting <CR> expansions will brake the redo command.
|
||||||
|
|
||||||
|
If you type <S-BS> (shift + backspace) instead, only the closing delimiter
|
||||||
|
will be deleted. NOTE that this will not usually work when using Vim from the
|
||||||
|
terminal, see 'delimitMate#JumpAny()' below to see how to fix it.
|
||||||
|
|
||||||
|
e.g. typing at the "|": >
|
||||||
|
|
||||||
|
What | Before | After
|
||||||
|
==============================================
|
||||||
|
<BS> | call expand(|) | call expand|
|
||||||
|
---------|-------------------|-----------------
|
||||||
|
<BS> | call expand( | ) | call expand(|)
|
||||||
|
---------|-------------------|-----------------
|
||||||
|
<BS> | call expand( | call expand(|)
|
||||||
|
| | |
|
||||||
|
| ) |
|
||||||
|
---------|-------------------|-----------------
|
||||||
|
<S-BS> | call expand(|) | call expand(|
|
||||||
|
<
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
3.4 SMART QUOTES *delimitMateSmartQuotes*
|
||||||
|
|
||||||
|
Only one quote will be inserted following a quote, a "\" or, following or
|
||||||
|
preceding a keyword character. This should cover closing quotes after a
|
||||||
|
string, opening quotes before a string, escaped quotes and apostrophes. Except
|
||||||
|
for apostrophes, this feature can be disabled setting the option
|
||||||
|
|'delimitMate_smart_quotes'| to 0.
|
||||||
|
|
||||||
|
e.g. typing at the "|": >
|
||||||
|
|
||||||
|
What | Before | After
|
||||||
|
=======================================
|
||||||
|
" | Text | | Text "|"
|
||||||
|
" | "String| | "String"|
|
||||||
|
" | let i = "| | let i = "|"
|
||||||
|
'm | I| | I'm|
|
||||||
|
<
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
3.4 SMART MATCHPAIRS *delimitMateSmartMatchpairs*
|
||||||
|
|
||||||
|
This is similar to "smart quotes", but applied to the characters in
|
||||||
|
|'delimitMate_matchpairs'|. The difference is that delimitMate will not
|
||||||
|
auto-close the pair when the regex matches the text on the right of the
|
||||||
|
cursor. See |'delimitMate_smart_matchpairs'| for more details.
|
||||||
|
|
||||||
|
|
||||||
|
e.g. typing at the "|": >
|
||||||
|
|
||||||
|
What | Before | After
|
||||||
|
=======================================
|
||||||
|
( | function| | function(|)
|
||||||
|
( | |var | (|var
|
||||||
|
<
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
3.5 BALANCING MATCHING PAIRS *delimitMateBalance*
|
||||||
|
|
||||||
|
When inserting an opening paren and |'delimitMate_balance_matchpairs'| is
|
||||||
|
enabled, delimitMate will try to balance the closing pairs in the current
|
||||||
|
line.
|
||||||
|
|
||||||
|
e.g. typing at the "|": >
|
||||||
|
|
||||||
|
What | Before | After
|
||||||
|
=======================================
|
||||||
|
( | | | (|)
|
||||||
|
( | |) | (|)
|
||||||
|
(( | |) | ((|))
|
||||||
|
<
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
3.6 FILE TYPE BASED CONFIGURATION *delimitMateFileType*
|
||||||
|
|
||||||
|
delimitMate options can be set globally for all buffers using global
|
||||||
|
("regular") variables in your |vimrc| file. But |:autocmd| can be used to set
|
||||||
|
options for specific file types (see |'filetype'|) using buffer variables in
|
||||||
|
the following way: >
|
||||||
|
|
||||||
|
au FileType mail,text let b:delimitMate_autoclose = 0
|
||||||
|
^ ^ ^ ^ ^
|
||||||
|
| | | | |
|
||||||
|
| | | | - Option value.
|
||||||
|
| | | - Option name.
|
||||||
|
| | - Buffer variable.
|
||||||
|
| - File types for which the option will be set.
|
||||||
|
- Don't forget to put this event.
|
||||||
|
<
|
||||||
|
NOTE that you should use buffer variables (|b:var|) only to set options with
|
||||||
|
|:autocmd|, for global options use regular variables (|g:var|) in your vimrc.
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
3.7 SYNTAX AWARENESS *delimitMateSyntax*
|
||||||
|
|
||||||
|
The features of this plug-in might not be always helpful, comments and strings
|
||||||
|
usualy don't need auto-completion. delimitMate monitors which region is being
|
||||||
|
edited and if it detects that the cursor is in a comment it'll turn itself off
|
||||||
|
until the cursor leaves the comment. The excluded regions can be set using the
|
||||||
|
option |'delimitMate_excluded_regions'|. Read |group-name| for a list of
|
||||||
|
regions or syntax group names.
|
||||||
|
|
||||||
|
NOTE that this feature relies on a proper syntax file for the current file
|
||||||
|
type, if the appropiate syntax file doesn't define a region, delimitMate won't
|
||||||
|
know about it.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
4. COMMANDS *delimitMateCommands*
|
4. COMMANDS *delimitMateCommands*
|
||||||
|
|
||||||
@@ -435,34 +554,69 @@ represented by an "|": >
|
|||||||
<
|
<
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
5. FUNCTIONS *delimitMateFunctions*
|
5. MAPPINGS *delimitMateMappings*
|
||||||
|
|
||||||
|
delimitMate doesn't override any existing map, so you may encounter that it
|
||||||
|
doesn't work as expected because a mapping is missing. In that case, the
|
||||||
|
conflicting mappings should be resolved by either disabling the conflicting
|
||||||
|
mapping or creating a custom mappings.
|
||||||
|
|
||||||
|
In order to make custom mappings easier and prevent overwritting existing
|
||||||
|
ones, delimitMate uses the |<Plug>| + |hasmapto()| (|usr_41.txt|) construct
|
||||||
|
for its mappings.
|
||||||
|
|
||||||
|
These are the default mappings:
|
||||||
|
|
||||||
|
<BS> is mapped to <Plug>delimitMateBS
|
||||||
|
<S-BS> is mapped to <Plug>delimitMateS-BS
|
||||||
|
<S-Tab> is mapped to <Plug>delimitMateS-Tab
|
||||||
|
<C-G>g is mapped to <Plug>delimitMateJumpMany
|
||||||
|
<Del> is mapped to <Plug>delimitMateDel
|
||||||
|
<Esc> is mapped to <Plug>delimitMateEsc
|
||||||
|
<Left> is mapped to <Plug>delimitMateLeft
|
||||||
|
<Right> is mapped to <Plug>delimitMateRight
|
||||||
|
<Home> is mapped to <Plug>delimitMateHome
|
||||||
|
<End> is mapped to <Plug>delimitMateEnd
|
||||||
|
<Up> is mapped to <Plug>delimitMateUp
|
||||||
|
<Down> is mapped to <Plug>delimitMateDown
|
||||||
|
<PageUp> is mapped to <Plug>delimitMatePageUp
|
||||||
|
<PageDown> is mapped to <Plug>delimitMatePageDown
|
||||||
|
<S-Down> is mapped to <Plug>delimitMateS-Down
|
||||||
|
<S-Up> is mapped to <Plug>delimitMateS-Up
|
||||||
|
<LeftMouse> is mapped to <Plug>delimitMateMLeftMouse
|
||||||
|
<RightMouse> is mapped to <Plug>delimitMateMRightMouse
|
||||||
|
|
||||||
|
The rest of the mappings correspond to parens, quotes, CR, Space, etc. and they
|
||||||
|
depend on the values of the delimitMate options, they have the following form:
|
||||||
|
|
||||||
|
<Plug>delimitMate + char
|
||||||
|
|
||||||
|
e.g.: for "(":
|
||||||
|
|
||||||
|
( is mapped to <Plug>delimitMate(
|
||||||
|
|
||||||
|
e.g.: If you have <CR> expansion enabled, you might want to skip it on pop-up
|
||||||
|
menus:
|
||||||
|
|
||||||
|
imap <expr> <CR> pumvisible() ?
|
||||||
|
\"\<c-y>" :
|
||||||
|
\ "<Plug>delimitMateCR"
|
||||||
|
|
||||||
|
|
||||||
|
==============================================================================
|
||||||
|
6. FUNCTIONS *delimitMateFunctions*
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
delimitMate#WithinEmptyPair() *delimitMate_WithinEmptyPair*
|
delimitMate#WithinEmptyPair() *delimitMate#WithinEmptyPair()*
|
||||||
|
|
||||||
Returns 1 if the cursor is inside an empty pair, 0 otherwise.
|
Returns 1 if the cursor is inside an empty pair, 0 otherwise.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
delimitMate#ExpandReturn() *delimitMate#ExpandReturn()*
|
|
||||||
|
|
||||||
Returns the expansion for <CR>.
|
|
||||||
|
|
||||||
e.g.: This mapping could be used to select an item on a pop-up menu or expand
|
|
||||||
<CR> inside an empty pair: >
|
|
||||||
|
|
||||||
inoremap <expr> <CR> pumvisible() ? "\<c-y>" :
|
|
||||||
\ delimitMate#WithinEmptyPair() ?
|
|
||||||
\ delimitMate#ExpandReturn() : "\<CR>"
|
|
||||||
<
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
delimitMate#ExpandSpace() *delimitMate#ExpandSpace()*
|
|
||||||
|
|
||||||
Returns the expansion for <Space>.
|
|
||||||
e.g.: >
|
e.g.: >
|
||||||
|
|
||||||
inoremap <expr> <Space> delimitMate#WithinEmptyPair() ?
|
inoremap <expr> <CR> delimitMate#WithinEmptyPair() ?
|
||||||
\ delimitMate#ExpandSpace() : "\<Space>"
|
\ "\<C-R>=delimitMate#ExpandReturn()\<CR>" :
|
||||||
|
\ "external_mapping"
|
||||||
<
|
<
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
delimitMate#ShouldJump() *delimitMate#ShouldJump()*
|
delimitMate#ShouldJump() *delimitMate#ShouldJump()*
|
||||||
|
|
||||||
@@ -470,24 +624,23 @@ Returns 1 if there is a closing delimiter or a quote to the right of the
|
|||||||
cursor, 0 otherwise.
|
cursor, 0 otherwise.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
delimitMate#JumpAny() *delimitMate#JumpAny()*
|
delimitMate#JumpAny(key) *delimitMate#JumpAny()*
|
||||||
|
|
||||||
This function returns a mapping that will make the cursor jump to the right.
|
This function returns a mapping that will make the cursor jump to the right
|
||||||
|
when delimitMate#ShouldJump() returns 1, returns the argument "key" otherwise.
|
||||||
e.g.: You can use this to create your own mapping to jump over any delimiter.
|
e.g.: You can use this to create your own mapping to jump over any delimiter.
|
||||||
>
|
>
|
||||||
inoremap <expr> <C-Tab> delimitMate#ShouldJump() ?
|
inoremap <C-Tab> <C-R>=delimitMate#JumpAny("\<C-Tab>")<CR>
|
||||||
\ delimitMate#JumpAny() : "\<C-Tab>"
|
|
||||||
<
|
<
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
6. TODO LIST *delimitMateTodo*
|
7. TODO LIST *delimitMateTodo*
|
||||||
|
|
||||||
- Automatic set-up by file type.
|
- Automatic set-up by file type.
|
||||||
- Make visual wrapping work on blockwise visual mode.
|
- Make block-wise visual wrapping work on un-even regions.
|
||||||
- Limit behaviour by region.
|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
7. MAINTAINER *delimitMateMaintainer*
|
8. MAINTAINER *delimitMateMaintainer*
|
||||||
|
|
||||||
Hi there! My name is Israel Chauca F. and I can be reached at:
|
Hi there! My name is Israel Chauca F. and I can be reached at:
|
||||||
mailto:israelchauca@gmail.com
|
mailto:israelchauca@gmail.com
|
||||||
@@ -496,39 +649,99 @@ Feel free to send me any suggestions and/or comments about this plugin, I'll
|
|||||||
be very pleased to read them.
|
be very pleased to read them.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
8. CREDITS *delimitMateCredits*
|
9. CREDITS *delimitMateCredits*
|
||||||
|
|
||||||
Some of the code that make this script is modified or just shamelessly copied
|
Contributors: ~
|
||||||
from the following sources:
|
|
||||||
|
|
||||||
- Ian McCracken
|
- Kim Silkebækken ~
|
||||||
Post titled: Vim, Part II: Matching Pairs:
|
Fixed mappings being echoed in the terminal.
|
||||||
http://concisionandconcinnity.blogspot.com/
|
|
||||||
|
|
||||||
- Aristotle Pagaltzis
|
- Eric Van Dewoestine ~
|
||||||
From the comments on the previous blog post and from:
|
Implemented smart matchpairs.
|
||||||
http://gist.github.com/144619
|
|
||||||
|
|
||||||
- Vim Scripts:
|
Some of the code that makes this script was modified or just shamelessly
|
||||||
http://www.vim.org/scripts
|
copied from the following sources:
|
||||||
|
|
||||||
This script was inspired by the auto-completion of delimiters of TextMate.
|
- Ian McCracken ~
|
||||||
|
Post titled: Vim, Part II: Matching Pairs:
|
||||||
|
http://concisionandconcinnity.blogspot.com/
|
||||||
|
|
||||||
|
- Aristotle Pagaltzis ~
|
||||||
|
From the comments on the previous blog post and from:
|
||||||
|
http://gist.github.com/144619
|
||||||
|
|
||||||
|
- Karl Guertin ~
|
||||||
|
AutoClose:
|
||||||
|
http://www.vim.org/scripts/script.php?script_id=1849
|
||||||
|
|
||||||
|
- Thiago Alves ~
|
||||||
|
AutoClose:
|
||||||
|
http://www.vim.org/scripts/script.php?script_id=2009
|
||||||
|
|
||||||
|
- Edoardo Vacchi ~
|
||||||
|
ClosePairs:
|
||||||
|
http://www.vim.org/scripts/script.php?script_id=2373
|
||||||
|
|
||||||
|
This script was inspired by the auto-completion of delimiters on TextMate.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
9. HISTORY *delimitMateHistory*
|
10. HISTORY *delimitMateHistory*
|
||||||
|
|
||||||
Version Date Release notes ~
|
Version Date Release notes ~
|
||||||
|---------|------------|-----------------------------------------------------|
|
|---------|------------|-----------------------------------------------------|
|
||||||
2.2 2010-05-16 * Current release:
|
2.6 2011-01-14 * Current release:
|
||||||
- Added command to switch the plug-in on and off.
|
- Add smart_matchpairs feature.
|
||||||
|
- Add mapping to jump over contiguous delimiters.
|
||||||
|
- Fix behaviour of b:loaded_delimitMate.
|
||||||
|
|---------|------------|-----------------------------------------------------|
|
||||||
|
2.5.1 2010-09-30 * - Remove visual wrapping. Surround.vim offers a much
|
||||||
|
better implementation.
|
||||||
|
- Minor mods to DelimitMateTest.
|
||||||
|
|---------|------------|-----------------------------------------------------|
|
||||||
|
2.5 2010-09-22 * - Better handling of mappings.
|
||||||
|
- Add report for mappings in |:DelimitMateTest|.
|
||||||
|
- Allow the use of "|" and multi-byte characters in
|
||||||
|
|'delimitMate_quotes'| and |'delimitMate_matchpairs'|.
|
||||||
|
- Allow commands to be concatenated using |.
|
||||||
|
|---------|------------|-----------------------------------------------------|
|
||||||
|
2.4.1 2010-07-31 * - Fix problem with <Home> and <End>.
|
||||||
|
- Add missing doc on |'delimitMate_smart_quotes'|,
|
||||||
|
|delimitMateBalance| and
|
||||||
|
|'delimitMate_balance_matchpairs'|.
|
||||||
|
|---------|------------|-----------------------------------------------------|
|
||||||
|
2.4 2010-07-29 * - Unbalanced parens: see :help delimitMateBalance.
|
||||||
|
- Visual wrapping now works on block-wise visual
|
||||||
|
with some limitations.
|
||||||
|
- Arrow keys didn't work on terminal.
|
||||||
|
- Added option to allow nested quotes.
|
||||||
|
- Expand Smart Quotes to look for a string on the
|
||||||
|
right of the cursor.
|
||||||
|
|
||||||
|
|---------|------------|-----------------------------------------------------|
|
||||||
|
2.3.1 2010-06-06 * - Fix: an extra <Space> is inserted after <Space>
|
||||||
|
expansion.
|
||||||
|
|
||||||
|
|---------|------------|-----------------------------------------------------|
|
||||||
|
2.3 2010-06-06 * - Syntax aware: Will turn off when editing comments
|
||||||
|
or other regions, customizable.
|
||||||
|
- Changed format of most mappings.
|
||||||
|
- Fix: <CR> expansion doesn't brake automatic
|
||||||
|
indentation adjustments anymore.
|
||||||
|
- Fix: Arrow keys would insert A, B, C or D instead
|
||||||
|
of moving the cursor when using Vim on a terminal.
|
||||||
|
|
||||||
|
|---------|------------|-----------------------------------------------------|
|
||||||
|
2.2 2010-05-16 * - Added command to switch the plug-in on and off.
|
||||||
- Fix: some problems with <Left>, <Right> and <CR>.
|
- Fix: some problems with <Left>, <Right> and <CR>.
|
||||||
- Fix: A small problem when inserting a delimiter at
|
- Fix: A small problem when inserting a delimiter at
|
||||||
the beginning of the line.
|
the beginning of the line.
|
||||||
|
|
||||||
|---------|------------|-----------------------------------------------------|
|
|---------|------------|-----------------------------------------------------|
|
||||||
2.1 2010-05-10 * - Most of the functions have been moved to an
|
2.1 2010-05-10 * - Most of the functions have been moved to an
|
||||||
autoload script to avoid loading unnecessary ones.
|
autoload script to avoid loading unnecessary ones.
|
||||||
- Fixed a problem with the redo command.
|
- Fixed a problem with the redo command.
|
||||||
- Many small fixes.
|
- Many small fixes.
|
||||||
|
|
||||||
|---------|------------|-----------------------------------------------------|
|
|---------|------------|-----------------------------------------------------|
|
||||||
2.0 2010-04-01 * New features:
|
2.0 2010-04-01 * New features:
|
||||||
- All features are redo/undo-wise safe.
|
- All features are redo/undo-wise safe.
|
||||||
@@ -544,7 +757,6 @@ This script was inspired by the auto-completion of delimiters of TextMate.
|
|||||||
active if you have any of the expansion options
|
active if you have any of the expansion options
|
||||||
set.
|
set.
|
||||||
- <S-Backspace> deletes the closing delimiter.
|
- <S-Backspace> deletes the closing delimiter.
|
||||||
|
|
||||||
* Fixed bug:
|
* Fixed bug:
|
||||||
- s:vars were being used to store buffer options.
|
- s:vars were being used to store buffer options.
|
||||||
|
|
||||||
@@ -596,9 +808,11 @@ This script was inspired by the auto-completion of delimiters of TextMate.
|
|||||||
|---------|------------|-----------------------------------------------------|
|
|---------|------------|-----------------------------------------------------|
|
||||||
|
|
||||||
|
|
||||||
... |"| _ _ . . ___ ~
|
`\|||/´ MMM \|/ www __^__ ~
|
||||||
o,*,(o o) _|_|_ o' \,=./ `o . .:::. /_\ `* ~
|
(o o) (o o) @ @ (O-O) /(o o)\\ ~
|
||||||
8(o o)(_)Ooo (o o) (o o) :(o o): . (o o) ~
|
ooO_(_)_Ooo__ ooO_(_)_Ooo___oOO_(_)_OOo___oOO__(_)__OOo___oOO__(_)__OOo_____ ~
|
||||||
---ooO-(_)---Ooo----ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo- ~
|
_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|____ ~
|
||||||
|
__|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_ ~
|
||||||
|
_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|____ ~
|
||||||
|
|
||||||
vim:tw=78:ts=8:ft=help:norl:formatoptions+=tcroqn:autoindent:
|
vim:tw=78:et:ts=2:sw=2:ft=help:norl:formatoptions+=tcroqn:autoindent:
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
" ============================================================================
|
|
||||||
" File: plugin/delimitMate.vim
|
" File: plugin/delimitMate.vim
|
||||||
" Version: 2.2
|
" Version: 2.6
|
||||||
" Modified: 2010-05-16
|
" Modified: 2011-01-14
|
||||||
" Description: This plugin provides auto-completion for quotes, parens, etc.
|
" Description: This plugin provides auto-completion for quotes, parens, etc.
|
||||||
" Maintainer: Israel Chauca F. <israelchauca@gmail.com>
|
" Maintainer: Israel Chauca F. <israelchauca@gmail.com>
|
||||||
" Manual: Read ":help delimitMate".
|
" Manual: Read ":help delimitMate".
|
||||||
|
" ============================================================================
|
||||||
|
|
||||||
" Initialization: {{{
|
" Initialization: {{{
|
||||||
if exists("g:loaded_delimitMate") "{{{
|
|
||||||
" User doesn't want this plugin, let's get out!
|
if exists("g:loaded_delimitMate") || &cp
|
||||||
|
" User doesn't want this plugin or compatible is set, let's get out!
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
let g:loaded_delimitMate = 1
|
let g:loaded_delimitMate = 1
|
||||||
@@ -25,25 +26,183 @@ if v:version < 700
|
|||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let s:loaded_delimitMate = 1 " }}}
|
let s:loaded_delimitMate = 1
|
||||||
let delimitMate_version = '2.2'
|
let delimitMate_version = "2.6"
|
||||||
|
|
||||||
|
function! s:option_init(name, default) "{{{
|
||||||
|
let b = exists("b:delimitMate_" . a:name)
|
||||||
|
let g = exists("g:delimitMate_" . a:name)
|
||||||
|
let prefix = "_l_delimitMate_"
|
||||||
|
|
||||||
|
if !b && !g
|
||||||
|
let sufix = a:default
|
||||||
|
elseif !b && g
|
||||||
|
exec "let sufix = g:delimitMate_" . a:name
|
||||||
|
else
|
||||||
|
exec "let sufix = b:delimitMate_" . a:name
|
||||||
|
endif
|
||||||
|
if exists("b:" . prefix . a:name)
|
||||||
|
exec "unlockvar! b:" . prefix . a:name
|
||||||
|
endif
|
||||||
|
exec "let b:" . prefix . a:name . " = " . string(sufix)
|
||||||
|
exec "lockvar! b:" . prefix . a:name
|
||||||
|
endfunction "}}}
|
||||||
|
|
||||||
|
function! s:init() "{{{
|
||||||
|
" Initialize variables:
|
||||||
|
|
||||||
|
" autoclose
|
||||||
|
call s:option_init("autoclose", 1)
|
||||||
|
|
||||||
|
" matchpairs
|
||||||
|
call s:option_init("matchpairs", string(&matchpairs)[1:-2])
|
||||||
|
call s:option_init("matchpairs_list", split(b:_l_delimitMate_matchpairs, ','))
|
||||||
|
call s:option_init("left_delims", split(b:_l_delimitMate_matchpairs, ':.,\='))
|
||||||
|
call s:option_init("right_delims", split(b:_l_delimitMate_matchpairs, ',\=.:'))
|
||||||
|
|
||||||
|
" quotes
|
||||||
|
call s:option_init("quotes", "\" ' `")
|
||||||
|
call s:option_init("quotes_list", split(b:_l_delimitMate_quotes))
|
||||||
|
|
||||||
|
" nesting_quotes
|
||||||
|
call s:option_init("nesting_quotes", [])
|
||||||
|
|
||||||
|
" excluded_regions
|
||||||
|
call s:option_init("excluded_regions", "Comment")
|
||||||
|
call s:option_init("excluded_regions_list", split(b:_l_delimitMate_excluded_regions, ',\s*'))
|
||||||
|
let enabled = len(b:_l_delimitMate_excluded_regions_list) > 0
|
||||||
|
call s:option_init("excluded_regions_enabled", enabled)
|
||||||
|
|
||||||
|
" excluded filetypes
|
||||||
|
call s:option_init("excluded_ft", "")
|
||||||
|
|
||||||
|
" expand_space
|
||||||
|
if exists("b:delimitMate_expand_space") && type(b:delimitMate_expand_space) == type("")
|
||||||
|
echom "b:delimitMate_expand_space is '".b:delimitMate_expand_space."' but it must be either 1 or 0!"
|
||||||
|
echom "Read :help 'delimitMate_expand_space' for more details."
|
||||||
|
unlet b:delimitMate_expand_space
|
||||||
|
let b:delimitMate_expand_space = 1
|
||||||
|
endif
|
||||||
|
if exists("g:delimitMate_expand_space") && type(g:delimitMate_expand_space) == type("")
|
||||||
|
echom "delimitMate_expand_space is '".g:delimitMate_expand_space."' but it must be either 1 or 0!"
|
||||||
|
echom "Read :help 'delimitMate_expand_space' for more details."
|
||||||
|
unlet g:delimitMate_expand_space
|
||||||
|
let g:delimitMate_expand_space = 1
|
||||||
|
endif
|
||||||
|
call s:option_init("expand_space", 0)
|
||||||
|
|
||||||
|
" expand_cr
|
||||||
|
if exists("b:delimitMate_expand_cr") && type(b:delimitMate_expand_cr) == type("")
|
||||||
|
echom "b:delimitMate_expand_cr is '".b:delimitMate_expand_cr."' but it must be either 1 or 0!"
|
||||||
|
echom "Read :help 'delimitMate_expand_cr' for more details."
|
||||||
|
unlet b:delimitMate_expand_cr
|
||||||
|
let b:delimitMate_expand_cr = 1
|
||||||
|
endif
|
||||||
|
if exists("g:delimitMate_expand_cr") && type(g:delimitMate_expand_cr) == type("")
|
||||||
|
echom "delimitMate_expand_cr is '".g:delimitMate_expand_cr."' but it must be either 1 or 0!"
|
||||||
|
echom "Read :help 'delimitMate_expand_cr' for more details."
|
||||||
|
unlet g:delimitMate_expand_cr
|
||||||
|
let g:delimitMate_expand_cr = 1
|
||||||
|
endif
|
||||||
|
if ((&backspace !~ 'eol' || &backspace !~ 'start') && &backspace != 2) &&
|
||||||
|
\ ((exists('b:delimitMate_expand_cr') && b:delimitMate_expand_cr == 1) ||
|
||||||
|
\ (exists('g:delimitMate_expand_cr') && g:delimitMate_expand_cr == 1))
|
||||||
|
echom "delimitMate: There seems to be some incompatibility with your settings that may interfer with the expansion of <CR>. See :help 'delimitMate_expand_cr' for details."
|
||||||
|
endif
|
||||||
|
call s:option_init("expand_cr", 0)
|
||||||
|
|
||||||
|
" smart_matchpairs
|
||||||
|
call s:option_init("smart_matchpairs", '^\%(\w\|\!\|£\|\$\|_\|["'']\s*\S\)')
|
||||||
|
|
||||||
|
" smart_quotes
|
||||||
|
call s:option_init("smart_quotes", 1)
|
||||||
|
|
||||||
|
" apostrophes
|
||||||
|
call s:option_init("apostrophes", "")
|
||||||
|
call s:option_init("apostrophes_list", split(b:_l_delimitMate_apostrophes, ":\s*"))
|
||||||
|
|
||||||
|
" tab2exit
|
||||||
|
call s:option_init("tab2exit", 1)
|
||||||
|
|
||||||
|
" balance_matchpairs
|
||||||
|
call s:option_init("balance_matchpairs", 0)
|
||||||
|
|
||||||
|
let b:_l_delimitMate_buffer = []
|
||||||
|
|
||||||
|
endfunction "}}} Init()
|
||||||
|
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
" Tools: {{{
|
" Functions: {{{
|
||||||
|
|
||||||
|
function! s:Map() "{{{
|
||||||
|
" Set mappings:
|
||||||
|
try
|
||||||
|
let save_cpo = &cpo
|
||||||
|
let save_keymap = &keymap
|
||||||
|
let save_iminsert = &iminsert
|
||||||
|
let save_imsearch = &imsearch
|
||||||
|
set keymap=
|
||||||
|
set cpo&vim
|
||||||
|
if b:_l_delimitMate_autoclose
|
||||||
|
call s:AutoClose()
|
||||||
|
else
|
||||||
|
call s:NoAutoClose()
|
||||||
|
endif
|
||||||
|
call s:ExtraMappings()
|
||||||
|
finally
|
||||||
|
let &cpo = save_cpo
|
||||||
|
let &keymap = save_keymap
|
||||||
|
let &iminsert = save_iminsert
|
||||||
|
let &imsearch = save_imsearch
|
||||||
|
endtry
|
||||||
|
|
||||||
|
let b:delimitMate_enabled = 1
|
||||||
|
|
||||||
|
endfunction "}}} Map()
|
||||||
|
|
||||||
|
function! s:Unmap() " {{{
|
||||||
|
let imaps =
|
||||||
|
\ b:_l_delimitMate_right_delims +
|
||||||
|
\ b:_l_delimitMate_left_delims +
|
||||||
|
\ b:_l_delimitMate_quotes_list +
|
||||||
|
\ b:_l_delimitMate_apostrophes_list +
|
||||||
|
\ ['<BS>', '<S-BS>', '<Del>', '<CR>', '<Space>', '<S-Tab>', '<Esc>'] +
|
||||||
|
\ ['<Up>', '<Down>', '<Left>', '<Right>', '<LeftMouse>', '<RightMouse>'] +
|
||||||
|
\ ['<Home>', '<End>', '<PageUp>', '<PageDown>', '<S-Down>', '<S-Up>', '<C-G>g']
|
||||||
|
|
||||||
|
for map in imaps
|
||||||
|
if maparg(map, "i") =~? 'delimitMate'
|
||||||
|
if map == '|'
|
||||||
|
let map = '<Bar>'
|
||||||
|
endif
|
||||||
|
exec 'silent! iunmap <buffer> ' . map
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
|
||||||
|
if !has('gui_running')
|
||||||
|
silent! iunmap <C-[>OC
|
||||||
|
endif
|
||||||
|
|
||||||
|
let b:delimitMate_enabled = 0
|
||||||
|
endfunction " }}} s:Unmap()
|
||||||
|
|
||||||
function! s:TestMappingsDo() "{{{
|
function! s:TestMappingsDo() "{{{
|
||||||
|
%d
|
||||||
if !exists("g:delimitMate_testing")
|
if !exists("g:delimitMate_testing")
|
||||||
silent call delimitMate#TestMappings()
|
silent call delimitMate#TestMappings()
|
||||||
else
|
else
|
||||||
let temp_varsDM = [b:delimitMate_expand_space, b:delimitMate_expand_cr, b:delimitMate_autoclose]
|
let temp_varsDM = [b:_l_delimitMate_expand_space, b:_l_delimitMate_expand_cr, b:_l_delimitMate_autoclose]
|
||||||
for i in [0,1]
|
for i in [0,1]
|
||||||
let b:delimitMate_expand_space = i
|
let b:delimitMate_expand_space = i
|
||||||
let b:delimitMate_expand_cr = i
|
let b:delimitMate_expand_cr = i
|
||||||
for a in [0,1]
|
for a in [0,1]
|
||||||
let b:delimitMate_autoclose = a
|
let b:delimitMate_autoclose = a
|
||||||
call delimitMate#Init()
|
call s:init()
|
||||||
|
call s:Unmap()
|
||||||
|
call s:Map()
|
||||||
call delimitMate#TestMappings()
|
call delimitMate#TestMappings()
|
||||||
exec "normal i\<CR>"
|
call append(line('$'),'')
|
||||||
endfor
|
endfor
|
||||||
endfor
|
endfor
|
||||||
let b:delimitMate_expand_space = temp_varsDM[0]
|
let b:delimitMate_expand_space = temp_varsDM[0]
|
||||||
@@ -52,66 +211,222 @@ function! s:TestMappingsDo() "{{{
|
|||||||
unlet temp_varsDM
|
unlet temp_varsDM
|
||||||
endif
|
endif
|
||||||
normal gg
|
normal gg
|
||||||
|
g/\%^$/d
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! s:DelimitMateDo() "{{{
|
function! s:DelimitMateDo(...) "{{{
|
||||||
if exists("g:delimitMate_excluded_ft")
|
|
||||||
" Check if this file type is excluded:
|
" First, remove all magic, if needed:
|
||||||
for ft in split(g:delimitMate_excluded_ft,',')
|
if exists("b:delimitMate_enabled") && b:delimitMate_enabled == 1
|
||||||
if ft ==? &filetype
|
call s:Unmap()
|
||||||
"echomsg "excluded"
|
endif
|
||||||
call delimitMate#UnMap()
|
|
||||||
return 1
|
" Check if this file type is excluded:
|
||||||
endif
|
if exists("g:delimitMate_excluded_ft") &&
|
||||||
endfor
|
\ index(split(g:delimitMate_excluded_ft, ','), &filetype, 0, 1) >= 0
|
||||||
|
|
||||||
|
" Finish here:
|
||||||
|
return 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Check if user tried to disable using b:loaded_delimitMate
|
||||||
|
if exists("b:loaded_delimitMate")
|
||||||
|
return 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Initialize settings:
|
||||||
|
call s:init()
|
||||||
|
|
||||||
|
" Now, add magic:
|
||||||
|
call s:Map()
|
||||||
|
|
||||||
|
if a:0 > 0
|
||||||
|
echo "delimitMate has been reset."
|
||||||
endif
|
endif
|
||||||
try
|
|
||||||
"echomsg "included"
|
|
||||||
let save_cpo = &cpo
|
|
||||||
let save_keymap = &keymap
|
|
||||||
set keymap=
|
|
||||||
set cpo&vim
|
|
||||||
call delimitMate#Init()
|
|
||||||
finally
|
|
||||||
let &cpo = save_cpo
|
|
||||||
let &keymap = save_keymap
|
|
||||||
endtry
|
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! s:DelimitMateSwitch() "{{{
|
function! s:DelimitMateSwitch() "{{{
|
||||||
if b:delimitMate_enabled
|
if exists("b:delimitMate_enabled") && b:delimitMate_enabled
|
||||||
call delimitMate#UnMap()
|
call s:Unmap()
|
||||||
|
echo "delimitMate has been disabled."
|
||||||
else
|
else
|
||||||
call delimitMate#Init()
|
call s:Unmap()
|
||||||
|
call s:init()
|
||||||
|
call s:Map()
|
||||||
|
echo "delimitMate has been enabled."
|
||||||
|
endif
|
||||||
|
endfunction "}}}
|
||||||
|
|
||||||
|
function! s:Finish() " {{{
|
||||||
|
if exists('g:delimitMate_loaded')
|
||||||
|
return delimitMate#Finish(1)
|
||||||
|
endif
|
||||||
|
return ''
|
||||||
|
endfunction " }}}
|
||||||
|
|
||||||
|
function! s:FlushBuffer() " {{{
|
||||||
|
if exists('g:delimitMate_loaded')
|
||||||
|
return delimitMate#FlushBuffer()
|
||||||
|
endif
|
||||||
|
return ''
|
||||||
|
endfunction " }}}
|
||||||
|
|
||||||
|
"}}}
|
||||||
|
|
||||||
|
" Mappers: {{{
|
||||||
|
function! s:NoAutoClose() "{{{
|
||||||
|
" inoremap <buffer> ) <C-R>=delimitMate#SkipDelim('\)')<CR>
|
||||||
|
for delim in b:_l_delimitMate_right_delims + b:_l_delimitMate_quotes_list
|
||||||
|
if delim == '|'
|
||||||
|
let delim = '<Bar>'
|
||||||
|
endif
|
||||||
|
exec 'inoremap <silent> <Plug>delimitMate' . delim . ' <C-R>=delimitMate#SkipDelim("' . escape(delim,'"') . '")<CR>'
|
||||||
|
exec 'silent! imap <unique> <buffer> '.delim.' <Plug>delimitMate'.delim
|
||||||
|
endfor
|
||||||
|
endfunction "}}}
|
||||||
|
|
||||||
|
function! s:AutoClose() "{{{
|
||||||
|
" Add matching pair and jump to the midle:
|
||||||
|
" inoremap <silent> <buffer> ( ()<Left>
|
||||||
|
let i = 0
|
||||||
|
while i < len(b:_l_delimitMate_matchpairs_list)
|
||||||
|
let ld = b:_l_delimitMate_left_delims[i] == '|' ? '<bar>' : b:_l_delimitMate_left_delims[i]
|
||||||
|
let rd = b:_l_delimitMate_right_delims[i] == '|' ? '<bar>' : b:_l_delimitMate_right_delims[i]
|
||||||
|
exec 'inoremap <silent> <Plug>delimitMate' . ld . ' ' . ld . '<C-R>=delimitMate#ParenDelim("' . escape(rd, '|') . '")<CR>'
|
||||||
|
exec 'silent! imap <unique> <buffer> '.ld.' <Plug>delimitMate'.ld
|
||||||
|
let i += 1
|
||||||
|
endwhile
|
||||||
|
|
||||||
|
" Exit from inside the matching pair:
|
||||||
|
for delim in b:_l_delimitMate_right_delims
|
||||||
|
exec 'inoremap <silent> <Plug>delimitMate' . delim . ' <C-R>=delimitMate#JumpOut("\' . delim . '")<CR>'
|
||||||
|
exec 'silent! imap <unique> <buffer> ' . delim . ' <Plug>delimitMate'. delim
|
||||||
|
endfor
|
||||||
|
|
||||||
|
" Add matching quote and jump to the midle, or exit if inside a pair of matching quotes:
|
||||||
|
" inoremap <silent> <buffer> " <C-R>=delimitMate#QuoteDelim("\"")<CR>
|
||||||
|
for delim in b:_l_delimitMate_quotes_list
|
||||||
|
if delim == '|'
|
||||||
|
let delim = '<Bar>'
|
||||||
|
endif
|
||||||
|
exec 'inoremap <silent> <Plug>delimitMate' . delim . ' <C-R>=delimitMate#QuoteDelim("\' . delim . '")<CR>'
|
||||||
|
exec 'silent! imap <unique> <buffer> ' . delim . ' <Plug>delimitMate' . delim
|
||||||
|
endfor
|
||||||
|
|
||||||
|
" Try to fix the use of apostrophes (kept for backward compatibility):
|
||||||
|
" inoremap <silent> <buffer> n't n't
|
||||||
|
for map in b:_l_delimitMate_apostrophes_list
|
||||||
|
exec "inoremap <silent> " . map . " " . map
|
||||||
|
exec 'silent! imap <unique> <buffer> ' . map . ' <Plug>delimitMate' . map
|
||||||
|
endfor
|
||||||
|
endfunction "}}}
|
||||||
|
|
||||||
|
function! s:ExtraMappings() "{{{
|
||||||
|
" If pair is empty, delete both delimiters:
|
||||||
|
inoremap <silent> <Plug>delimitMateBS <C-R>=delimitMate#BS()<CR>
|
||||||
|
if !hasmapto('<Plug>delimitMateBS','i')
|
||||||
|
silent! imap <unique> <buffer> <BS> <Plug>delimitMateBS
|
||||||
|
endif
|
||||||
|
" If pair is empty, delete closing delimiter:
|
||||||
|
inoremap <silent> <expr> <Plug>delimitMateS-BS delimitMate#WithinEmptyPair() ? "\<C-R>=delimitMate#Del()\<CR>" : "\<S-BS>"
|
||||||
|
if !hasmapto('<Plug>delimitMateS-BS','i')
|
||||||
|
silent! imap <unique> <buffer> <S-BS> <Plug>delimitMateS-BS
|
||||||
|
endif
|
||||||
|
" Expand return if inside an empty pair:
|
||||||
|
inoremap <silent> <Plug>delimitMateCR <C-R>=delimitMate#ExpandReturn()<CR>
|
||||||
|
if b:_l_delimitMate_expand_cr != 0 && !hasmapto('<Plug>delimitMateCR', 'i')
|
||||||
|
silent! imap <unique> <buffer> <CR> <Plug>delimitMateCR
|
||||||
|
endif
|
||||||
|
" Expand space if inside an empty pair:
|
||||||
|
inoremap <silent> <Plug>delimitMateSpace <C-R>=delimitMate#ExpandSpace()<CR>
|
||||||
|
if b:_l_delimitMate_expand_space != 0 && !hasmapto('<Plug>delimitMateSpace', 'i')
|
||||||
|
silent! imap <unique> <buffer> <Space> <Plug>delimitMateSpace
|
||||||
|
endif
|
||||||
|
" Jump over any delimiter:
|
||||||
|
inoremap <silent> <Plug>delimitMateS-Tab <C-R>=delimitMate#JumpAny("\<S-Tab>")<CR>
|
||||||
|
if b:_l_delimitMate_tab2exit && !hasmapto('<Plug>delimitMateS-Tab', 'i')
|
||||||
|
silent! imap <unique> <buffer> <S-Tab> <Plug>delimitMateS-Tab
|
||||||
|
endif
|
||||||
|
" Change char buffer on Del:
|
||||||
|
inoremap <silent> <Plug>delimitMateDel <C-R>=delimitMate#Del()<CR>
|
||||||
|
if !hasmapto('<Plug>delimitMateDel', 'i')
|
||||||
|
silent! imap <unique> <buffer> <Del> <Plug>delimitMateDel
|
||||||
|
endif
|
||||||
|
" Flush the char buffer on movement keystrokes or when leaving insert mode:
|
||||||
|
for map in ['Esc', 'Left', 'Right', 'Home', 'End']
|
||||||
|
exec 'inoremap <silent> <Plug>delimitMate'.map.' <C-R>=<SID>Finish()<CR><'.map.'>'
|
||||||
|
if !hasmapto('<Plug>delimitMate'.map, 'i')
|
||||||
|
exec 'silent! imap <unique> <buffer> <'.map.'> <Plug>delimitMate'.map
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
" Except when pop-up menu is active:
|
||||||
|
for map in ['Up', 'Down', 'PageUp', 'PageDown', 'S-Down', 'S-Up']
|
||||||
|
exec 'inoremap <silent> <expr> <Plug>delimitMate'.map.' pumvisible() ? "\<'.map.'>" : "\<C-R>=\<SID>Finish()\<CR>\<'.map.'>"'
|
||||||
|
if !hasmapto('<Plug>delimitMate'.map, 'i')
|
||||||
|
exec 'silent! imap <unique> <buffer> <'.map.'> <Plug>delimitMate'.map
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
" Avoid ambiguous mappings:
|
||||||
|
for map in ['LeftMouse', 'RightMouse']
|
||||||
|
exec 'inoremap <silent> <Plug>delimitMateM'.map.' <C-R>=delimitMate#Finish(1)<CR><'.map.'>'
|
||||||
|
if !hasmapto('<Plug>delimitMate'.map, 'i')
|
||||||
|
exec 'silent! imap <unique> <buffer> <'.map.'> <Plug>delimitMateM'.map
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
|
||||||
|
" Jump over next delimiters
|
||||||
|
inoremap <buffer> <Plug>delimitMateJumpMany <C-R>=len(b:_l_delimitMate_buffer) ? delimitMate#Finish(0) : delimitMate#JumpMany()<CR>
|
||||||
|
if !hasmapto('<Plug>delimitMateJumpMany')
|
||||||
|
imap <silent> <buffer> <C-G>g <Plug>delimitMateJumpMany
|
||||||
|
endif
|
||||||
|
|
||||||
|
" The following simply creates an ambiguous mapping so vim fully processes
|
||||||
|
" the escape sequence for terminal keys, see 'ttimeout' for a rough
|
||||||
|
" explanation, this just forces it to work
|
||||||
|
if !has('gui_running')
|
||||||
|
imap <silent> <C-[>OC <RIGHT>
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
" Commands: {{{
|
" Commands: {{{
|
||||||
|
|
||||||
call s:DelimitMateDo()
|
call s:DelimitMateDo()
|
||||||
|
|
||||||
" Let me refresh without re-loading the buffer:
|
" Let me refresh without re-loading the buffer:
|
||||||
command! DelimitMateReload call s:DelimitMateDo()
|
command! -bar DelimitMateReload call s:DelimitMateDo(1)
|
||||||
|
|
||||||
" Quick test:
|
" Quick test:
|
||||||
command! DelimitMateTest call s:TestMappingsDo()
|
command! -bar DelimitMateTest silent call s:TestMappingsDo()
|
||||||
|
|
||||||
" Switch On/Off:
|
" Switch On/Off:
|
||||||
command! DelimitMateSwitch call s:DelimitMateSwitch()
|
command! -bar DelimitMateSwitch call s:DelimitMateSwitch()
|
||||||
|
"}}}
|
||||||
|
|
||||||
" Run on file type events.
|
" Autocommands: {{{
|
||||||
"autocmd VimEnter * autocmd FileType * call <SID>DelimitMateDo()
|
|
||||||
autocmd FileType * call <SID>DelimitMateDo()
|
|
||||||
|
|
||||||
" Run on new buffers.
|
augroup delimitMate
|
||||||
autocmd BufNewFile,BufRead,BufEnter * if !exists("b:loaded_delimitMate") | call <SID>DelimitMateDo() | endif
|
au!
|
||||||
|
" Run on file type change.
|
||||||
|
"autocmd VimEnter * autocmd FileType * call <SID>DelimitMateDo()
|
||||||
|
autocmd FileType * call <SID>DelimitMateDo()
|
||||||
|
|
||||||
" Flush the char buffer:
|
" Run on new buffers.
|
||||||
autocmd InsertEnter * call delimitMate#FlushBuffer()
|
autocmd BufNewFile,BufRead,BufEnter *
|
||||||
autocmd BufEnter * if mode() == 'i' | call delimitMate#FlushBuffer() | endif
|
\ if !exists('b:delimitMate_was_here') |
|
||||||
|
\ call <SID>DelimitMateDo() |
|
||||||
|
\ let b:delimitMate_was_here = 1 |
|
||||||
|
\ endif
|
||||||
|
|
||||||
"function! s:GetSynRegion () | echo synIDattr(synIDtrans(synID(line('.'), col('.'), 1)), 'name') | endfunction
|
" Flush the char buffer:
|
||||||
|
autocmd InsertEnter * call <SID>FlushBuffer()
|
||||||
|
autocmd BufEnter *
|
||||||
|
\ if mode() == 'i' |
|
||||||
|
\ call <SID>FlushBuffer() |
|
||||||
|
\ endif
|
||||||
|
|
||||||
|
augroup END
|
||||||
|
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user