mirror of
https://github.com/Raimondi/delimitMate.git
synced 2025-12-06 20:54:31 +08:00
Compare commits
205 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fe1983cfa1 | ||
|
|
a4ac44a84f | ||
|
|
4c13ed6aee | ||
|
|
eafd832c04 | ||
|
|
e13872fdb2 | ||
|
|
9a9b9edb9a | ||
|
|
0f353bd2b3 | ||
|
|
c1b832bbf8 | ||
|
|
073957f0a1 | ||
|
|
c678061b79 | ||
|
|
12c7d85ff6 | ||
|
|
66834e7209 | ||
|
|
21072cf13e | ||
|
|
d952f6c721 | ||
|
|
0efe44bc70 | ||
|
|
631d72465a | ||
|
|
4024181af2 | ||
|
|
38487bbec8 | ||
|
|
c74a48ccd8 | ||
|
|
df1f32f772 | ||
|
|
f2b9b3a0c2 | ||
|
|
1c45f7bbde | ||
|
|
a1f21e8ef5 | ||
|
|
eba94168ce | ||
|
|
06c1f31632 | ||
|
|
9826c667e0 | ||
|
|
35280c1444 | ||
|
|
82160a5de6 | ||
|
|
07d9fa9ddc | ||
|
|
54853a954c | ||
|
|
f00f6b6cf2 | ||
|
|
d280d23a83 | ||
|
|
821e0019fb | ||
|
|
5ef40e0234 | ||
|
|
399e18d669 | ||
|
|
92fba35d27 | ||
|
|
0528bdac15 | ||
|
|
5db098e953 | ||
|
|
b45536fe8d | ||
|
|
3dde5cc8cb | ||
|
|
5787ec4f59 | ||
|
|
2dc880bf1c | ||
|
|
440f38858f | ||
|
|
f7f895c211 | ||
|
|
654dc14e6e | ||
|
|
543be33b13 | ||
|
|
7345bfddef | ||
|
|
16a35eefab | ||
|
|
74ab16ea5b | ||
|
|
2adbf5a8d7 | ||
|
|
e4a02eb998 | ||
|
|
ad11ab2210 | ||
|
|
6b0d448f6a | ||
|
|
32c9db8f37 | ||
|
|
a77423a46f | ||
|
|
57fd02b2e0 | ||
|
|
14faba1c62 | ||
|
|
8ab087c95c | ||
|
|
61d62e8920 | ||
|
|
7ce61655a7 | ||
|
|
8d133d4726 | ||
|
|
7caa6092b7 | ||
|
|
d98d8c0a0d | ||
|
|
e2d63e38f6 | ||
|
|
579e3520a4 | ||
|
|
90d07a68be | ||
|
|
2cb3f4d5e6 | ||
|
|
3a23e89cb5 | ||
|
|
70e1ac1462 | ||
|
|
d4ba528935 | ||
|
|
8a8aad183f | ||
|
|
cfc6654855 | ||
|
|
f2efe4331b | ||
|
|
dfa7e9b730 | ||
|
|
765bdd80dc | ||
|
|
739d2f9bd4 | ||
|
|
eb7738e4aa | ||
|
|
32f5d8df07 | ||
|
|
7b5887c324 | ||
|
|
0326b7c14a | ||
|
|
1dfe26a538 | ||
|
|
9c1564a22f | ||
|
|
028964cf7d | ||
|
|
5a84c1a746 | ||
|
|
0f9563969d | ||
|
|
d3ffebab74 | ||
|
|
ece6c39a65 | ||
|
|
ad151d3e55 | ||
|
|
b65d719353 | ||
|
|
a42dff4ad8 | ||
|
|
4a7d5a6e54 | ||
|
|
50a0df0be4 | ||
|
|
cecebf6e86 | ||
|
|
ad4430706e | ||
|
|
93d4a373fb | ||
|
|
a9f51531d9 | ||
|
|
6bb98110b4 | ||
|
|
0b34aea202 | ||
|
|
f1e92d05d5 | ||
|
|
8ec2bcb89a | ||
|
|
beb87ef41f | ||
|
|
26a6def62f | ||
|
|
0fb597ef36 | ||
|
|
fe5dd9a61a | ||
|
|
bb9b0edcc5 | ||
|
|
f3176a664c | ||
|
|
1cbbe90a09 | ||
|
|
a9174f65ba | ||
|
|
2af2dd2350 | ||
|
|
9c77b8434a | ||
|
|
646794cbda | ||
|
|
93fdcf92e1 | ||
|
|
fbbd9514c5 | ||
|
|
be5c41b3c1 | ||
|
|
b853ee9f35 | ||
|
|
eb2625c4a7 | ||
|
|
e17f6cd23c | ||
|
|
54acd56b48 | ||
|
|
9bdd4b078a | ||
|
|
f5748da36c | ||
|
|
eade67b409 | ||
|
|
b3f62f79c2 | ||
|
|
9d133d5b69 | ||
|
|
9f003b5bf5 | ||
|
|
e688e20151 | ||
|
|
8749708115 | ||
|
|
5cc5d8d9b3 | ||
|
|
98b4119746 | ||
|
|
c889905e47 | ||
|
|
db54dadb46 | ||
|
|
604260f56e | ||
|
|
581a3ebc17 | ||
|
|
cc1acaba96 | ||
|
|
7b781ab6b6 | ||
|
|
233eb52a97 | ||
|
|
aff9743269 | ||
|
|
ce1d05fac5 | ||
|
|
6dad313734 | ||
|
|
5263e25548 | ||
|
|
39b8298390 | ||
|
|
57b80ea78a | ||
|
|
a5b7141fc4 | ||
|
|
9efb01da68 | ||
|
|
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 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -6,3 +6,6 @@
|
|||||||
vimball.txt
|
vimball.txt
|
||||||
*.orig
|
*.orig
|
||||||
tags
|
tags
|
||||||
|
test/build
|
||||||
|
test/*.tap
|
||||||
|
test/*.msgout
|
||||||
|
|||||||
122
Makefile
122
Makefile
@@ -1,62 +1,82 @@
|
|||||||
PLUGIN=$(shell basename "$$PWD")
|
PLUGIN = $(wildcard plugin/*.vim)
|
||||||
SCRIPT=$(wildcard plugin/*.vim)
|
SOURCES = $(PLUGIN)
|
||||||
#AUTOL=$(wildcard autoload/*.vim)
|
LIB = $(wildcard autoload/*.vim)
|
||||||
AUTOL=autoload/$(PLUGIN).vim
|
SOURCES += $(LIB)
|
||||||
DOC=$(wildcard doc/*.txt)
|
DOC = $(wildcard doc/*.txt)
|
||||||
TESTS=$(wildcard autoload/*Tests.vim)
|
SOURCES += $(DOC)
|
||||||
VERSION=$(shell perl -ne 'if (/\*\sCurrent\srelease:/) {s/^\s+(\d+\.\S+)\s.*$$/\1/;print}' $(DOC))
|
#NAME = $(shell basename "$$PWD")
|
||||||
VIMFOLDER=~/.vim/
|
NAME = delimitMate
|
||||||
VIM=/usr/bin/vim
|
VERSION = $(shell $(SED) -n -e '/Current \+release/{s/^ \+\([0-9.]\+\).*/\1/;p;}' $(firstword $(DOC)))
|
||||||
|
FILENAME = $(NAME)-$(VERSION)
|
||||||
|
DESTDIR = $(HOME)/.vim
|
||||||
|
VIM = vim
|
||||||
|
SED = $(shell command -v gsed || command -v sed)
|
||||||
|
PERL = perl
|
||||||
|
comma := ,
|
||||||
|
empty :=
|
||||||
|
space := $(empty) $(empty)
|
||||||
|
|
||||||
.PHONY: $(PLUGIN).vba README
|
.PHONY: version clean distclean undo release test install uninstall
|
||||||
|
|
||||||
all: vimball README zip gzip
|
all: zip gzip
|
||||||
|
dist: version all
|
||||||
vimball: $(PLUGIN).vba
|
vimball: $(FILENAME).vmb
|
||||||
|
zip: $(FILENAME).zip $(FILENAME).vmb.zip
|
||||||
|
gzip: $(FILENAME).tar.gz $(FILENAME).vmb.gz
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@echo clean
|
rm -f */*.orig *.~* .VimballRecord *.zip *.gz *.vmb
|
||||||
rm -f *.vba */*.orig *.~* .VimballRecord *.zip *.gz
|
|
||||||
|
|
||||||
dist-clean: clean
|
distclean: clean
|
||||||
|
-zsh -c 'setopt extendedglob; rm -f ^(README.md|Makefile)'
|
||||||
|
-zsh -c 'setopt extendedglob; rm -f .^(git|README.md|Makefile)*'
|
||||||
|
|
||||||
undo:
|
undo:
|
||||||
for i in */*.orig; do mv -f "$$i" "$${i%.*}"; done
|
for i in */*.orig; do mv -f "$$i" "$${i%.*}"; done
|
||||||
|
|
||||||
README:
|
|
||||||
@echo README
|
|
||||||
cp -f $(DOC) README
|
|
||||||
|
|
||||||
$(PLUGIN).vba:
|
|
||||||
@echo $(PLUGIN).vba
|
|
||||||
rm -f $(PLUGIN)-$(VERSION).vba
|
|
||||||
$(VIM) -N -c 'ru! vimballPlugin.vim' -c ':call append("0", [ "$(SCRIPT)", "$(AUTOL)", "$(DOC)"])' -c '$$d' -c ":%MkVimball $(PLUGIN)-$(VERSION) ." -c':q!'
|
|
||||||
ln -f $(PLUGIN)-$(VERSION).vba $(PLUGIN).vba
|
|
||||||
|
|
||||||
zip:
|
|
||||||
@echo zip
|
|
||||||
rm -f *.zip
|
|
||||||
zip -r $(PLUGIN).zip doc plugin autoload
|
|
||||||
zip $(PLUGIN).zip -d \*.sw\? || echo 1
|
|
||||||
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
|
|
||||||
@echo vimball
|
|
||||||
gzip -f $(PLUGIN).vba
|
|
||||||
|
|
||||||
release: version all
|
|
||||||
|
|
||||||
version:
|
version:
|
||||||
@echo version: $(VERSION)
|
$(PERL) -i.orig -pne 'if (/^"\sVersion:/) {s/(\d+\.\S+)/$(VERSION)/}' $(PLUGIN) $(LIB)
|
||||||
perl -i.orig -pne 'if (/^"\sVersion:/) {s/(\d+\.\S+)/$(VERSION)/}' $(SCRIPT) $(AUTOL)
|
$(PERL) -i.orig -pne \
|
||||||
perl -i.orig -pne 'if (/let\sdelimitMate_version/) {s/"(\d+\.\S+)"/"$(VERSION)"/}' $(SCRIPT)
|
'if (/let\sdelimitMate_version/) {s/"(\d+\.\S+)"/"$(VERSION)"/}' $(PLUGIN)
|
||||||
perl -i.orig -pne 'if (/beasts/) {s/(v\d+\.\S+)/v$(VERSION)/}' $(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 \
|
||||||
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)
|
'if (/^"\sModified:/) {$$now_string = strftime "%F", localtime; s/(\d+-\d+-\d+)/$$now_string/e}' \
|
||||||
@echo Version: $(VERSION)
|
$(PLUGIN) $(LIB)
|
||||||
|
$(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:
|
test:
|
||||||
|
$(MAKE) -C test
|
||||||
|
|
||||||
|
install: $(SOURCES)
|
||||||
|
for dir in $(^D);\
|
||||||
|
do install -d -m 0755 $(DESTDIR)$(PREFIX)/$$dir;\
|
||||||
|
done;\
|
||||||
|
for file in $^;\
|
||||||
|
do install -m 0644 $$file $(DESTDIR)$(PREFIX)/$$file;\
|
||||||
|
done;
|
||||||
|
|
||||||
|
uninstall:
|
||||||
|
for file in $(SOURCES);\
|
||||||
|
do rm -f $(DESTDIR)$(PREFIX)/$$file;\
|
||||||
|
done;
|
||||||
|
|
||||||
|
%.vmb: $(SOURCES)
|
||||||
|
$(VIM) -N -es -u NORC \
|
||||||
|
-c 'call setline(1,["$(subst $(space),"$(comma)",$^)"])'\
|
||||||
|
-c "%MkVimball! $(basename $@) ." -c 'q!'
|
||||||
|
|
||||||
|
%.vmb.zip: vimball
|
||||||
|
zip $@ $(basename $@)
|
||||||
|
|
||||||
|
%.zip: $(SOURCES)
|
||||||
|
zip $@ $^
|
||||||
|
|
||||||
|
%.vmb.gz: vimball
|
||||||
|
gzip -f $(basename $@)
|
||||||
|
|
||||||
|
%.tar.gz: $(SOURCES)
|
||||||
|
tar -cvzf $@ $^
|
||||||
|
|
||||||
|
# vim:ts=2:sw=2
|
||||||
|
|||||||
746
README
746
README
@@ -1,746 +0,0 @@
|
|||||||
*delimitMate* Trying to keep those beasts at bay! v2.4.1 *delimitMate.txt*
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
==============================================================================
|
|
||||||
0.- CONTENTS *delimitMate-contents*
|
|
||||||
|
|
||||||
1. Introduction____________________________|delimitMateIntro|
|
|
||||||
2. Functionality___________________________|delimitMateFunctionality|
|
|
||||||
2.1 Automatic closing & exiting________|delimitMateAutoClose|
|
|
||||||
2.2 Expansion of space and CR__________|delimitMateExpansion|
|
|
||||||
2.3 Backspace__________________________|delimitMateBackspace|
|
|
||||||
2.4 Visual wrapping____________________|delimitMateVisualWrapping|
|
|
||||||
2.5 Smart Quotes_______________________|delimitMateSmartQuotes|
|
|
||||||
2.6 Balancing matching pairs___________|delimitMateBalance|
|
|
||||||
2.7 FileType based configuration_______|delimitMateFileType|
|
|
||||||
2.8 Syntax awareness___________________|delimitMateSyntax|
|
|
||||||
3. Customization___________________________|delimitMateOptions|
|
|
||||||
3.1 Options summary____________________|delimitMateOptionSummary|
|
|
||||||
3.2 Options details____________________|delimitMateOptionDetails|
|
|
||||||
4. Commands________________________________|delimitMateCommands|
|
|
||||||
5. Functions_______________________________|delimitMateFunctions|
|
|
||||||
6. TODO list_______________________________|delimitMateTodo|
|
|
||||||
7. Maintainer______________________________|delimitMateMaintainer|
|
|
||||||
8. Credits_________________________________|delimitMateCredits|
|
|
||||||
9. History_________________________________|delimitMateHistory|
|
|
||||||
|
|
||||||
==============================================================================
|
|
||||||
1.- INTRODUCTION *delimitMateIntro*
|
|
||||||
|
|
||||||
This plug-in provides automatic closing of quotes, parenthesis, brackets,
|
|
||||||
etc.; besides some other related features that should make your time in insert
|
|
||||||
mode a little bit easier.
|
|
||||||
|
|
||||||
Most of the features can be modified or disabled permanently, using global
|
|
||||||
variables, or on a FileType basis, using autocommands. With a couple of
|
|
||||||
exceptions and limitations, this features don't brake undo, redo or history.
|
|
||||||
|
|
||||||
==============================================================================
|
|
||||||
2. FUNCTIONALITY *delimitMateFunctionality*
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
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> | ()|
|
|
||||||
<
|
|
||||||
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*
|
|
||||||
|
|
||||||
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 <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(|
|
|
||||||
<
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
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 well
|
|
||||||
on blockwise visual mode when the selection has lines one character smaller
|
|
||||||
than the rest, any suggestions to fix this will be very 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, following or
|
|
||||||
preceding an alphanumeric 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
|
|
||||||
=======================================
|
|
||||||
" | "String| | "String"|
|
|
||||||
" | let i = "| | let i = "|"
|
|
||||||
' | I| | I'|
|
|
||||||
<
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
2.6 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
|
|
||||||
=======================================
|
|
||||||
( | |) | (|)
|
|
||||||
( | | | (|)
|
|
||||||
( | (|) | ((|))
|
|
||||||
<
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
2.7 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.
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
2.8 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.
|
|
||||||
|
|
||||||
==============================================================================
|
|
||||||
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*
|
|
||||||
|
|
||||||
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_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_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.
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
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 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_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 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 = ""
|
|
||||||
<
|
|
||||||
==============================================================================
|
|
||||||
4. COMMANDS *delimitMateCommands*
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
:DelimitMateReload *:DelimitMateReload*
|
|
||||||
|
|
||||||
Re-sets all the mappings used for this script, use it if any option has been
|
|
||||||
changed or if the filetype option hasn't been set yet.
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
:DelimitMateSwitch *:DelimitMateSwitch*
|
|
||||||
|
|
||||||
Switches the plug-in on and off.
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
:DelimitMateTest *:DelimitMateTest*
|
|
||||||
|
|
||||||
This command tests every mapping set-up for this script, useful for testing
|
|
||||||
custom configurations.
|
|
||||||
|
|
||||||
The following output corresponds to the default values, it will be different
|
|
||||||
depending on your configuration. "Open & close:" represents the final result
|
|
||||||
when the closing delimiter has been inserted, either manually or
|
|
||||||
automatically, see |delimitMateExpansion|. "Delete:" typing backspace in an
|
|
||||||
empty pair, see |delimitMateBackspace|. "Exit:" typing a closing delimiter
|
|
||||||
inside a pair of delimiters, see |delimitMateAutoclose|. "Space:" the
|
|
||||||
expansion, if any, of space, see |delimitMateExpansion|. "Visual-L",
|
|
||||||
"Visual-R" and "Visual" shows visual wrapping, see
|
|
||||||
|delimitMateVisualWrapping|. "Car return:" the expansion of car return, see
|
|
||||||
|delimitMateExpansion|. The cursor's position at the end of every test is
|
|
||||||
represented by an "|": >
|
|
||||||
|
|
||||||
* AUTOCLOSE:
|
|
||||||
Open & close: (|)
|
|
||||||
Delete: |
|
|
||||||
Exit: ()|
|
|
||||||
Space: ( |)
|
|
||||||
Visual-L: (v)
|
|
||||||
Visual-R: (v)
|
|
||||||
Car return: (
|
|
||||||
|)
|
|
||||||
|
|
||||||
Open & close: {|}
|
|
||||||
Delete: |
|
|
||||||
Exit: {}|
|
|
||||||
Space: { |}
|
|
||||||
Visual-L: {v}
|
|
||||||
Visual-R: {v}
|
|
||||||
Car return: {
|
|
||||||
|}
|
|
||||||
|
|
||||||
Open & close: [|]
|
|
||||||
Delete: |
|
|
||||||
Exit: []|
|
|
||||||
Space: [ |]
|
|
||||||
Visual-L: [v]
|
|
||||||
Visual-R: [v]
|
|
||||||
Car return: [
|
|
||||||
|]
|
|
||||||
|
|
||||||
Open & close: "|"
|
|
||||||
Delete: |
|
|
||||||
Exit: ""|
|
|
||||||
Space: " |"
|
|
||||||
Visual: "v"
|
|
||||||
Car return: "
|
|
||||||
|"
|
|
||||||
|
|
||||||
Open & close: '|'
|
|
||||||
Delete: |
|
|
||||||
Exit: ''|
|
|
||||||
Space: ' |'
|
|
||||||
Visual: 'v'
|
|
||||||
Car return: '
|
|
||||||
|'
|
|
||||||
|
|
||||||
Open & close: `|`
|
|
||||||
Delete: |
|
|
||||||
Exit: ``|
|
|
||||||
Space: ` |`
|
|
||||||
Visual: `v`
|
|
||||||
Car return: `
|
|
||||||
|`
|
|
||||||
<
|
|
||||||
|
|
||||||
==============================================================================
|
|
||||||
5. FUNCTIONS *delimitMateFunctions*
|
|
||||||
|
|
||||||
Functions should be used enclosed between <C-R>= and <CR>, otherwise they
|
|
||||||
might not work as expected or at all.
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
delimitMate#WithinEmptyPair() *delimitMate_WithinEmptyPair()*
|
|
||||||
|
|
||||||
Returns 1 if the cursor is inside an empty pair, 0 otherwise.
|
|
||||||
e.g.: >
|
|
||||||
|
|
||||||
inoremap <expr> <CR> delimitMate#WithinEmptyPair() ?
|
|
||||||
\ "\<C-R>=delimitMate#ExpandReturn()\<CR>" :
|
|
||||||
\ "external_mapping"
|
|
||||||
<
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
delimitMate#ExpandReturn() *delimitMate#ExpandReturn()*
|
|
||||||
|
|
||||||
Returns the expansion for <CR> if enabled and inside an empty pair, returns
|
|
||||||
<CR> otherwise.
|
|
||||||
|
|
||||||
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>" :
|
|
||||||
\ "\<C-R>=delimitMate#ExpandReturn()\<CR>"
|
|
||||||
<
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
delimitMate#ExpandSpace() *delimitMate#ExpandSpace()*
|
|
||||||
|
|
||||||
Returns the expansion for <Space> if enabled and inside an empty pair, returns
|
|
||||||
<Space> otherwise.
|
|
||||||
e.g.: >
|
|
||||||
|
|
||||||
inoremap <Space> <C-R>=delimitMate#ExpandSpace()<CR>
|
|
||||||
<
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
delimitMate#ShouldJump() *delimitMate#ShouldJump()*
|
|
||||||
|
|
||||||
Returns 1 if there is a closing delimiter or a quote to the right of the
|
|
||||||
cursor, 0 otherwise.
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
delimitMate#JumpAny(key) *delimitMate#JumpAny()*
|
|
||||||
|
|
||||||
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.
|
|
||||||
>
|
|
||||||
inoremap <C-Tab> <C-R>=delimitMate#JumpAny("\<C-Tab>")<CR>
|
|
||||||
<
|
|
||||||
|
|
||||||
==============================================================================
|
|
||||||
6. TODO LIST *delimitMateTodo*
|
|
||||||
|
|
||||||
- Automatic set-up by file type.
|
|
||||||
- Make block-wise visual wrapping work on un-even regions.
|
|
||||||
|
|
||||||
==============================================================================
|
|
||||||
7. MAINTAINER *delimitMateMaintainer*
|
|
||||||
|
|
||||||
Hi there! My name is Israel Chauca F. and I can be reached at:
|
|
||||||
mailto:israelchauca@gmail.com
|
|
||||||
|
|
||||||
Feel free to send me any suggestions and/or comments about this plugin, I'll
|
|
||||||
be very pleased to read them.
|
|
||||||
|
|
||||||
==============================================================================
|
|
||||||
8. CREDITS *delimitMateCredits*
|
|
||||||
|
|
||||||
Some of the code that make this script is modified or just shamelessly copied
|
|
||||||
from the following sources:
|
|
||||||
|
|
||||||
- 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*
|
|
||||||
|
|
||||||
Version Date Release notes ~
|
|
||||||
|---------|------------|-----------------------------------------------------|
|
|
||||||
2.4.1 2010-07-31 * Current release:
|
|
||||||
- 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: A small problem when inserting a delimiter at
|
|
||||||
the beginning of the line.
|
|
||||||
|
|
||||||
|---------|------------|-----------------------------------------------------|
|
|
||||||
2.1 2010-05-10 * - Most of the functions have been moved to an
|
|
||||||
autoload script to avoid loading unnecessary ones.
|
|
||||||
- Fixed a problem with the redo command.
|
|
||||||
- Many small fixes.
|
|
||||||
|
|
||||||
|---------|------------|-----------------------------------------------------|
|
|
||||||
2.0 2010-04-01 * New features:
|
|
||||||
- All features are redo/undo-wise safe.
|
|
||||||
- A single quote typed after an alphanumeric
|
|
||||||
character is considered an apostrophe and one
|
|
||||||
single quote is inserted.
|
|
||||||
- A quote typed after another quote inserts a single
|
|
||||||
quote and the cursor jumps to the middle.
|
|
||||||
- <S-Tab> jumps out of any empty pair.
|
|
||||||
- <CR> and <Space> expansions are fixed, but the
|
|
||||||
functions used for it are global and can be used in
|
|
||||||
custom mappings. The previous system is still
|
|
||||||
active if you have any of the expansion options
|
|
||||||
set.
|
|
||||||
- <S-Backspace> deletes the closing delimiter.
|
|
||||||
* Fixed bug:
|
|
||||||
- s:vars were being used to store buffer options.
|
|
||||||
|
|
||||||
|---------|------------|-----------------------------------------------------|
|
|
||||||
1.6 2009-10-10 * Now delimitMate tries to fix the balancing of single
|
|
||||||
quotes when used as apostrophes. You can read
|
|
||||||
|delimitMate_apostrophes| for details.
|
|
||||||
Fixed an error when |b:delimitMate_expand_space|
|
|
||||||
wasn't set but |delimitMate_expand_space| wasn't.
|
|
||||||
|
|
||||||
|---------|------------|-----------------------------------------------------|
|
|
||||||
1.5 2009-10-05 * Fix: delimitMate should work correctly for files
|
|
||||||
passed as arguments to Vim. Thanks to Ben Beuchler
|
|
||||||
for helping to nail this bug.
|
|
||||||
|
|
||||||
|---------|------------|-----------------------------------------------------|
|
|
||||||
1.4 2009-09-27 * Fix: delimitMate is now enabled on new buffers even
|
|
||||||
if they don't have set the file type option or were
|
|
||||||
opened directly from the terminal.
|
|
||||||
|
|
||||||
|---------|------------|-----------------------------------------------------|
|
|
||||||
1.3 2009-09-24 * Now local options can be used along with autocmd
|
|
||||||
for specific file type configurations.
|
|
||||||
Fixes:
|
|
||||||
- Unnamed register content is not lost on visual
|
|
||||||
mode.
|
|
||||||
- Use noremap where appropiate.
|
|
||||||
- Wrapping a single empty line works as expected.
|
|
||||||
|
|
||||||
|---------|------------|-----------------------------------------------------|
|
|
||||||
1.2 2009-09-07 * Fixes:
|
|
||||||
- When inside nested empty pairs, deleting the
|
|
||||||
innermost left delimiter would delete all right
|
|
||||||
contiguous delimiters.
|
|
||||||
- When inside an empty pair, inserting a left
|
|
||||||
delimiter wouldn't insert the right one, instead
|
|
||||||
the cursor would jump to the right.
|
|
||||||
- New buffer inside the current window wouldn't
|
|
||||||
have the mappings set.
|
|
||||||
|
|
||||||
|---------|------------|-----------------------------------------------------|
|
|
||||||
1.1 2009-08-25 * Fixed an error that ocurred when mapleader wasn't
|
|
||||||
set and added support for GetLatestScripts
|
|
||||||
auto-detection.
|
|
||||||
|
|
||||||
|---------|------------|-----------------------------------------------------|
|
|
||||||
1.0 2009-08-23 * Initial upload.
|
|
||||||
|
|
||||||
|---------|------------|-----------------------------------------------------|
|
|
||||||
|
|
||||||
|
|
||||||
`\|||/´ MMM \|/ www __^__ ~
|
|
||||||
(o o) (o o) @ @ (O-O) /(o o)\\ ~
|
|
||||||
ooO_(_)_Ooo__ ooO_(_)_Ooo___oOO_(_)_OOo___oOO__(_)__OOo___oOO__(_)__OOo_____ ~
|
|
||||||
_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|____ ~
|
|
||||||
__|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_ ~
|
|
||||||
_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|____ ~
|
|
||||||
|
|
||||||
vim:tw=78:et:ts=2:sw=2:ft=help:norl:formatoptions+=tcroqn:autoindent:
|
|
||||||
6
README.md
Normal file
6
README.md
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
This plug-in provides automatic closing of quotes, parenthesis, brackets, etc., besides some other related features that
|
||||||
|
should make your time in insert mode a little bit easier, like syntax awareness (will not insert the closing delimiter
|
||||||
|
in comments and other configurable regions), <CR> and <Space> expansions (off by default), and some more.
|
||||||
|
|
||||||
|
Most of the features can be modified or disabled permanently, using global variables, or on a FileType basis, using
|
||||||
|
:autocmd.
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,281 +0,0 @@
|
|||||||
function! delimitMateTests#Main()
|
|
||||||
if !exists("g:delimitMate_testing")
|
|
||||||
echoerr "delimitMateTests#Main(): If you really want to use me, you must set delimitMate_testing to any value."
|
|
||||||
return
|
|
||||||
elseif g:delimitMate_testing == "fork"
|
|
||||||
!gvim -N -u NONE -U NONE -c "set backspace=eol,start" -c "set background=light" -c "syntax on" -c "let delimitMate_testing = 1" -c "so autoload/delimitMate.vim" -c "so autoload/delimitMateTests.vim" -c "so plugin/delimitMate.vim" -c "call delimitMateTests\#Main()"
|
|
||||||
return ""
|
|
||||||
endif
|
|
||||||
nmap <F1> :qall!<CR>
|
|
||||||
let nomore = &more
|
|
||||||
set nomore
|
|
||||||
let b:test_results = {}
|
|
||||||
let b:errors = 0
|
|
||||||
let b:corrects = 0
|
|
||||||
let b:ignores = 0
|
|
||||||
|
|
||||||
function! SetOptions(list) " {{{
|
|
||||||
let b:delimitMate_autoclose = 1
|
|
||||||
let b:delimitMate_matchpairs = &matchpairs
|
|
||||||
let b:delimitMate_quotes = "\" ' `"
|
|
||||||
let b:delimitMate_excluded_regions = "Comment"
|
|
||||||
silent! unlet b:delimitMate_visual_leader
|
|
||||||
let b:delimitMate_expand_space = 0
|
|
||||||
let b:delimitMate_expand_cr = 0
|
|
||||||
let b:delimitMate_smart_quotes = 1
|
|
||||||
let b:delimitMate_apostrophes = ""
|
|
||||||
let b:delimitMate_tab2exit = 1
|
|
||||||
" Set current test options:
|
|
||||||
for str in a:list
|
|
||||||
let pair = split(str, ':')
|
|
||||||
exec "let b:delimitMate_" . pair[0] . " = " . pair[1]
|
|
||||||
endfor
|
|
||||||
DelimitMateReload
|
|
||||||
endfunction " }}}
|
|
||||||
|
|
||||||
function! Type(name, input, output, options, ...) " {{{
|
|
||||||
if a:0 > 0
|
|
||||||
let ignore = a:1
|
|
||||||
else
|
|
||||||
let ignore = 0
|
|
||||||
endif
|
|
||||||
if a:input != "\<Esc>."
|
|
||||||
" Set default options:
|
|
||||||
call SetOptions(a:options)
|
|
||||||
let CapR = ""
|
|
||||||
normal ggVG"_d
|
|
||||||
exec "normal i" . a:input . "|\<Esc>"
|
|
||||||
else
|
|
||||||
let CapR = "_R"
|
|
||||||
normal gg.
|
|
||||||
endif
|
|
||||||
|
|
||||||
exec "normal \<Esc>"
|
|
||||||
call setpos('.', [0, 1, 1, 0])
|
|
||||||
let result = len(a:output) != line('$')
|
|
||||||
for line in a:output
|
|
||||||
if getline('.') != line || result == 1
|
|
||||||
let result = 1
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
call setpos('.', [0, line('.') + 1, 1, 0])
|
|
||||||
endfor
|
|
||||||
let text = getline('.')
|
|
||||||
let i = 2
|
|
||||||
while i <= line('$')
|
|
||||||
let text = text . "<cr>" . getline(i)
|
|
||||||
let i += 1
|
|
||||||
endwhile
|
|
||||||
if ignore == 1
|
|
||||||
let label = "Ignored"
|
|
||||||
let result = "?="
|
|
||||||
let b:ignores += 1
|
|
||||||
elseif result == 0
|
|
||||||
let label = "Passed"
|
|
||||||
let result = "=="
|
|
||||||
let b:corrects += 1
|
|
||||||
else
|
|
||||||
let label = "Failed"
|
|
||||||
let result = "!="
|
|
||||||
let b:errors += 1
|
|
||||||
endif
|
|
||||||
exec "let b:test_results['" .
|
|
||||||
\ substitute(a:name, "[^a-zA-Z0-9_]", "_", "g") . CapR . "'] = '" .
|
|
||||||
\ label . ": ' . a:input . ' => ' . text . ' " .
|
|
||||||
\ result . " ' . join(a:output, '<cr>')"
|
|
||||||
endfunction " }}}
|
|
||||||
|
|
||||||
function! RepeatLast(name, output, ...) " {{{
|
|
||||||
if a:0 > 0
|
|
||||||
let arg1 = a:1
|
|
||||||
else
|
|
||||||
let arg1 = ''
|
|
||||||
endif
|
|
||||||
call Type(a:name, "\<Esc>.", a:output, [], arg1)
|
|
||||||
endfunction " }}}
|
|
||||||
|
|
||||||
" Test's test {{{
|
|
||||||
call Type("Test 1", "123", ["123|"], [])
|
|
||||||
call RepeatLast("Test 1", ["123|123|"])
|
|
||||||
|
|
||||||
" Auto-closing parens
|
|
||||||
call Type("Autoclose parens", "(", ["(|)"], [])
|
|
||||||
call RepeatLast("Autoclose_parens", ["(|)(|)"])
|
|
||||||
|
|
||||||
" Auto-closing quotes
|
|
||||||
call Type("Autoclose quotes", '"', ['"|"'], [])
|
|
||||||
call RepeatLast("Autoclose_quotes", ['"|""|"'])
|
|
||||||
|
|
||||||
" Deleting parens
|
|
||||||
call Type("Delete empty parens", "(\<BS>", ["|"], [])
|
|
||||||
call RepeatLast("Delete empty parens", ["||"])
|
|
||||||
|
|
||||||
" Deleting quotes
|
|
||||||
call Type("Delete emtpy quotes", "\"\<BS>", ['|'], [])
|
|
||||||
call RepeatLast("Delete empty quotes", ["||"])
|
|
||||||
|
|
||||||
" Manual closing parens
|
|
||||||
call Type("Manual closing parens", "()", ["(|)"], ["autoclose:0"])
|
|
||||||
call RepeatLast("Manual closing parens", ["(|)(|)"])
|
|
||||||
|
|
||||||
" Manual closing quotes
|
|
||||||
call Type("Manual closing quotes", "\"\"", ['"|"'], ["autoclose:0"])
|
|
||||||
call RepeatLast("Manual closing quotes", ['"|""|"'])
|
|
||||||
|
|
||||||
" Jump over paren
|
|
||||||
call Type("Jump over paren", "()", ['()|'], [])
|
|
||||||
call RepeatLast("Jump over paren", ['()|()|'])
|
|
||||||
|
|
||||||
" Jump over quote
|
|
||||||
call Type("Jump over quote", "\"\"", ['""|'], [])
|
|
||||||
call RepeatLast("Jump over quote", ['""|""|'])
|
|
||||||
|
|
||||||
" Apostrophe
|
|
||||||
call Type("Apostrophe", "test'", ["test'|"], [])
|
|
||||||
call RepeatLast("Apostrophe", ["test'|test'|"])
|
|
||||||
|
|
||||||
" Close quote
|
|
||||||
call Type("Close quote", "'\<Del>\<Esc>a'", ["'|'"], [])
|
|
||||||
|
|
||||||
" Closing paren
|
|
||||||
call Type("Closing paren", "abcd)", ["abcd)|"], [])
|
|
||||||
|
|
||||||
" <S-Tab>
|
|
||||||
call Type("S Tab", "(\<S-Tab>", ["()|"], [])
|
|
||||||
call RepeatLast("S Tab", ["()|()|"])
|
|
||||||
|
|
||||||
" Space expansion
|
|
||||||
call Type("Space expansion", "(\<Space>\<BS>", ['(|)'], ['expand_space:1'])
|
|
||||||
call RepeatLast("BS with space expansion", ['(|)(|)'])
|
|
||||||
|
|
||||||
" BS with space expansion
|
|
||||||
call Type("BS with space expansion", "(\<Space>", ['( | )'], ['expand_space:1'])
|
|
||||||
call RepeatLast("Space expansion", ['( | )( | )'])
|
|
||||||
|
|
||||||
" Car return expansion
|
|
||||||
call Type("CR expansion", "(\<CR>", ['(', '|', ')'], ['expand_cr:1'])
|
|
||||||
call RepeatLast("CR expansion", ['(', '|', ')(', '|', ')'], 1)
|
|
||||||
|
|
||||||
" BS with car return expansion
|
|
||||||
call Type("BS with CR expansion", "(\<CR>\<BS>", ['(|)'], ['expand_cr: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
|
|
||||||
call Type("Smart quote alphanumeric", "a\"4", ['a"4|'], [])
|
|
||||||
call RepeatLast("Smart quote alphanumeric", ['a"4|a"4|'])
|
|
||||||
|
|
||||||
" Smart quotes
|
|
||||||
call Type("Smart quote escaped", "esc\\\"", ['esc\"|'], [])
|
|
||||||
call RepeatLast("Smart quote escaped", ['esc\"|esc\"|'])
|
|
||||||
|
|
||||||
" Smart quotes
|
|
||||||
call Type("Smart quote apostrophe", "I'm", ["I'm|"], ['smart_quotes:0'])
|
|
||||||
call RepeatLast("Smart quote escaped", ["I'm|I'm|"])
|
|
||||||
|
|
||||||
" Backspace inside space expansion
|
|
||||||
call Type("Backspace inside space expansion", "(\<Space>\<BS>", ['(|)'], ['expand_space:1'])
|
|
||||||
call RepeatLast("Backspace inside space expansion", ['(|)(|)'])
|
|
||||||
|
|
||||||
" <Right-arrow> inserts text
|
|
||||||
call Type("<Right-arrow> inserts text", "(he\<Right>\<Space>th\<Right>\<Right>", ['(he) th|'], [])
|
|
||||||
|
|
||||||
" Backspace inside CR expansion
|
|
||||||
call Type("Backspace inside CR expansion", "(\<CR>\<BS>", ['(|)'], ['expand_cr:1'])
|
|
||||||
call RepeatLast("Backspace inside CR expansion", ['(|)(|)'], 1)
|
|
||||||
|
|
||||||
" FileType event
|
|
||||||
let g:delimitMate_excluded_ft = "vim"
|
|
||||||
set ft=vim
|
|
||||||
call Type("FileType Autoclose parens", "(", ["(|"], [])
|
|
||||||
unlet g:delimitMate_excluded_ft
|
|
||||||
set ft=
|
|
||||||
|
|
||||||
" Duplicated delimiter after CR
|
|
||||||
call Type("Duplicated delimiter after CR", "(\<CR>", ['(', '|)'], [])
|
|
||||||
|
|
||||||
" Deactivate on comments: The first call to a closing delimiter
|
|
||||||
" will not work here as expected, but it does in real life tests.
|
|
||||||
set ft=vim
|
|
||||||
call Type("Deactivate on comments", "\"()``[]''\"\"", ["\"()``[]''\"\"|"], ["autoclose:0"], 1)
|
|
||||||
set ft=
|
|
||||||
|
|
||||||
" Deactivate parens on comments: The first call to a closing delimiter
|
|
||||||
" will not work here as expected, but it does in real life tests.
|
|
||||||
set ft=vim
|
|
||||||
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=
|
|
||||||
|
|
||||||
" Manual close at start of line
|
|
||||||
call Type("Manual close at start of line", "m)\<Left>\<Left>)", [')|m)'], ["autoclose:0"])
|
|
||||||
|
|
||||||
"}}}
|
|
||||||
|
|
||||||
" Show results: {{{
|
|
||||||
normal ggVG"_d
|
|
||||||
call append(0, split(string(b:test_results)[1:-2], ', '))
|
|
||||||
call append(0, "*TESTS REPORT: " . b:errors . " failed, " . b:corrects . " passed and " . b:ignores . " ignored.")
|
|
||||||
normal "_ddgg
|
|
||||||
let @/ = ".\\+Failed:.*!="
|
|
||||||
2,$sort /^.\+':/
|
|
||||||
normal gg
|
|
||||||
exec search('Ignored:','nW').",$sort! /^.\\+':/"
|
|
||||||
set nohlsearch
|
|
||||||
syn match lineIgnored ".*Ignored.*"
|
|
||||||
syn match labelPassed "'\@<=.\+\(': 'Passed\)\@="
|
|
||||||
syn match labelFailed "'\@<=.\+\(': 'Failed\)\@="
|
|
||||||
syn match resultPassed "\('Passed: \)\@<=.\+\('$\)\@="
|
|
||||||
syn match resultFailed "\('Failed: \)\@<=.\+\('$\)\@=" contains=resultInequal
|
|
||||||
syn match resultIgnored "\('Ignored: \)\@<=.\+\('$\)\@="
|
|
||||||
syn match resultInequal "!="
|
|
||||||
syn match resultSummary "^\*.\+" contains=resultSummaryNumber
|
|
||||||
syn match resultSummaryNumber "[1-9][0-9]* failed*" contained
|
|
||||||
|
|
||||||
hi def link lineIgnored Ignore
|
|
||||||
hi def link labelPassed Comment
|
|
||||||
hi def link labelFailed Special
|
|
||||||
hi def link resultPassed Ignore
|
|
||||||
hi def link resultFailed Boolean
|
|
||||||
hi def link resultInequal Error
|
|
||||||
hi def link resultSummary SpecialComment
|
|
||||||
hi def link resultSummaryNumber Error
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
let &more = nomore
|
|
||||||
endfunction
|
|
||||||
" vim:foldmethod=marker:foldcolumn=4
|
|
||||||
|
|
||||||
4
basic_vimrc
Normal file
4
basic_vimrc
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
so ./test/_setup.vim
|
||||||
|
let delimitMate_expand_cr = 1
|
||||||
|
filetype indent plugin on
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
*delimitMate* Trying to keep those beasts at bay! v2.4.1 *delimitMate.txt*
|
*delimitMate.txt* Trying to keep those beasts at bay! v2.7 *delimitMate*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -20,24 +20,24 @@
|
|||||||
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 Balancing matching pairs___________|delimitMateBalance|
|
3.3 Backspace__________________________|delimitMateBackspace|
|
||||||
2.7 FileType based configuration_______|delimitMateFileType|
|
3.4 Smart Quotes_______________________|delimitMateSmartQuotes|
|
||||||
2.8 Syntax awareness___________________|delimitMateSyntax|
|
3.5 Balancing matching pairs___________|delimitMateBalance|
|
||||||
3. Customization___________________________|delimitMateOptions|
|
3.6 FileType based configuration_______|delimitMateFileType|
|
||||||
3.1 Options summary____________________|delimitMateOptionSummary|
|
3.7 Syntax awareness___________________|delimitMateSyntax|
|
||||||
3.2 Options details____________________|delimitMateOptionDetails|
|
|
||||||
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*
|
||||||
@@ -47,198 +47,23 @@ 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.
|
||||||
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: Abbreviations 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> | ()|
|
|
||||||
<
|
|
||||||
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*
|
|
||||||
|
|
||||||
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 <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(|
|
|
||||||
<
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
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 well
|
|
||||||
on blockwise visual mode when the selection has lines one character smaller
|
|
||||||
than the rest, any suggestions to fix this will be very 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, following or
|
|
||||||
preceding an alphanumeric 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
|
|
||||||
=======================================
|
|
||||||
" | "String| | "String"|
|
|
||||||
" | let i = "| | let i = "|"
|
|
||||||
' | I| | I'|
|
|
||||||
<
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
2.6 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
|
|
||||||
=======================================
|
|
||||||
( | |) | (|)
|
|
||||||
( | | | (|)
|
|
||||||
( | (|) | ((|))
|
|
||||||
<
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
2.7 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.
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
2.8 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.
|
|
||||||
|
|
||||||
==============================================================================
|
|
||||||
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
|
||||||
@@ -258,14 +83,16 @@ specific file types, see |delimitMateOptionDetails| for examples.
|
|||||||
|'delimitMate_nesting_quotes'| Tells delimitMate which quotes should be
|
|'delimitMate_nesting_quotes'| Tells delimitMate which quotes should be
|
||||||
allowed to be nested.
|
allowed to be nested.
|
||||||
|
|
||||||
|'delimitMate_visual_leader'| Sets the leader to be used in visual mode.
|
|
||||||
|
|
||||||
|'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_jump_expansion'| Turns on/off jumping over expansions.
|
||||||
|
|
||||||
|'delimitMate_smart_quotes'| Turns on/off the "smart quotes" feature.
|
|'delimitMate_smart_quotes'| Turns on/off the "smart quotes" feature.
|
||||||
|
|
||||||
|
|'delimitMate_smart_matchpairs'| Turns on/off the "smart matchpairs" feature.
|
||||||
|
|
||||||
|'delimitMate_balance_matchpairs'|Turns on/off the "balance matching pairs"
|
|'delimitMate_balance_matchpairs'|Turns on/off the "balance matching pairs"
|
||||||
feature.
|
feature.
|
||||||
|
|
||||||
@@ -274,13 +101,17 @@ specific file types, see |delimitMateOptionDetails| for examples.
|
|||||||
|
|
||||||
|'delimitMate_excluded_ft'| Turns off the script for the given file types.
|
|'delimitMate_excluded_ft'| Turns off the script for the given file types.
|
||||||
|
|
||||||
|
|'delimitMate_eol_marker'| Determines what to insert after the closing
|
||||||
|
matchpair when typing an opening matchpair on
|
||||||
|
the end of the line.
|
||||||
|
|
||||||
|'delimitMate_apostrophes'| Tells delimitMate how it should "fix"
|
|'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.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
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
|
||||||
@@ -288,7 +119,7 @@ autocmd to modify delimitMate's behavior for specific file types, read more in
|
|||||||
|delimitMateFileType|.
|
|delimitMateFileType|.
|
||||||
|
|
||||||
Note: Use buffer variables only to set options for specific file types using
|
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
|
:autocmd, use global variables to set options for all buffers. Read more in
|
||||||
|g:var| and |b:var|.
|
|g:var| and |b:var|.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
@@ -299,6 +130,15 @@ e.g.: >
|
|||||||
let loaded_delimitMate = 1
|
let loaded_delimitMate = 1
|
||||||
au FileType mail let b:loaded_delimitMate = 1
|
au FileType mail let b:loaded_delimitMate = 1
|
||||||
<
|
<
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
*'delimitMate_offByDefault'*
|
||||||
|
Values: 0 or 1.~
|
||||||
|
Default: 0~
|
||||||
|
|
||||||
|
If this option is set to 1, delimitMate will load, but will not take
|
||||||
|
effect in any buffer unless |:DelimitMateSwitch| is called in that
|
||||||
|
buffer.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*'delimitMate_autoclose'*
|
*'delimitMate_autoclose'*
|
||||||
*'b:delimitMate_autoclose'*
|
*'b:delimitMate_autoclose'*
|
||||||
@@ -314,7 +154,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
|
||||||
@@ -341,32 +182,23 @@ e.g.: >
|
|||||||
Values: A list of quotes. ~
|
Values: A list of quotes. ~
|
||||||
Default: [] ~
|
Default: [] ~
|
||||||
|
|
||||||
Quotes listed here will not be able to jump out of the empty pair, thus
|
When adding a third quote listed in this option is inserted, three quotes will
|
||||||
allowing the autoclosed quotes to be nested.
|
be inserted to the right of the cursor and the cursor will stay in the middle.
|
||||||
|
If more quotes are inserted the number of quotes on both sides of the cursor
|
||||||
|
will stay balanced.
|
||||||
e.g.: >
|
e.g.: >
|
||||||
let delimitMate_nesting_quotes = ['"','`']
|
let delimitMate_nesting_quotes = ['"','`']
|
||||||
au FileType python let b:delimitMate_nesting_quotes = ['"']
|
au FileType python let b:delimitMate_nesting_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'*
|
*'delimitMate_expand_cr'*
|
||||||
*'b:delimitMate_expand_cr'*
|
*'b:delimitMate_expand_cr'*
|
||||||
Values: 1 or 0 ~
|
Values: 0, 1 or 2 ~
|
||||||
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 delimitMate_expand_cr = 1
|
let delimitMate_expand_cr = 1
|
||||||
au FileType mail let b:delimitMate_expand_cr = 1
|
au FileType mail let b:delimitMate_expand_cr = 1
|
||||||
@@ -376,24 +208,73 @@ e.g.: >
|
|||||||
*'b:delimitMate_expand_space'*
|
*'b:delimitMate_expand_space'*
|
||||||
Values: 1 or 0 ~
|
Values: 1 or 0 ~
|
||||||
Default: 0 ~
|
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 = 1
|
let delimitMate_expand_space = 1
|
||||||
au FileType tcl let b:delimitMate_expand_space = 1
|
au FileType tcl let b:delimitMate_expand_space = 1
|
||||||
<
|
<
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
*'delimitMate_expand_inside_quotes'*
|
||||||
|
*'b:delimitMate_expand_inside_quotes'*
|
||||||
|
Values: 1 or 0 ~
|
||||||
|
Default: 0 ~
|
||||||
|
When this option is set to 1 the expansion of space and cr will also be
|
||||||
|
applied to quotes. Read |delimitMateExpansion| for details.
|
||||||
|
|
||||||
|
e.g.: >
|
||||||
|
let delimitMate_expand_inside_quotes = 1
|
||||||
|
au FileType mail let b:delimitMate_expand_inside_quotes = 1
|
||||||
|
<
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
*'delimitMate_jump_expansion'*
|
||||||
|
*'b:delimitMate_jump_expansion'*
|
||||||
|
Values: 1 or 0 ~
|
||||||
|
Default: 0 ~
|
||||||
|
This option turns on/off the jumping over <CR> and <Space> expansions when
|
||||||
|
inserting closing matchpairs. Read |delimitMateExpansion| for details.
|
||||||
|
e.g.: >
|
||||||
|
let delimitMate_jump_expansion = 1
|
||||||
|
au FileType tcl let b:delimitMate_jump_expansion = 1
|
||||||
|
<
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*'delimitMate_smart_quotes'*
|
*'delimitMate_smart_quotes'*
|
||||||
*'b:delimitMate_smart_quotes'*
|
*'b:delimitMate_smart_quotes'*
|
||||||
Values: 1 or 0 ~
|
Values: String with an optional ! at the beginning followed by a regexp ~
|
||||||
Default: 1 ~
|
Default:~
|
||||||
|
'\%(\w\|[^[:punct:][:space:]]\|\%(\\\\\)*\\\)\%#\|\%#\%(\w\|[^[:space:][:punct:]]\)' ~
|
||||||
|
|
||||||
|
A bang (!) at the beginning is removed and used to "negate" the pattern. The
|
||||||
|
remaining text is used as a regexp to be matched on the current line. A single
|
||||||
|
quote is inserted when the pattern matches and a bang is not present. The bang
|
||||||
|
changes that, so a single quote is inserted only if the regexp does not match.
|
||||||
|
|
||||||
|
This feature is disabled when the variable is set to an empty string, with the
|
||||||
|
exception of apostrophes.
|
||||||
|
|
||||||
|
Note that you need to use '\%#' to match the position of the cursor. Keep in
|
||||||
|
mind that '\%#' matches with zero width, so if you need to match the char
|
||||||
|
under the cursor (which would be the one to the right on insert mode) use
|
||||||
|
something like '\%#.'.
|
||||||
|
|
||||||
This option turns on/off the smart quotes feature. Read
|
|
||||||
|delimitMateSmartQuotes| for details.
|
|
||||||
e.g.: >
|
e.g.: >
|
||||||
let delimitMate_smart_quotes = 0
|
let delimitMate_smart_quotes = '\w\%#'
|
||||||
au FileType tcl let b:delimitMate_smart_quotes = 0
|
au FileType tcl let b:delimitMate_smart_quotes = '!\s\%#\w'
|
||||||
|
<
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
*'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'*
|
*'delimitMate_balance_matchpairs'*
|
||||||
@@ -415,7 +296,7 @@ Default: Comment ~
|
|||||||
This options turns delimitMate off for the listed regions, read |group-name|
|
This options turns delimitMate off for the listed regions, read |group-name|
|
||||||
for more info about what is a region.
|
for more info about what is a region.
|
||||||
e.g.: >
|
e.g.: >
|
||||||
let delimitMate_excluded_regions = "Comments,String"
|
let delimitMate_excluded_regions = "Comment,String"
|
||||||
<
|
<
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*'delimitMate_excluded_ft'*
|
*'delimitMate_excluded_ft'*
|
||||||
@@ -427,6 +308,17 @@ only if you don't want any of the features it provides on those file types.
|
|||||||
e.g.: >
|
e.g.: >
|
||||||
let delimitMate_excluded_ft = "mail,txt"
|
let delimitMate_excluded_ft = "mail,txt"
|
||||||
<
|
<
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
*'delimitMate_eol_marker'*
|
||||||
|
Values: String. ~
|
||||||
|
Default: Empty. ~
|
||||||
|
|
||||||
|
The contents of this string will be inserted after the closing matchpair or
|
||||||
|
quote when the respective opening matchpair or quote is inserted at the end
|
||||||
|
of the line.
|
||||||
|
e.g.: >
|
||||||
|
au FileType c,perl let b:delimitMate_eol_marker = ";"
|
||||||
|
<
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*'delimitMate_apostrophes'*
|
*'delimitMate_apostrophes'*
|
||||||
Values: Strings separated by ":". ~
|
Values: Strings separated by ":". ~
|
||||||
@@ -443,6 +335,209 @@ 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 any matchpair, <Space> and <CR> can be
|
||||||
|
expanded, see |'delimitMate_expand_space'| and
|
||||||
|
|'delimitMate_expand_cr'|:
|
||||||
|
|
||||||
|
Expand <Space> to: >
|
||||||
|
|
||||||
|
You start with | You get
|
||||||
|
==============================
|
||||||
|
(|) | ( | )
|
||||||
|
<
|
||||||
|
Expand <CR> to: >
|
||||||
|
|
||||||
|
You start with | You get
|
||||||
|
==============================
|
||||||
|
(|) | (
|
||||||
|
| |
|
||||||
|
| )
|
||||||
|
<
|
||||||
|
|
||||||
|
When you have |'delimitMate_jump_expansion'| enabled, if there is an existing
|
||||||
|
closing paren/bracket/etc. on the next line, delimitMate will make the cursor
|
||||||
|
jump over any whitespace/<CR> and place it after the existing closing
|
||||||
|
delimiter instead of inserting a new one.
|
||||||
|
|
||||||
|
When |'delimitMate_expand_cr'| is set to 2, the following will also happen: >
|
||||||
|
|
||||||
|
You start with | You get
|
||||||
|
==============================
|
||||||
|
(foo|) | (foo
|
||||||
|
| |
|
||||||
|
| )
|
||||||
|
<
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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 "\", following or
|
||||||
|
preceding a keyword character, or when the number of quotes in the current
|
||||||
|
line is odd. This should cover closing quotes after a string, opening quotes
|
||||||
|
before a string, escaped quotes and apostrophes. See more details about
|
||||||
|
customizing this feature on |'delimitMate_smart_quotes'|.
|
||||||
|
|
||||||
|
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*
|
||||||
|
|
||||||
@@ -529,13 +624,46 @@ represented by an "|": >
|
|||||||
<
|
<
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
5. FUNCTIONS *delimitMateFunctions*
|
5. MAPPINGS *delimitMateMappings*
|
||||||
|
|
||||||
Functions should be used enclosed between <C-R>= and <CR>, otherwise they
|
delimitMate doesn't override any existing map, so you may encounter that it
|
||||||
might not work as expected or at all.
|
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 for the extra features:
|
||||||
|
|
||||||
|
<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
|
||||||
|
|
||||||
|
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.
|
||||||
e.g.: >
|
e.g.: >
|
||||||
@@ -545,28 +673,6 @@ e.g.: >
|
|||||||
\ "external_mapping"
|
\ "external_mapping"
|
||||||
<
|
<
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
delimitMate#ExpandReturn() *delimitMate#ExpandReturn()*
|
|
||||||
|
|
||||||
Returns the expansion for <CR> if enabled and inside an empty pair, returns
|
|
||||||
<CR> otherwise.
|
|
||||||
|
|
||||||
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>" :
|
|
||||||
\ "\<C-R>=delimitMate#ExpandReturn()\<CR>"
|
|
||||||
<
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
delimitMate#ExpandSpace() *delimitMate#ExpandSpace()*
|
|
||||||
|
|
||||||
Returns the expansion for <Space> if enabled and inside an empty pair, returns
|
|
||||||
<Space> otherwise.
|
|
||||||
e.g.: >
|
|
||||||
|
|
||||||
inoremap <Space> <C-R>=delimitMate#ExpandSpace()<CR>
|
|
||||||
<
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
delimitMate#ShouldJump() *delimitMate#ShouldJump()*
|
delimitMate#ShouldJump() *delimitMate#ShouldJump()*
|
||||||
|
|
||||||
@@ -574,23 +680,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(key) *delimitMate#JumpAny()*
|
delimitMate#JumpAny() *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.
|
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 <C-Tab> <C-R>=delimitMate#JumpAny("\<C-Tab>")<CR>
|
inoremap <C-Tab> <C-R>=delimitMate#JumpAny()<CR>
|
||||||
<
|
<
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
6. TODO LIST *delimitMateTodo*
|
7. TODO LIST *delimitMateTodo*
|
||||||
|
|
||||||
- Automatic set-up by file type.
|
- Automatic set-up by file type.
|
||||||
- Make block-wise visual wrapping work on un-even regions.
|
- Make block-wise visual wrapping work on un-even regions.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
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
|
||||||
@@ -599,40 +705,70 @@ 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
|
|
||||||
|
|
||||||
- Karl Guertin
|
Some of the code that makes this script was modified or just shamelessly
|
||||||
AutoClose:
|
copied from the following sources:
|
||||||
http://www.vim.org/scripts/script.php?script_id=1849
|
|
||||||
|
|
||||||
- Thiago Alves
|
- Ian McCracken ~
|
||||||
AutoClose:
|
Post titled: Vim, Part II: Matching Pairs:
|
||||||
http://www.vim.org/scripts/script.php?script_id=2009
|
http://concisionandconcinnity.blogspot.com/
|
||||||
|
|
||||||
- Edoardo Vacchi
|
- Aristotle Pagaltzis ~
|
||||||
ClosePairs:
|
From the comments on the previous blog post and from:
|
||||||
http://www.vim.org/scripts/script.php?script_id=2373
|
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.
|
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.4.1 2010-07-31 * Current release:
|
2.7 2013-07-15 * Current release:
|
||||||
- Fix problem with <Home> and <End>.
|
- Lots of bug fixes.
|
||||||
|
- Add delimitMate_offByDefault.
|
||||||
|
- Add delimitMate_eol_marker.
|
||||||
|
- Reduce the number of mappings.
|
||||||
|
- Stop using setline().
|
||||||
|
- Better handling of nested quotes.
|
||||||
|
- Allow a custom pattern for smart_quotes.
|
||||||
|
|---------|------------|-----------------------------------------------------|
|
||||||
|
2.6 2011-01-14 * - 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'|,
|
- Add missing doc on |'delimitMate_smart_quotes'|,
|
||||||
|delimitMateBalance| and
|
|delimitMateBalance| and
|
||||||
|'delimitMate_balance_matchpairs'|.
|
|'delimitMate_balance_matchpairs'|.
|
||||||
@@ -653,7 +789,7 @@ This script was inspired by the auto-completion of delimiters on TextMate.
|
|||||||
2.3 2010-06-06 * - Syntax aware: Will turn off when editing comments
|
2.3 2010-06-06 * - Syntax aware: Will turn off when editing comments
|
||||||
or other regions, customizable.
|
or other regions, customizable.
|
||||||
- Changed format of most mappings.
|
- Changed format of most mappings.
|
||||||
- Fix: <CR> expansion doesn't brake automatic
|
- Fix: <CR> expansion doesn't break automatic
|
||||||
indentation adjustments anymore.
|
indentation adjustments anymore.
|
||||||
- Fix: Arrow keys would insert A, B, C or D instead
|
- Fix: Arrow keys would insert A, B, C or D instead
|
||||||
of moving the cursor when using Vim on a terminal.
|
of moving the cursor when using Vim on a terminal.
|
||||||
@@ -743,4 +879,4 @@ _____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|____ ~
|
|||||||
__|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_ ~
|
__|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_ ~
|
||||||
_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|____ ~
|
_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|____ ~
|
||||||
|
|
||||||
vim:tw=78:et:ts=2:sw=2:ft=help:norl:formatoptions+=tcroqn:autoindent:
|
vim:tw=78:et:ts=8:sw=2:ft=help:norl:formatoptions+=tcroqn:autoindent:
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
" ============================================================================
|
|
||||||
" File: plugin/delimitMate.vim
|
" File: plugin/delimitMate.vim
|
||||||
" Version: 2.4.1
|
" Version: 2.7
|
||||||
" Modified: 2010-07-31
|
" Modified: 2013-07-15
|
||||||
" 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: {{{
|
||||||
|
|
||||||
@@ -13,13 +13,8 @@ if exists("g:loaded_delimitMate") || &cp
|
|||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
let g:loaded_delimitMate = 1
|
let g:loaded_delimitMate = 1
|
||||||
|
let save_cpo = &cpo
|
||||||
if exists("s:loaded_delimitMate") && !exists("g:delimitMate_testing")
|
set cpo&vim
|
||||||
" Don't define the functions if they already exist: just do the work
|
|
||||||
" (unless we are testing):
|
|
||||||
call s:DelimitMateDo()
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
|
|
||||||
if v:version < 700
|
if v:version < 700
|
||||||
echoerr "delimitMate: this plugin requires vim >= 7!"
|
echoerr "delimitMate: this plugin requires vim >= 7!"
|
||||||
@@ -27,75 +22,343 @@ if v:version < 700
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
let s:loaded_delimitMate = 1
|
let s:loaded_delimitMate = 1
|
||||||
let delimitMate_version = "2.4.1"
|
let delimitMate_version = "2.7"
|
||||||
|
|
||||||
|
function! s:option_init(name, default) "{{{
|
||||||
|
let b = exists("b:delimitMate_" . a:name)
|
||||||
|
let g = exists("g:delimitMate_" . a:name)
|
||||||
|
" Find value to use.
|
||||||
|
if !b && !g
|
||||||
|
let value = a:default
|
||||||
|
elseif b
|
||||||
|
exec "let value = b:delimitMate_" . a:name
|
||||||
|
else
|
||||||
|
exec "let value = g:delimitMate_" . a:name
|
||||||
|
endif
|
||||||
|
call s:s(a:name, value)
|
||||||
|
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", map(split(s:g('matchpairs'), ','), 'split(v:val, '':'')'))
|
||||||
|
let pairs = s:g('matchpairs_list')
|
||||||
|
if len(filter(pairs, 'v:val[0] ==# v:val[1]'))
|
||||||
|
echohl ErrorMsg
|
||||||
|
echom 'delimitMate: each member of a pair in delimitMate_matchpairs must be different from each other.'
|
||||||
|
echom 'delimitMate: invalid pairs: ' . join(map(pairs, 'join(v:val, ":")'), ', ')
|
||||||
|
echohl Normal
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
call s:option_init("left_delims", map(copy(s:g('matchpairs_list')), 'v:val[0]'))
|
||||||
|
call s:option_init("right_delims", map(copy(s:g('matchpairs_list')), 'v:val[1]'))
|
||||||
|
" quotes
|
||||||
|
call s:option_init("quotes", "\" ' `")
|
||||||
|
call s:option_init("quotes_list",split(s:g('quotes'), '\s\+'))
|
||||||
|
" 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(s:g('excluded_regions'), ',\s*'))
|
||||||
|
let enabled = len(s:g('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)
|
||||||
|
" expand_in_quotes
|
||||||
|
call s:option_init('expand_inside_quotes', 0)
|
||||||
|
" jump_expansion
|
||||||
|
call s:option_init("jump_expansion", 0)
|
||||||
|
" smart_matchpairs
|
||||||
|
call s:option_init("smart_matchpairs", '^\%(\w\|\!\|£\|\$\|_\|["'']\s*\S\)')
|
||||||
|
" smart_quotes
|
||||||
|
" XXX: backward compatibility. Ugly, should go the way of the dodo soon.
|
||||||
|
let quotes = escape(join(s:g('quotes_list'), ''), '\-^[]')
|
||||||
|
let default_smart_quotes = '\%(\w\|[^[:punct:][:space:]' . quotes . ']\|\%(\\\\\)*\\\)\%#\|\%#\%(\w\|[^[:space:][:punct:]' . quotes . ']\)'
|
||||||
|
if exists('g:delimitMate_smart_quotes') && type(g:delimitMate_smart_quotes) == type(0)
|
||||||
|
if g:delimitMate_smart_quotes
|
||||||
|
unlet g:delimitMate_smart_quotes
|
||||||
|
else
|
||||||
|
unlet g:delimitMate_smart_quotes
|
||||||
|
let g:delimitMate_smart_quotes = ''
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
if exists('b:delimitMate_smart_quotes') && type(b:delimitMate_smart_quotes) == type(0)
|
||||||
|
if b:delimitMate_smart_quotes
|
||||||
|
unlet b:delimitMate_smart_quotes
|
||||||
|
if exists('g:delimitMate_smart_quotes') && type(g:delimitMate_smart_quotes) && g:delimitMate_smart_quotes
|
||||||
|
let b:delimitMate_smart_quotes = default_smart_quotes
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
unlet b:delimitMate_smart_quotes
|
||||||
|
let b:delimitMate_smart_quotes = ''
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
call s:option_init("smart_quotes", default_smart_quotes)
|
||||||
|
" apostrophes
|
||||||
|
call s:option_init("apostrophes", "")
|
||||||
|
call s:option_init("apostrophes_list", split(s:g('apostrophes'), ":\s*"))
|
||||||
|
" tab2exit
|
||||||
|
call s:option_init("tab2exit", 1)
|
||||||
|
" balance_matchpairs
|
||||||
|
call s:option_init("balance_matchpairs", 0)
|
||||||
|
" eol marker
|
||||||
|
call s:option_init("eol_marker", "")
|
||||||
|
" Everything is fine.
|
||||||
|
return 1
|
||||||
|
endfunction "}}} Init()
|
||||||
|
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
" Functions: {{{
|
" Functions: {{{
|
||||||
|
|
||||||
|
function! s:g(...) " {{{
|
||||||
|
return call('delimitMate#Get', a:000)
|
||||||
|
endfunction " }}}
|
||||||
|
|
||||||
|
function! s:s(...) " {{{
|
||||||
|
return call('delimitMate#Set', a:000)
|
||||||
|
endfunction " }}}
|
||||||
|
|
||||||
|
function! s:Map() "{{{
|
||||||
|
" Set mappings:
|
||||||
|
try
|
||||||
|
let save_keymap = &keymap
|
||||||
|
let save_iminsert = &iminsert
|
||||||
|
let save_imsearch = &imsearch
|
||||||
|
let save_cpo = &cpo
|
||||||
|
set keymap=
|
||||||
|
set cpo&vim
|
||||||
|
if s:g('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 =
|
||||||
|
\ s:g('right_delims', []) +
|
||||||
|
\ s:g('left_delims', []) +
|
||||||
|
\ s:g('quotes_list', []) +
|
||||||
|
\ s:g('apostrophes_list', []) +
|
||||||
|
\ ['<BS>', '<C-h>', '<S-BS>', '<Del>', '<CR>', '<Space>', '<S-Tab>', '<Esc>'] +
|
||||||
|
\ ['<Up>', '<Down>', '<Left>', '<Right>', '<LeftMouse>', '<RightMouse>'] +
|
||||||
|
\ ['<C-Left>', '<C-Right>'] +
|
||||||
|
\ ['<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
|
||||||
|
let b:delimitMate_enabled = 0
|
||||||
|
endfunction " }}} s:Unmap()
|
||||||
|
|
||||||
function! s:TestMappingsDo() "{{{
|
function! s:TestMappingsDo() "{{{
|
||||||
if !exists("g:delimitMate_testing")
|
if &modified
|
||||||
silent call delimitMate#TestMappings()
|
let confirm = input("Modified buffer, type \"yes\" to write and proceed "
|
||||||
else
|
\ . "with test: ") ==? 'yes'
|
||||||
let temp_varsDM = [b:_l_delimitMate_expand_space, b:_l_delimitMate_expand_cr, b:_l_delimitMate_autoclose]
|
if !confirm
|
||||||
for i in [0,1]
|
return
|
||||||
let b:delimitMate_expand_space = i
|
endif
|
||||||
let b:delimitMate_expand_cr = i
|
|
||||||
for a in [0,1]
|
|
||||||
let b:delimitMate_autoclose = a
|
|
||||||
call delimitMate#Init()
|
|
||||||
call delimitMate#UnMap()
|
|
||||||
call delimitMate#Map()
|
|
||||||
call delimitMate#TestMappings()
|
|
||||||
normal o
|
|
||||||
endfor
|
|
||||||
endfor
|
|
||||||
let b:delimitMate_expand_space = temp_varsDM[0]
|
|
||||||
let b:delimitMate_expand_cr = temp_varsDM[1]
|
|
||||||
let b:delimitMate_autoclose = temp_varsDM[2]
|
|
||||||
unlet temp_varsDM
|
|
||||||
endif
|
endif
|
||||||
normal gg
|
call delimitMate#TestMappings()
|
||||||
|
g/\%^$/d
|
||||||
|
0
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! s:DelimitMateDo(...) "{{{
|
function! s:DelimitMateDo(...) "{{{
|
||||||
" Initialize settings:
|
" First, remove all magic, if needed:
|
||||||
call delimitMate#Init()
|
if exists("b:delimitMate_enabled") && b:delimitMate_enabled == 1
|
||||||
|
call s:Unmap()
|
||||||
|
endif
|
||||||
" Check if this file type is excluded:
|
" Check if this file type is excluded:
|
||||||
if exists("g:delimitMate_excluded_ft") &&
|
if exists("g:delimitMate_excluded_ft") &&
|
||||||
\ index(split(g:delimitMate_excluded_ft, ','), &filetype, 0, 1) >= 0
|
\ index(split(g:delimitMate_excluded_ft, ','), &filetype, 0, 1) >= 0
|
||||||
|
" Finish here:
|
||||||
" Remove any magic:
|
return 1
|
||||||
call delimitMate#UnMap()
|
|
||||||
|
|
||||||
" Finish here:
|
|
||||||
return 1
|
|
||||||
endif
|
endif
|
||||||
|
" Check if user tried to disable using b:loaded_delimitMate
|
||||||
" First, remove all magic, if needed:
|
if exists("b:loaded_delimitMate")
|
||||||
if exists("b:delimitMate_enabled") && b:delimitMate_enabled == 1
|
return 1
|
||||||
call delimitMate#UnMap()
|
endif
|
||||||
|
" Initialize settings:
|
||||||
|
if ! s:init()
|
||||||
|
" Something went wrong.
|
||||||
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Now, add magic:
|
" Now, add magic:
|
||||||
call delimitMate#Map()
|
if !exists("g:delimitMate_offByDefault") || !g:delimitMate_offByDefault
|
||||||
|
call s:Map()
|
||||||
|
endif
|
||||||
if a:0 > 0
|
if a:0 > 0
|
||||||
echo "delimitMate has been reset."
|
echo "delimitMate has been reset."
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! s:DelimitMateSwitch() "{{{
|
function! s:DelimitMateSwitch() "{{{
|
||||||
call delimitMate#Init()
|
|
||||||
if exists("b:delimitMate_enabled") && b:delimitMate_enabled
|
if exists("b:delimitMate_enabled") && b:delimitMate_enabled
|
||||||
call delimitMate#UnMap()
|
call s:Unmap()
|
||||||
echo "delimitMate has been disabled."
|
echo "delimitMate has been disabled."
|
||||||
else
|
else
|
||||||
call delimitMate#UnMap()
|
call s:Unmap()
|
||||||
call delimitMate#Map()
|
call s:init()
|
||||||
|
call s:Map()
|
||||||
echo "delimitMate has been enabled."
|
echo "delimitMate has been enabled."
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
"}}}
|
||||||
|
|
||||||
|
" Mappers: {{{
|
||||||
|
function! s:TriggerAbb() "{{{
|
||||||
|
if v:version < 703
|
||||||
|
\ || ( v:version == 703 && !has('patch489') )
|
||||||
|
\ || pumvisible()
|
||||||
|
return ''
|
||||||
|
endif
|
||||||
|
return "\<C-]>"
|
||||||
|
endfunction "}}}
|
||||||
|
|
||||||
|
function! s:NoAutoClose() "{{{
|
||||||
|
" inoremap <buffer> ) <C-R>=delimitMate#SkipDelim('\)')<CR>
|
||||||
|
for delim in s:g('right_delims') + s:g('quotes_list')
|
||||||
|
if delim == '|'
|
||||||
|
let delim = '<Bar>'
|
||||||
|
endif
|
||||||
|
exec 'inoremap <silent> <Plug>delimitMate' . delim . ' <C-R>=<SID>TriggerAbb().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(s:g('matchpairs_list'))
|
||||||
|
let ld = s:g('left_delims')[i] == '|' ? '<bar>' : s:g('left_delims')[i]
|
||||||
|
let rd = s:g('right_delims')[i] == '|' ? '<bar>' : s:g('right_delims')[i]
|
||||||
|
exec 'inoremap <expr><silent> <Plug>delimitMate' . ld
|
||||||
|
\. ' <SID>TriggerAbb().delimitMate#ParenDelim("' . escape(rd, '|') . '")'
|
||||||
|
exec 'silent! imap <unique> <buffer> '.ld
|
||||||
|
\.' <Plug>delimitMate'.ld
|
||||||
|
let i += 1
|
||||||
|
endwhile
|
||||||
|
|
||||||
|
" Exit from inside the matching pair:
|
||||||
|
for delim in s:g('right_delims')
|
||||||
|
let delim = delim == '|' ? '<bar>' : delim
|
||||||
|
exec 'inoremap <expr><silent> <Plug>delimitMate' . delim
|
||||||
|
\. ' <SID>TriggerAbb().delimitMate#JumpOut("\' . delim . '")'
|
||||||
|
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 s:g('quotes_list')
|
||||||
|
if delim == '|'
|
||||||
|
let delim = '<Bar>'
|
||||||
|
endif
|
||||||
|
exec 'inoremap <expr><silent> <Plug>delimitMate' . delim
|
||||||
|
\. ' <SID>TriggerAbb()."<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 s:g('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')
|
||||||
|
if maparg('<BS>'. 'i') == ''
|
||||||
|
silent! imap <unique> <buffer> <BS> <Plug>delimitMateBS
|
||||||
|
endif
|
||||||
|
if maparg('<C-h>'. 'i') == ''
|
||||||
|
silent! imap <unique> <buffer> <C-h> <Plug>delimitMateBS
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
" If pair is empty, delete closing delimiter:
|
||||||
|
inoremap <silent> <expr> <Plug>delimitMateS-BS delimitMate#WithinEmptyPair() ? "\<Del>" : "\<S-BS>"
|
||||||
|
if !hasmapto('<Plug>delimitMateS-BS','i') && maparg('<S-BS>', 'i') == ''
|
||||||
|
silent! imap <unique> <buffer> <S-BS> <Plug>delimitMateS-BS
|
||||||
|
endif
|
||||||
|
" Expand return if inside an empty pair:
|
||||||
|
inoremap <expr><silent> <Plug>delimitMateCR <SID>TriggerAbb()."\<C-R>=delimitMate#ExpandReturn()\<CR>"
|
||||||
|
if s:g('expand_cr') && !hasmapto('<Plug>delimitMateCR', 'i') && maparg('<CR>', 'i') == ''
|
||||||
|
silent! imap <unique> <buffer> <CR> <Plug>delimitMateCR
|
||||||
|
endif
|
||||||
|
" Expand space if inside an empty pair:
|
||||||
|
inoremap <expr><silent> <Plug>delimitMateSpace <SID>TriggerAbb()."\<C-R>=delimitMate#ExpandSpace()\<CR>"
|
||||||
|
if s:g('expand_space') && !hasmapto('<Plug>delimitMateSpace', 'i') && maparg('<Space>', 'i') == ''
|
||||||
|
silent! imap <unique> <buffer> <Space> <Plug>delimitMateSpace
|
||||||
|
endif
|
||||||
|
" Jump over any delimiter:
|
||||||
|
inoremap <expr><silent> <Plug>delimitMateS-Tab <SID>TriggerAbb()."\<C-R>=delimitMate#JumpAny()\<CR>"
|
||||||
|
if s:g('tab2exit') && !hasmapto('<Plug>delimitMateS-Tab', 'i') && maparg('<S-Tab>', 'i') == ''
|
||||||
|
silent! imap <unique> <buffer> <S-Tab> <Plug>delimitMateS-Tab
|
||||||
|
endif
|
||||||
|
" Jump over next delimiters
|
||||||
|
inoremap <expr><buffer> <Plug>delimitMateJumpMany <SID>TriggerAbb()."\<C-R>=delimitMate#JumpMany()\<CR>"
|
||||||
|
if !hasmapto('<Plug>delimitMateJumpMany', 'i') && maparg("<C-G>g", 'i') == ''
|
||||||
|
imap <silent> <buffer> <C-G>g <Plug>delimitMateJumpMany
|
||||||
|
endif
|
||||||
|
endfunction "}}}
|
||||||
|
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
@@ -104,13 +367,13 @@ endfunction "}}}
|
|||||||
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(1)
|
command! -bar DelimitMateReload call s:DelimitMateDo(1)
|
||||||
|
|
||||||
" Quick test:
|
" Quick test:
|
||||||
command! DelimitMateTest call s:TestMappingsDo()
|
command! -bar DelimitMateTest call s:TestMappingsDo()
|
||||||
|
|
||||||
" Switch On/Off:
|
" Switch On/Off:
|
||||||
command! DelimitMateSwitch call s:DelimitMateSwitch()
|
command! -bar DelimitMateSwitch call s:DelimitMateSwitch()
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
" Autocommands: {{{
|
" Autocommands: {{{
|
||||||
@@ -123,20 +386,14 @@ augroup delimitMate
|
|||||||
|
|
||||||
" Run on new buffers.
|
" Run on new buffers.
|
||||||
autocmd BufNewFile,BufRead,BufEnter *
|
autocmd BufNewFile,BufRead,BufEnter *
|
||||||
\ if !exists("b:loaded_delimitMate") |
|
\ if !exists('b:delimitMate_was_here') |
|
||||||
\ call <SID>DelimitMateDo() |
|
\ call <SID>DelimitMateDo() |
|
||||||
|
\ let b:delimitMate_was_here = 1 |
|
||||||
\ endif
|
\ endif
|
||||||
|
|
||||||
" Flush the char buffer:
|
|
||||||
autocmd InsertEnter * call delimitMate#FlushBuffer()
|
|
||||||
autocmd BufEnter *
|
|
||||||
\ if mode() == 'i' |
|
|
||||||
\ call delimitMate#FlushBuffer() |
|
|
||||||
\ endif
|
|
||||||
|
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
|
let &cpo = save_cpo
|
||||||
" GetLatestVimScripts: 2754 1 :AutoInstall: delimitMate.vim
|
" GetLatestVimScripts: 2754 1 :AutoInstall: delimitMate.vim
|
||||||
" vim:foldmethod=marker:foldcolumn=4
|
" vim:foldmethod=marker:foldcolumn=4:ts=2:sw=2
|
||||||
|
|||||||
9
test/Makefile
Normal file
9
test/Makefile
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
all: build/runVimTests
|
||||||
|
build/runVimTests/bin/runVimTests.sh -0 .
|
||||||
|
|
||||||
|
build/runVimTests: build/VimTAP
|
||||||
|
git clone https://github.com/inkarkat/runVimTests $@
|
||||||
|
|
||||||
|
# Use VimTAP as directory name, as used with runVimTestsSetup.vim.
|
||||||
|
build/VimTAP:
|
||||||
|
git clone https://github.com/inkarkat/vimtap $@
|
||||||
18
test/README.md
Normal file
18
test/README.md
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Automatic test setup
|
||||||
|
You can use `make` (or `make test` from the top level directory) to run the
|
||||||
|
tests.
|
||||||
|
|
||||||
|
# Manual test setup instructions
|
||||||
|
The plugins [runVimTests](http://www.vim.org/scripts/script.php?script_id=2565)
|
||||||
|
and [VimTAP](http://www.vim.org/scripts/script.php?script_id=2213) are needed
|
||||||
|
to run these tests.
|
||||||
|
|
||||||
|
Besides the `_setup.vim` configuration file present in this repo you need to
|
||||||
|
create a global one and place it in the same dir where the runVimTests
|
||||||
|
executable is located. Assuming the executable is at '~/bin/runVimTests' this
|
||||||
|
global configuration file should be '~/bin/runVimTestsSetup.vim' and should
|
||||||
|
have something like the following lines inside of it:
|
||||||
|
|
||||||
|
" Prepend tests repos to &rtp
|
||||||
|
let &runtimepath = '/path/to/runVimTests_dir,' . &rtp
|
||||||
|
let &runtimepath = '/path/to/vimTAP_dir,' . &rtp
|
||||||
12
test/_setup.vim
Normal file
12
test/_setup.vim
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
let &rtp = expand('<sfile>:p:h:h') . ',' . &rtp . ',' . expand('<sfile>:p:h:h') . '/after'
|
||||||
|
set bs=2
|
||||||
|
ru plugin/delimitMate.vim
|
||||||
|
let runVimTests = expand('<sfile>:p:h').'/build/runVimTests'
|
||||||
|
if isdirectory(runVimTests)
|
||||||
|
let &rtp = runVimTests . ',' . &rtp
|
||||||
|
endif
|
||||||
|
let vimTAP = expand('<sfile>:p:h').'/build/VimTAP'
|
||||||
|
if isdirectory(vimTAP)
|
||||||
|
let &rtp = vimTAP . ',' . &rtp
|
||||||
|
endif
|
||||||
|
|
||||||
41
test/autoclose_matchpairs.txt
Normal file
41
test/autoclose_matchpairs.txt
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
let g:delimitMate_autoclose = 1
|
||||||
|
"(x" "(x)"
|
||||||
|
"(\<BS>x" "x"
|
||||||
|
"()x" "()x"
|
||||||
|
"((\<C-G>gx" "(())x"
|
||||||
|
"(x\<Esc>u" ""
|
||||||
|
"@(x" "@(x)"
|
||||||
|
"@#\<Left>(x" "@(x)#"
|
||||||
|
"(\<S-Tab>x" "()x"
|
||||||
|
let g:delimitMate_autoclose = 0
|
||||||
|
"(x" "(x"
|
||||||
|
"()x" "(x)"
|
||||||
|
"())x" "()x"
|
||||||
|
"()\<BS>x" "x"
|
||||||
|
"@()x" "@(x)"
|
||||||
|
"@#\<Left>()x" "@(x)#"
|
||||||
|
let g:delimitMate_expand_space = 1
|
||||||
|
let g:delimitMate_autoclose = 1
|
||||||
|
"(\<Space>x" "( x )"
|
||||||
|
"(\<Space>\<BS>x" "(x)"
|
||||||
|
let g:delimitMate_autoclose = 0
|
||||||
|
"()\<Space>\<BS>x" "(x)"
|
||||||
|
let g:delimitMate_autoclose = 1
|
||||||
|
# Handle backspace gracefully.
|
||||||
|
set backspace=
|
||||||
|
"(\<Esc>a\<BS>x" "(x)"
|
||||||
|
set bs=2
|
||||||
|
# closing parens removes characters. #133
|
||||||
|
"(a\<Esc>i)" "()a)"
|
||||||
|
|
||||||
|
# Add semicolon next to the closing paren. Issue #77.
|
||||||
|
new
|
||||||
|
let b:delimitMate_eol_marker = ';'
|
||||||
|
"abc(x" "abc(x);"
|
||||||
|
%d
|
||||||
|
# BS should behave accordingly.
|
||||||
|
"abc(\<BS>" "abc;"
|
||||||
|
# Expand iabbreviations
|
||||||
|
unlet b:delimitMate_eol_marker
|
||||||
|
iabb def ghi
|
||||||
|
"def(" "ghi()"
|
||||||
42
test/autoclose_matchpairs.vim
Normal file
42
test/autoclose_matchpairs.vim
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
let g:delimitMate_matchpairs = '(:),{:},[:],<:>,¿:?,¡:!'
|
||||||
|
let lines = readfile(expand('<sfile>:t:r').'.txt')
|
||||||
|
call vimtest#StartTap()
|
||||||
|
let testsnumber = len(filter(copy(lines), 'v:val =~ ''^"'''))
|
||||||
|
let itemsnumber = len(split(g:delimitMate_matchpairs, ','))
|
||||||
|
call vimtap#Plan(testsnumber * itemsnumber)
|
||||||
|
let tcount = 1
|
||||||
|
let reload = 1
|
||||||
|
for item in lines
|
||||||
|
if item =~ '^#\|^\s*$'
|
||||||
|
" A comment or empty line.
|
||||||
|
continue
|
||||||
|
endif
|
||||||
|
if item !~ '^"'
|
||||||
|
" A command.
|
||||||
|
exec item
|
||||||
|
call vimtap#Diag(item)
|
||||||
|
let reload = 1
|
||||||
|
continue
|
||||||
|
endif
|
||||||
|
if reload
|
||||||
|
DelimitMateReload
|
||||||
|
call vimtap#Diag('DelimitMateReload')
|
||||||
|
let reload = 0
|
||||||
|
endif
|
||||||
|
let [input, output] = split(item, '"\%(\\.\|[^\\"]\)*"\zs\s*\ze"\%(\\.\|[^\\"]\)*"')
|
||||||
|
for [s:l,s:r] in map(split(g:delimitMate_matchpairs, ','), 'split(v:val, ":")')
|
||||||
|
let input2 = substitute(input, '(', s:l, 'g')
|
||||||
|
let input2 = substitute(input2, ')', s:r, 'g')
|
||||||
|
let output2 = substitute(output, '(', s:l, 'g')
|
||||||
|
let output2 = substitute(output2, ')', s:r, 'g')
|
||||||
|
%d
|
||||||
|
exec 'normal i'.eval(input2)."\<Esc>"
|
||||||
|
let line = getline('.')
|
||||||
|
let passed = line == eval(output2)
|
||||||
|
call vimtap#Is(line, eval(output2), input2)
|
||||||
|
", input2 . ' => ' . string(line) .
|
||||||
|
" \ (passed ? ' =' : ' !') . '= ' . string(eval(output2)))
|
||||||
|
let tcount += 1
|
||||||
|
endfor
|
||||||
|
endfor
|
||||||
|
call vimtest#Quit()
|
||||||
73
test/autoclose_quotes.txt
Normal file
73
test/autoclose_quotes.txt
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
let g:delimitMate_autoclose = 1
|
||||||
|
"'x" "'x'"
|
||||||
|
"'x\<Esc>u" ""
|
||||||
|
"''x" "''x"
|
||||||
|
"'\<BS>x" "x"
|
||||||
|
"'\<C-G>gx" "''x"
|
||||||
|
# This will fail for double quote.
|
||||||
|
"'\"x" "'\"x\"'"
|
||||||
|
"@'x" "@'x'"
|
||||||
|
"@#\<Left>'x" "@'x'#"
|
||||||
|
"'\<S-Tab>x" "''x"
|
||||||
|
"abc'" "abc'"
|
||||||
|
"abc\\'x" "abc\\'x"
|
||||||
|
"u'Привет'" "u'Привет'"
|
||||||
|
"u'string'" "u'string'"
|
||||||
|
let g:delimitMate_autoclose = 0
|
||||||
|
"'x" "'x"
|
||||||
|
"''x" "'x'"
|
||||||
|
"'''x" "''x"
|
||||||
|
"''\<BS>x" "x"
|
||||||
|
"@''x" "@'x'"
|
||||||
|
"@#\<Left>''x" "@'x'#"
|
||||||
|
let g:delimitMate_expand_space = 1
|
||||||
|
let g:delimitMate_autoclose = 1
|
||||||
|
"'\<Space>x" "' x'"
|
||||||
|
let g:delimitMate_expand_inside_quotes = 1
|
||||||
|
"'\<Space>x" "' x '"
|
||||||
|
"'\<Space>\<BS>x" "'x'"
|
||||||
|
"abc\\''\<Space>x" "abc\\' x'"
|
||||||
|
let g:delimitMate_autoclose = 0
|
||||||
|
"''\<Space>\<BS>x" "'x'"
|
||||||
|
let g:delimitMate_autoclose = 1
|
||||||
|
# Handle backspace gracefully.
|
||||||
|
set backspace=
|
||||||
|
"'\<Esc>a\<BS>x" "'x'"
|
||||||
|
set backspace=2
|
||||||
|
set cpo=ces$
|
||||||
|
"'x" "'x'"
|
||||||
|
# Make sure smart quote works beyond first column.
|
||||||
|
" 'x" " 'x'"
|
||||||
|
# smart quote, check fo char on the right.
|
||||||
|
"a\<space>b\<left>'" "a 'b"
|
||||||
|
# Make sure we jump over a quote on the right. #89.
|
||||||
|
"('test'x" "('test'x)"
|
||||||
|
# Duplicate whole line when inserting quote at bol #105
|
||||||
|
"}\<Home>'" "''}"
|
||||||
|
"'\<Del>abc '" "'abc '"
|
||||||
|
"''abc '" "''abc ''"
|
||||||
|
# Nesting quotes:
|
||||||
|
let g:delimitMate_nesting_quotes = split(g:delimitMate_quotes, '\s\+')
|
||||||
|
"'''x" "'''x'''"
|
||||||
|
"''''x" "''''x''''"
|
||||||
|
"''x" "''x"
|
||||||
|
"'x" "'x'"
|
||||||
|
unlet g:delimitMate_nesting_quotes
|
||||||
|
# expand iabbreviations
|
||||||
|
iabb def ghi
|
||||||
|
"def'" "ghi'"
|
||||||
|
let g:delimitMate_smart_quotes = '\w\%#\_.'
|
||||||
|
"xyz'x" "xyz'x"
|
||||||
|
"xyz 'x" "xyz 'x'"
|
||||||
|
let g:delimitMate_smart_quotes = '\s\%#\_.'
|
||||||
|
"abc'x" "abc'x'"
|
||||||
|
"abc 'x" "abc 'x"
|
||||||
|
# let's try the negated form
|
||||||
|
let g:delimitMate_smart_quotes = '!\w\%#\_.'
|
||||||
|
"cba'x" "cba'x'"
|
||||||
|
"cba 'x" "cba 'x"
|
||||||
|
let g:delimitMate_smart_quotes = '!\s\%#\_.'
|
||||||
|
"zyx'x" "zyx'x"
|
||||||
|
"zyx 'x" "zyx 'x'"
|
||||||
|
unlet g:delimitMate_smart_quotes
|
||||||
|
"'\<CR>\<BS>" "''"
|
||||||
47
test/autoclose_quotes.vim
Normal file
47
test/autoclose_quotes.vim
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
"let g:delimitMate_quotes = '" '' ` ” « |'
|
||||||
|
let g:delimitMate_quotes = '" '' ` « |'
|
||||||
|
let lines = readfile(expand('<sfile>:t:r').'.txt')
|
||||||
|
call vimtest#StartTap()
|
||||||
|
let testsnumber = len(filter(copy(lines), 'v:val =~ ''^"'''))
|
||||||
|
let itemsnumber = len(split(g:delimitMate_quotes, ' '))
|
||||||
|
call vimtap#Plan(testsnumber * itemsnumber)
|
||||||
|
let reload = 1
|
||||||
|
let tcount = 1
|
||||||
|
let linenr = 0
|
||||||
|
for item in lines
|
||||||
|
let linenr += 1
|
||||||
|
if item =~ '^#\|^\s*$'
|
||||||
|
" A comment or empty line.
|
||||||
|
continue
|
||||||
|
endif
|
||||||
|
if item !~ '^"'
|
||||||
|
" A command.
|
||||||
|
exec item
|
||||||
|
call vimtap#Diag(item)
|
||||||
|
let reload = 1
|
||||||
|
continue
|
||||||
|
endif
|
||||||
|
if reload
|
||||||
|
DelimitMateReload
|
||||||
|
call vimtap#Diag('DelimitMateReload')
|
||||||
|
let reload = 0
|
||||||
|
endif
|
||||||
|
let quotes = split(g:delimitMate_quotes, '\s')
|
||||||
|
for quote in quotes
|
||||||
|
if vimtap#Skip(1, tcount != 26, "This test is invalid for double quote.")
|
||||||
|
let tcount += 1
|
||||||
|
continue
|
||||||
|
endif
|
||||||
|
let [input, output] = split(item, '"\%(\\.\|[^\\"]\)*"\zs\s*\ze"\%(\\.\|[^\\"]\)*"')
|
||||||
|
let input_q = substitute(input,"'" , escape(escape(quote, '"'), '\'), 'g')
|
||||||
|
let output_q = substitute(output,"'" , escape(escape(quote, '"'), '\'), 'g')
|
||||||
|
%d
|
||||||
|
exec 'normal i'.eval(input_q)."\<Esc>"
|
||||||
|
if quote == '”'
|
||||||
|
call vimtap#Todo(1)
|
||||||
|
endif
|
||||||
|
call vimtap#Is(getline('.'), eval(output_q), 'Line '.linenr.': '.eval(substitute(input_q, '\\<', '<','g')))
|
||||||
|
let tcount += 1
|
||||||
|
endfor
|
||||||
|
endfor
|
||||||
|
call vimtest#Quit()
|
||||||
96
test/expand_cr.txt
Normal file
96
test/expand_cr.txt
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
#
|
||||||
|
%d
|
||||||
|
filetype indent on
|
||||||
|
set bs=2 et sts=4 sw=4 ft=javascript
|
||||||
|
call setline(1, '$(document).ready(function() {})')
|
||||||
|
DelimitMateReload
|
||||||
|
exec "normal 31|i\<CR>x\<Esc>"
|
||||||
|
================================================================================
|
||||||
|
$(document).ready(function() {
|
||||||
|
x
|
||||||
|
})
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
# Issue #95
|
||||||
|
new
|
||||||
|
let b:delimitMate_jump_expansion = 1
|
||||||
|
DelimitMateReload
|
||||||
|
exec "normal i(\<CR>test)x"
|
||||||
|
================================================================================
|
||||||
|
(
|
||||||
|
test
|
||||||
|
)x
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
# Remove CR expansion on BS
|
||||||
|
%d
|
||||||
|
exec "normal i(\<CR>\<BS>x"
|
||||||
|
================================================================================
|
||||||
|
(x)
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
# Consider indentation with BS inside an empty CR expansion.
|
||||||
|
%d
|
||||||
|
exec "normal i( \<CR>\<BS>\<BS>x"
|
||||||
|
================================================================================
|
||||||
|
(x)
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
# Conflict with indentation settings (cindent). Issue #95
|
||||||
|
se cindent
|
||||||
|
call setline(1, ['sub foo {',' while (1) {', ' ', ' }', '}'])
|
||||||
|
call cursor(3, 8)
|
||||||
|
normal a}x
|
||||||
|
================================================================================
|
||||||
|
sub foo {
|
||||||
|
while (1) {
|
||||||
|
|
||||||
|
}x
|
||||||
|
}
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
%d
|
||||||
|
call setline(1, '"{bracketed}')
|
||||||
|
normal A"x
|
||||||
|
================================================================================
|
||||||
|
"{bracketed}"x
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
# Syntax folding enabled by autocmd breaks expansion. But ti can't be tested
|
||||||
|
# with :normal
|
||||||
|
new
|
||||||
|
autocmd InsertEnter * let w:fdm=&foldmethod | setl foldmethod=manual
|
||||||
|
autocmd InsertLeave * let &foldmethod = w:fdm
|
||||||
|
set foldmethod=marker
|
||||||
|
set foldmarker={,}
|
||||||
|
set foldlevel=0
|
||||||
|
set backspace=2
|
||||||
|
exec "normal iabc {\<CR>x"
|
||||||
|
================================================================================
|
||||||
|
abc {
|
||||||
|
x
|
||||||
|
}
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
# expand_cr != 2
|
||||||
|
%d_
|
||||||
|
call setline(1, 'abc(def)')
|
||||||
|
exec "normal $i\<CR>x"
|
||||||
|
================================================================================
|
||||||
|
abc(def
|
||||||
|
x)
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
# expand_cr == 2
|
||||||
|
%d_
|
||||||
|
let delimitMate_expand_cr = 2
|
||||||
|
DelimitMateReload
|
||||||
|
call setline(1, 'abc(def)')
|
||||||
|
exec "normal $i\<CR>x"
|
||||||
|
================================================================================
|
||||||
|
abc(def
|
||||||
|
x
|
||||||
|
)
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
# Play nice with smartindent
|
||||||
|
%d_
|
||||||
|
set all&
|
||||||
|
set smartindent
|
||||||
|
exec "normal $i{\<CR>x"
|
||||||
|
================================================================================
|
||||||
|
{
|
||||||
|
x
|
||||||
|
}
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
55
test/expand_cr.vim
Normal file
55
test/expand_cr.vim
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
let g:delimitMate_expand_cr = 1
|
||||||
|
"DelimitMateReload
|
||||||
|
let lines = readfile(expand('<sfile>:t:r').'.txt')
|
||||||
|
call vimtest#StartTap()
|
||||||
|
let testsnumber = len(filter(copy(lines), 'v:val =~ ''^=\{80}$'''))
|
||||||
|
call vimtap#Plan(testsnumber)
|
||||||
|
let tcount = 1
|
||||||
|
let expect = 0
|
||||||
|
let evaluate = 0
|
||||||
|
let commands = []
|
||||||
|
let header = ''
|
||||||
|
for item in lines
|
||||||
|
if item =~ '^=\{80}$'
|
||||||
|
let expect = 1
|
||||||
|
let expected = []
|
||||||
|
continue
|
||||||
|
endif
|
||||||
|
|
||||||
|
if item =~ '^#' && expect == 0
|
||||||
|
" A comment.
|
||||||
|
let header = empty(header) ? item[1:] : 'Lines should match.'
|
||||||
|
continue
|
||||||
|
endif
|
||||||
|
if item =~ '^\s*$' && expect == 0
|
||||||
|
" An empty line.
|
||||||
|
continue
|
||||||
|
endif
|
||||||
|
if ! expect
|
||||||
|
" A command.
|
||||||
|
call add(commands, item)
|
||||||
|
exec item
|
||||||
|
"call vimtap#Diag(item)
|
||||||
|
continue
|
||||||
|
endif
|
||||||
|
if item =~ '^-\{80}$'
|
||||||
|
let expect = 0
|
||||||
|
endif
|
||||||
|
if expect
|
||||||
|
call add(expected, item)
|
||||||
|
continue
|
||||||
|
endif
|
||||||
|
let lines = getline(1, line('$'))
|
||||||
|
let passed = lines == expected
|
||||||
|
echom string(lines)
|
||||||
|
echom string(expected)
|
||||||
|
call vimtap#Is(lines, expected, header)
|
||||||
|
echom string(commands)
|
||||||
|
for cmd in commands
|
||||||
|
call vimtap#Diag(cmd)
|
||||||
|
endfor
|
||||||
|
let commands = []
|
||||||
|
let header = ''
|
||||||
|
let tcount += 1
|
||||||
|
endfor
|
||||||
|
call vimtest#Quit()
|
||||||
8
test/expand_space.txt
Normal file
8
test/expand_space.txt
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# Issue #95
|
||||||
|
new
|
||||||
|
let b:delimitMate_jump_expansion = 1
|
||||||
|
DelimitMateReload
|
||||||
|
exec "normal i( test)x"
|
||||||
|
================================================================================
|
||||||
|
( test )x
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
42
test/expand_space.vim
Normal file
42
test/expand_space.vim
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
let g:delimitMate_expand_space = 1
|
||||||
|
"DelimitMateReload
|
||||||
|
let lines = readfile(expand('<sfile>:t:r').'.txt')
|
||||||
|
call vimtest#StartTap()
|
||||||
|
let testsnumber = len(filter(copy(lines), 'v:val =~ ''^=\{80}$'''))
|
||||||
|
call vimtap#Plan(testsnumber)
|
||||||
|
let tcount = 1
|
||||||
|
let expect = 0
|
||||||
|
let evaluate = 0
|
||||||
|
for item in lines
|
||||||
|
if item =~ '^=\{80}$'
|
||||||
|
let expect = 1
|
||||||
|
let expected = []
|
||||||
|
continue
|
||||||
|
endif
|
||||||
|
|
||||||
|
if item =~ '^#\|^\s*$' && expect == 0
|
||||||
|
" A comment or empty line.
|
||||||
|
continue
|
||||||
|
endif
|
||||||
|
if ! expect
|
||||||
|
" A command.
|
||||||
|
exec item
|
||||||
|
call vimtap#Diag(item)
|
||||||
|
continue
|
||||||
|
endif
|
||||||
|
if item =~ '^-\{80}$'
|
||||||
|
let expect = 0
|
||||||
|
endif
|
||||||
|
if expect
|
||||||
|
call add(expected, item)
|
||||||
|
continue
|
||||||
|
endif
|
||||||
|
let lines = getline(1, line('$'))
|
||||||
|
let passed = lines == expected
|
||||||
|
echom string(lines)
|
||||||
|
echom string(expected)
|
||||||
|
call vimtap#Ok(passed, string(expected) .
|
||||||
|
\ (passed ? ' =' : ' !') . '= ' . string(lines))
|
||||||
|
let tcount += 1
|
||||||
|
endfor
|
||||||
|
call vimtest#Quit()
|
||||||
Reference in New Issue
Block a user