73 Commits
2.1 ... 2.4

Author SHA1 Message Date
Israel Chauca Fuentes
b9cea6312a Release 2.4 2010-07-29 18:20:13 -05:00
Israel Chauca Fuentes
1b37d60840 Behave nicely with iminsert and imsearch. Thanks to nailxx@github.com. 2010-07-20 13:27:28 -05:00
Israel Chauca Fuentes
a70aa5285e Doc fix. Missing quotes. 2010-07-20 13:23:41 -05:00
Israel Chauca Fuentes
2eba04961d Added note about abbreviations not being expanded. # 26 2010-07-15 19:20:09 -05:00
Israel Chauca Fuentes
3519f82f79 \<Right\> doesn\'t work under terminal. #25 2010-07-15 04:10:38 -05:00
Israel Chauca Fuentes
e9491e473c Reorder some logic. 2010-07-15 04:07:56 -05:00
Israel Chauca Fuentes
9e3075cff5 Changelog update. 2010-07-03 14:43:20 -05:00
Israel Chauca Fuentes
7c9ba95565 Doc update. 2010-06-28 19:08:27 -05:00
Israel Chauca Fuentes
3ae285424c Expand smart quotes to consider [:alnum:] to the right. 2010-06-28 15:20:32 -05:00
Israel Chauca Fuentes
fa1d3b3d6a Add option to allow nesting quotes. #24 2010-06-28 13:18:04 -05:00
Israel Chauca Fuentes
63f8c2af4f Add note to the docs about <S-BS> not working on terminal. 2010-06-26 13:29:16 -05:00
Israel Chauca Fuentes
29eb98d79d Sort results from Tests#Main(). 2010-06-25 15:18:45 -05:00
Israel Chauca Fuentes
5b004ca49d Comment formatting. 2010-06-25 15:17:51 -05:00
Israel Chauca Fuentes
34df78f8ab Fix vars scope. 2010-06-25 15:17:17 -05:00
Israel Chauca Fuentes
e234e45846 #23 and vars with wrong values. 2010-06-25 15:16:25 -05:00
Israel Chauca Fuentes
081ec279ed Rename internal vars to hide them from completion. 2010-06-25 15:10:50 -05:00
Israel Chauca Fuentes
4399fa327f Doc corrections. 2010-06-23 12:53:58 -05:00
Israel Chauca Fuentes
ceaa6e01ed Deleted IsBlockVisual(). 2010-06-23 12:53:16 -05:00
Israel Chauca Fuentes
235f0dcbfb Fixed duplicate <silent>. 2010-06-23 12:52:18 -05:00
Israel Chauca Fuentes
fadd7fefbc Merge http://github.com/Lokaltog/delimitMate
Conflicts:
	autoload/delimitMate.vim
2010-06-22 21:25:05 -05:00
Israel Chauca Fuentes
193b6027c2 Fix #23. 2010-06-22 21:01:03 -05:00
Kim Silkebækken
a76439a641 Make all mappings silent
This change speeds up vim significantly in a terminal, and prevents the
annoying flickering of commands while typing.
2010-06-20 02:06:23 +02:00
Israel Chauca Fuentes
89cc598217 Update README. 2010-06-16 02:18:52 -05:00
Israel Chauca Fuentes
28ce6213fc Cosmetic changes. 2010-06-16 01:54:58 -05:00
Israel Chauca Fuentes
6d1f48c1bf Fix TestMappings(). 2010-06-16 01:54:40 -05:00
Israel Chauca Fuentes
0e20bcaff8 Use "fork" to open new gvim when testing. 2010-06-16 01:51:53 -05:00
Israel Chauca Fuentes
aae61ad8ba Use 'nomore'. 2010-06-16 01:50:33 -05:00
Israel Chauca Fuentes
4dac6ce6ac Fix TestMappings(). 2010-06-16 01:47:42 -05:00
Israel Chauca Fuentes
875a9e450b Silence some noise on UnMap(). 2010-06-16 01:45:40 -05:00
Israel Chauca Fuentes
48d2e3b9d1 Check for 'backspace' when <CR> expansion is enabled. 2010-06-16 01:44:11 -05:00
Israel Chauca Fuentes
5626a633d5 Escape \\ on options. 2010-06-16 01:40:55 -05:00
Israel Chauca Fuentes
3652ba24e3 Split Init() and simplify the set-up process. 2010-06-16 01:37:08 -05:00
Israel Chauca Fuentes
740fc90ae7 Expansion documentation and intialization fixed. 2010-06-12 22:50:14 -05:00
Israel Chauca Fuentes
e0de2dbf39 Use internal b:vars to read from user options. 2010-06-12 22:15:26 -05:00
Israel Chauca Fuentes
efcf9eb341 Formatting. 2010-06-12 12:28:50 -05:00
Israel Chauca Fuentes
2545fa5967 Reset autocmds on re-loading. 2010-06-12 12:26:30 -05:00
Israel Chauca Fuentes
c91674eed2 Doc update. 2010-06-09 19:10:29 -05:00
Israel Chauca Fuentes
542728671e Fix issue #21. 2010-06-09 12:32:57 -05:00
Israel Chauca Fuentes
d1621b6672 Block-wise visual wrapping works with limitations. 2010-06-09 03:20:11 -05:00
Israel Chauca Fuentes
6d1cc1187b Fixed issue #18 for non xterm terminals. 2010-06-08 21:54:22 -05:00
Israel Chauca Fuentes
377c3a37e1 Do not close on unbalanced parens. 2010-06-08 00:48:34 -05:00
Israel Chauca Fuentes
d03324135c Rename and reorder some function, update doc. 2010-06-07 00:54:55 -05:00
Israel Chauca Fuentes
edeaff4730 Missing quote. 2010-06-06 13:51:31 -05:00
Israel Chauca Fuentes
c85fee6eb5 README update. 2010-06-06 13:28:47 -05:00
Israel Chauca Fuentes
0ccb143a12 Doc and version update. 2010-06-06 13:22:14 -05:00
Israel Chauca Fuentes
941beed3b3 Extend detection of version string in Makefile. 2010-06-06 13:16:55 -05:00
Israel Chauca Fuentes
739a3e606c Fix: extra space inserted after <Space> expansion. 2010-06-06 02:51:30 -05:00
Israel Chauca Fuentes
61cc934b68 Give some feedback for commands. 2010-06-06 02:35:15 -05:00
Israel Chauca Fuentes
7aec4532f9 Change log update and minor doc edits. 2010-06-06 00:41:09 -05:00
Israel Chauca Fuentes
6f22aab0b8 Minor changes. 2010-06-06 00:01:23 -05:00
Israel Chauca Fuentes
592cf2fea1 Fix arrow keys on terminal, #18. 2010-06-02 22:34:01 -05:00
Israel Chauca Fuentes
3d818560eb README update. 2010-05-24 22:16:23 -05:00
Israel Chauca Fuentes
da66a3f7c9 Syntax awareness. 2010-05-24 22:11:23 -05:00
Israel Chauca Fuentes
e5ce5b0967 Fix: automatic indent was broken when expanding <CR>. 2010-05-23 14:29:50 -05:00
Israel Chauca Fuentes
03342b8d22 Makefile update. 2010-05-16 23:59:48 -05:00
Israel Chauca Fuentes
86c1895ceb Small corrections. 2010-05-16 22:55:17 -05:00
Israel Chauca Fuentes
fd4fb482fe Little updates. 2010-05-16 22:19:11 -05:00
Israel Chauca Fuentes
0fbbc0f808 Makefile rewrite. 2010-05-16 22:11:09 -05:00
Israel Chauca Fuentes
ced80ebb21 Doc corrections. 2010-05-16 18:30:18 -05:00
Israel Chauca Fuentes
7b0d9367b2 README file added. 2010-05-16 18:05:45 -05:00
Israel Chauca Fuentes
37512d7f89 Doc update. 2010-05-15 17:41:06 -05:00
Israel Chauca Fuentes
f8b5bbe555 Doc update about b:vars in vimrc. 2010-05-15 17:29:57 -05:00
Israel Chauca Fuentes
698b3f1e43 Doc correction. 2010-05-14 03:19:46 -05:00
Israel Chauca Fuentes
bdf477de4b Doc update 2010-05-13 20:14:06 -05:00
Israel Chauca Fuentes
b03d5dce36 More changes to Tests.vim. 2010-05-13 18:00:51 -05:00
Israel Chauca Fuentes
03390cfb5f Small changes to Tests.vim. 2010-05-13 15:44:04 -05:00
Israel Chauca Fuentes
45c66a4d07 Fix no autoclose at start of line replaces right char. 2010-05-13 15:27:36 -05:00
Israel Chauca Fuentes
a317b6ead7 A couple of updates. 2010-05-12 20:33:43 -05:00
Israel Chauca Fuentes
ed672dd39b Fix duplicate closing delimiter after <CR> 2010-05-12 19:57:48 -05:00
Israel Chauca Fuentes
72e639ff1a Fix #17 <Left> didn't work. 2010-05-11 13:22:51 -05:00
Israel Chauca Fuentes
95c899f3e2 Fix #16 Finish() didn't reset the char buffer. 2010-05-11 09:58:17 -05:00
Israel Chauca Fuentes
6d4113e3c3 Updated documentation about switch command. 2010-05-11 01:40:15 -05:00
Israel Chauca Fuentes
8d720b8932 Implemented command to switch on/off. 2010-05-11 01:27:40 -05:00
7 changed files with 1598 additions and 524 deletions

3
.gitignore vendored
View File

@@ -1,5 +1,8 @@
*.sw?
*.un?
*.vba
*.zip
*.gz
vimball.txt
*.orig
tags

View File

@@ -1,29 +1,72 @@
PLUGIN=delimitMate
PLUGIN=$(shell basename "$$PWD")
SCRIPT=$(wildcard plugin/*.vim)
#AUTOL=$(wildcard autoload/*.vim)
AUTOL=autoload/$(PLUGIN).vim
DOC=$(wildcard doc/*.txt)
TESTS=$(wildcard autoload/*Tests.vim)
VERSION=$(shell perl -ne 'if (/\*\sCurrent\srelease:/) {s/^\s+(\d+\.\S+)\s.*$$/\1/;print}' $(DOC))
VIMFOLDER=~/.vim/
VIM=/usr/bin/vim
install:
install -m 755 -d ~/.vim
install -m 755 -d ~/.vim/plugin/
install -m 755 -d ~/.vim/autoload/
install -m 755 -d ~/.vim/doc/
cp -f doc/${PLUGIN}.txt ~/.vim/doc/${PLUGIN}.txt
cp -f plugin/${PLUGIN}.vim ~/.vim/plugin/${PLUGIN}.vim
cp -f autoload/${PLUGIN}.vim ~/.vim/autoload/${PLUGIN}.vim
cp -f autoload/${PLUGIN}Tests.vim ~/.vim/autoload/${PLUGIN}Tests.vim
.PHONY: $(PLUGIN).vba README
doc_update: install
/usr/bin/vim -u NONE -c ':helptags ~/.vim/doc' -c ':q'
#install: vimball
#@echo install
#$(VIM) -N -c ':so %' -c':q!' $(PLUGIN)-$(VERSION).vba
#cp -f $(TESTS) $(VIMFOLDER)$(TESTS)
all: vimball README zip gzip
vimball: $(PLUGIN).vba
clean:
@echo clean
rm -f *.vba */*.orig *.~* .VimballRecord *.zip *.gz
dist-clean: clean
#uninstall:
#@echo uninstall
#$(VIM) -N -c':RmVimball' -c':q!' $(PLUGIN)-$(VERSION).vba
#rm -f $(VIMFOLDER)$(TESTS)
undo:
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:
zip -r ${PLUGIN}.zip doc plugin autoload
zip ${PLUGIN}.zip -d \*.sw\?
zip ${PLUGIN}.zip -d autoload/${PLUGIN}Tests.vim
vimball: install
echo doc/${PLUGIN}.txt > vimball.txt
echo plugin/${PLUGIN}.vim >> vimball.txt
echo autoload/${PLUGIN}.vim >> vimball.txt
/usr/bin/vim -c 'e vimball.txt' -c '%MkVimball! ${PLUGIN}' -c 'q'
@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
gzip -f ${PLUGIN}.vba
@echo vimball
gzip -f $(PLUGIN).vba
release: version all
version:
@echo version: $(VERSION)
perl -i.orig -pne 'if (/^"\sVersion:/) {s/(\d+\.\S+)/$(VERSION)/}' $(SCRIPT) $(AUTOL)
perl -i.orig -pne 'if (/let\sdelimitMate_version/) {s/"(\d+\.\S+)"/"$(VERSION)"/}' $(SCRIPT)
perl -i.orig -pne 'if (/beasts/) {s/(v\d+\.\S+)/v$(VERSION)/}' $(DOC)
perl -i.orig -MPOSIX -pne 'if (/^"\sModified:/) {$$now_string = strftime "%F", localtime; s/(\d+-\d+-\d+)/$$now_string/e}' $(SCRIPT) $(AUTOL)
perl -i.orig -MPOSIX -pne 'if (/^\s+$(VERSION)\s+\d+-\d+-\d+\s+\*/) {$$now_string = strftime "%F", localtime; s/(\d+-\d+-\d+)/$$now_string/}' $(DOC)
@echo Version: $(VERSION)
echo:

699
README Normal file
View File

@@ -0,0 +1,699 @@
*delimitMate* Trying to keep those beasts at bay! v2.4 *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 FileType based configuration_______|delimitMateFileType|
2.7 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 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.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.
==============================================================================
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_excluded_ft'| Turns off the script for the given file types.
|'delimitMate_excluded_regions'|Turns off the script for the given regions or
syntax group names.
|'delimitMate_apostrophes'| Tells delimitMate how it should "fix"
balancing of single quotes when used as
apostrophes. NOTE: Not needed any more, kept
for compatibility with older versions.
|'delimitMate_smart_quotes'| Turns on/off the "smart quotes" feature.
------------------------------------------------------------------------------
3.2 OPTIONS DETAILS *delimitMateOptionDetails*
Add the shown lines to your vimrc file in order to set the below options.
Buffer variables take precedence over global ones and can be used along with
autocmd to modify delimitMate's behavior for specific file types, read more in
|delimitMateFileType|.
Note: Use buffer variables only to set options for specific file types using
:autocmd, use global variables to set options for every buffer. Read more in
|g:var| and |b:var|.
------------------------------------------------------------------------------
*'loaded_delimitMate'*
*'b:loaded_delimitMate'*
This option prevents delimitMate from loading.
e.g.: >
let loaded_delimitMate = 1
au FileType mail let b:loaded_delimitMate = 1
<
------------------------------------------------------------------------------
*'delimitMate_autoclose'*
*'b:delimitMate_autoclose'*
Values: 0 or 1. ~
Default: 1 ~
If this option is set to 0, delimitMate will not add a closing delimiter
automagically. See |delimitMateAutoClose| for details.
e.g.: >
let delimitMate_autoclose = 0
au FileType mail let b:delimitMate_autoclose = 0
<
------------------------------------------------------------------------------
*'delimitMate_matchpairs'*
*'b:delimitMate_matchpairs'*
Values: A string with |'matchpairs'| syntax. ~
Default: &matchpairs ~
Use this option to tell delimitMate which characters should be considered
matching pairs. Read |delimitMateAutoClose| for details.
e.g: >
let delimitMate_matchpairs = "(:),[:],{:},<:>"
au FileType vim,html let b:delimitMate_matchpairs = "(:),[:],{:},<:>"
<
------------------------------------------------------------------------------
*'delimitMate_quotes'*
*'b:delimitMate_quotes'*
Values: A string of characters separated by spaces. ~
Default: "\" ' `" ~
Use this option to tell delimitMate which characters should be considered as
quotes. Read |delimitMateAutoClose| for details.
e.g.: >
let 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_quotes = ['"','`']
au FileType python let b:delimitMate_quotes = ['"']
<
------------------------------------------------------------------------------
*'delimitMate_visual_leader'*
*'b:delimitMate_visual_leader'*
Values: Any character. ~
Default: q ~
The value of this option will be used to wrap the selection in visual mode
when followed by a delimiter. Read |delimitMateVisualWrap| for details.
e.g: >
let delimitMate_visual_leader = "f"
au FileType html let b:delimitMate_visual_leader = "f"
<
------------------------------------------------------------------------------
*'delimitMate_expand_cr'*
*'b:delimitMate_expand_cr'*
Values: 1 or 0 ~
Default: 0 ~
This option turns on/off the expansion of <CR>. Read |delimitMateExpansion|
for details.
e.g.: >
let 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_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_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_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 2010-07-29 * Current release:
- 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:

View File

@@ -1,38 +1,170 @@
" ============================================================================
" File: autoload/delimitMate.vim
" Version: 2.1
" Version: 2.4
" Modified: 2010-07-29
" Description: This plugin provides auto-completion for quotes, parens, etc.
" Maintainer: Israel Chauca F. <israelchauca@gmail.com>
" Manual: Read ":help delimitMate".
" Utilities {{{
function! delimitMate#option_init(name, default) "{{{
let b = exists("b:delimitMate_" . a:name)
let g = exists("g:delimitMate_" . a:name)
let prefix = "_l_delimitMate_"
if !b && !g
let sufix = a:default
elseif !b && g
exec "let sufix = g:delimitMate_" . a:name
else
exec "let sufix = b:delimitMate_" . a:name
endif
if exists("b:" . prefix . a:name)
exec "unlockvar! b:" . prefix . a:name
endif
exec "let b:" . prefix . a:name . " = " . string(sufix)
exec "lockvar! b:" . prefix . a:name
endfunction "}}}
function! delimitMate#Init() "{{{
" Initialize variables:
" autoclose
call delimitMate#option_init("autoclose", 1)
" matchpairs
call delimitMate#option_init("matchpairs", string(&matchpairs)[1:-2])
call delimitMate#option_init("matchpairs_list", split(b:_l_delimitMate_matchpairs, ','))
call delimitMate#option_init("left_delims", split(b:_l_delimitMate_matchpairs, ':.,\='))
call delimitMate#option_init("right_delims", split(b:_l_delimitMate_matchpairs, ',\=.:'))
" quotes
call delimitMate#option_init("quotes", "\" ' `")
call delimitMate#option_init("quotes_list", split(b:_l_delimitMate_quotes))
" nesting_quotes
call delimitMate#option_init("nesting_quotes", [])
" excluded_regions
call delimitMate#option_init("excluded_regions", "Comment")
call delimitMate#option_init("excluded_regions_list", split(b:_l_delimitMate_excluded_regions, ',\s*'))
let enabled = len(b:_l_delimitMate_excluded_regions_list) > 0
call delimitMate#option_init("excluded_regions_enabled", enabled)
" visual_leader
let leader = exists('b:maplocalleader') ? b:maplocalleader :
\ exists('g:mapleader') ? g:mapleader : "\\"
call delimitMate#option_init("visual_leader", leader)
" 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 delimitMate#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'
echom "delimitMate: In order to use the <CR> expansion, you need to have 'eol' and 'start' in your backspace option. Read :help 'backspace'."
let b:delimitMate_expand_cr = 0
endif
call delimitMate#option_init("expand_cr", 0)
" smart_quotes
call delimitMate#option_init("smart_quotes", 1)
" apostrophes
call delimitMate#option_init("apostrophes", "")
call delimitMate#option_init("apostrophes_list", split(b:_l_delimitMate_apostrophes, ":\s*"))
" tab2exit
call delimitMate#option_init("tab2exit", 1)
" unbalanced_parens
call delimitMate#option_init("unbalanced_parens", 0)
let b:_l_delimitMate_buffer = []
let b:loaded_delimitMate = 1
endfunction "}}} Init()
function! delimitMate#Map() "{{{
" Set mappings:
try
let save_cpo = &cpo
let save_keymap = &keymap
let save_iminsert = &iminsert
let save_imsearch = &imsearch
set keymap=
set cpo&vim
if b:_l_delimitMate_autoclose
call delimitMate#AutoClose()
else
call delimitMate#NoAutoClose()
endif
call delimitMate#VisualMaps()
call delimitMate#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! delimitMate#ShouldJump() "{{{
" Returns 1 if the next character is a closing delimiter.
let col = col('.')
let lcol = col('$')
let char = getline('.')[col - 1]
let nchar = getline('.')[col]
let uchar = getline(line('.') + 1)[0]
for cdel in b:delimitMate_right_delims + b:delimitMate_quotes_list
" Closing delimiter on the right.
for cdel in b:_l_delimitMate_right_delims + b:_l_delimitMate_quotes_list
if char == cdel
" Closing delimiter on the right.
return 1
endif
endfor
if b:delimitMate_expand_space && char == " "
for cdel in b:delimitMate_right_delims + b:delimitMate_quotes_list
" Closing delimiter with space expansion.
let nchar = getline('.')[col]
if b:_l_delimitMate_expand_space && char == " "
for cdel in b:_l_delimitMate_right_delims + b:_l_delimitMate_quotes_list
if nchar == cdel
" Closing delimiter with space expansion.
return 1
endif
endfor
endif
if b:delimitMate_expand_cr && char == ""
for cdel in b:delimitMate_right_delims + b:delimitMate_quotes_list
" Closing delimiter with CR expansion.
let uchar = getline(line('.') + 1)[0]
if b:_l_delimitMate_expand_cr && char == ""
for cdel in b:_l_delimitMate_right_delims + b:_l_delimitMate_quotes_list
if uchar == cdel
" Closing delimiter with CR expansion.
return 1
endif
endfor
@@ -41,71 +173,54 @@ function! delimitMate#ShouldJump() "{{{
return 0
endfunction "}}}
function! delimitMate#IsBlockVisual() " {{{
if mode() == "\<C-V>"
return 1
endif
" Store unnamed register values for later use in delimitMate#RestoreRegister().
let b:save_reg = getreg('"')
let b:save_reg_mode = getregtype('"')
function! delimitMate#Visual(del) " {{{
if len(getline('.')) == 0
" This for proper wrap of empty lines.
let @" = "\n"
endif
return 0
endfunction " }}}
function! delimitMate#Visual(del) " {{{
" Let's find which kind of delimiter we got:
let index = index(b:_l_delimitMate_left_delims, a:del)
if index >= 0
let ld = a:del
let rd = b:_l_delimitMate_right_delims[index]
endif
let index = index(b:_l_delimitMate_right_delims, a:del)
if index >= 0
let ld = b:_l_delimitMate_left_delims[index]
let rd = a:del
endif
if index(b:_l_delimitMate_quotes_list, a:del) >= 0
let ld = a:del
let rd = ld
endif
let mode = mode()
if mode == "\<C-V>"
redraw
echom "delimitMate: delimitMate is disabled on blockwise visual mode."
return ""
endif
" Store unnamed register values for later use in delimitMate#RestoreRegister().
let b:save_reg = getreg('"')
let b:save_reg_mode = getregtype('"')
if len(getline('.')) == 0
" This for proper wrap of empty lines.
let @" = "\n"
endif
if mode ==# "V"
" Block-wise visual
return "I" . ld . "\<Esc>gv\<Right>A" . rd . "\<Esc>"
elseif mode ==# "V"
let dchar = "\<BS>"
else
let dchar = ""
endif
let index = index(b:delimitMate_left_delims, a:del)
if index >= 0
let ld = a:del
let rd = b:delimitMate_right_delims[index]
endif
let index = index(b:delimitMate_right_delims, a:del)
if index >= 0
let ld = b:delimitMate_left_delims[index]
let rd = a:del
endif
let index = index(b:delimitMate_quotes_list, a:del)
if index >= 0
let ld = a:del
let rd = ld
endif
" Store unnamed register values for later use in delimitMate#RestoreRegister().
let b:save_reg = getreg('"')
let b:save_reg_mode = getregtype('"')
return "s" . ld . "\<C-R>\"" . dchar . rd . "\<Esc>:call delimitMate#RestoreRegister()\<CR>"
endfunction " }}}
function! delimitMate#IsEmptyPair(str) "{{{
for pair in b:delimitMate_matchpairs_list
for pair in b:_l_delimitMate_matchpairs_list
if a:str == join( split( pair, ':' ),'' )
return 1
endif
endfor
for quote in b:delimitMate_quotes_list
for quote in b:_l_delimitMate_quotes_list
if a:str == quote . quote
return 1
endif
@@ -117,12 +232,12 @@ function! delimitMate#IsCRExpansion() " {{{
let nchar = getline(line('.')-1)[-1:]
let schar = getline(line('.')+1)[:0]
let isEmpty = getline('.') == ""
if index(b:delimitMate_left_delims, nchar) > -1 &&
\ index(b:delimitMate_left_delims, nchar) == index(b:delimitMate_right_delims, schar) &&
if index(b:_l_delimitMate_left_delims, nchar) > -1 &&
\ index(b:_l_delimitMate_left_delims, nchar) == index(b:_l_delimitMate_right_delims, schar) &&
\ isEmpty
return 1
elseif index(b:delimitMate_quotes_list, nchar) > -1 &&
\ index(b:delimitMate_quotes_list, nchar) == index(b:delimitMate_quotes_list, schar) &&
elseif index(b:_l_delimitMate_quotes_list, nchar) > -1 &&
\ index(b:_l_delimitMate_quotes_list, nchar) == index(b:_l_delimitMate_quotes_list, schar) &&
\ isEmpty
return 1
else
@@ -138,12 +253,12 @@ function! delimitMate#IsSpaceExpansion() " {{{
let nchar = line[col + 2]
let isSpaces = (line[col] == line[col+1] && line[col] == " ")
if index(b:delimitMate_left_delims, pchar) > -1 &&
\ index(b:delimitMate_left_delims, pchar) == index(b:delimitMate_right_delims, nchar) &&
if index(b:_l_delimitMate_left_delims, pchar) > -1 &&
\ index(b:_l_delimitMate_left_delims, pchar) == index(b:_l_delimitMate_right_delims, nchar) &&
\ isSpaces
return 1
elseif index(b:delimitMate_quotes_list, pchar) > -1 &&
\ index(b:delimitMate_quotes_list, pchar) == index(b:delimitMate_quotes_list, nchar) &&
elseif index(b:_l_delimitMate_quotes_list, pchar) > -1 &&
\ index(b:_l_delimitMate_quotes_list, pchar) == index(b:_l_delimitMate_quotes_list, nchar) &&
\ isSpaces
return 1
endif
@@ -181,13 +296,21 @@ function! delimitMate#WriteAfter(str) "{{{
endfunction " }}}
function! delimitMate#RestoreRegister() " {{{
" Restore unnamed register values store in delimitMate#IsBlockVisual().
" Restore unnamed register values stored in delimitMate#Visual().
call setreg('"', b:save_reg, b:save_reg_mode)
echo ""
endfunction " }}}
function! delimitMate#GetSyntaxRegion(line, col) "{{{
return synIDattr(synIDtrans(synID(a:line, a:col, 1)), 'name')
endfunction " }}}
function! delimitMate#GetCurrentSyntaxRegion() "{{{
return synIDattr(synIDtrans(synID(line('.'), col('.'), 1)), 'name')
let col = col('.')
if col == col('$')
let col = col - 1
endif
return delimitMate#GetSyntaxRegion(line('.'), col)
endfunction " }}}
function! delimitMate#GetCurrentSyntaxRegionIf(char) "{{{
@@ -195,47 +318,166 @@ function! delimitMate#GetCurrentSyntaxRegionIf(char) "{{{
let origin_line = getline('.')
let changed_line = strpart(origin_line, 0, col - 1) . a:char . strpart(origin_line, col - 1)
call setline('.', changed_line)
let region = synIDattr(synIDtrans(synID(line('.'), col, 1)), 'name')
let region = delimitMate#GetSyntaxRegion(line('.'), col)
call setline('.', origin_line)
return region
endfunction "}}}
function! delimitMate#IsForbidden(char) "{{{
if b:delimitMate_excluded_regions_enabled = 0
if b:_l_delimitMate_excluded_regions_enabled == 0
return 0
endif
let result = index(b:delimitMate_excluded_regions_list, delimitMate#GetCurrentSyntaxRegion()) >= 0
if result >= 0
return result + 1
"let result = index(b:_l_delimitMate_excluded_regions_list, delimitMate#GetCurrentSyntaxRegion()) >= 0
if index(b:_l_delimitMate_excluded_regions_list, delimitMate#GetCurrentSyntaxRegion()) >= 0
"echom "Forbidden 1!"
return 1
endif
let region = delimitMate#GetCurrentSyntaxRegionIf(a:char)
let result = index(b:delimitMate_excluded_regions_list, region) >= 0
"let result = index(b:_l_delimitMate_excluded_regions_list, region) >= 0
"return result || region == 'Comment'
return result + 1
"echom "Forbidden 2!"
return index(b:_l_delimitMate_excluded_regions_list, region) >= 0
endfunction "}}}
function! delimitMate#FlushBuffer() " {{{
let b:delimitMate_buffer = []
let b:_l_delimitMate_buffer = []
return ''
endfunction " }}}
function! delimitMate#BalancedParens(char) "{{{
" Returns:
" = 0 => Parens balanced.
" > 0 => More opening parens.
" < 0 => More closing parens.
let line = getline('.')
let col = col('.') - 2
let col = col >= 0 ? col : 0
let list = split(line, '\zs')
let left = b:_l_delimitMate_left_delims[index(b:_l_delimitMate_right_delims, a:char)]
let right = a:char
let opening = 0
let closing = 0
" If the cursor is not at the beginning, count what's behind it.
if col > 0
" Find the first opening paren:
let start = index(list, left)
" Must be before cursor:
let start = start < col ? start : col - 1
" Now count from the first opening until the cursor, this will prevent
" extra closing parens from being counted.
let opening = count(list[start : col - 1], left)
let closing = count(list[start : col - 1], right)
" I don't care if there are more closing parens than opening parens.
let closing = closing > opening ? opening : closing
endif
" Evaluate parens from the cursor to the end:
let opening += count(list[col :], left)
let closing += count(list[col :], right)
"echom ""
"echom line
"echom col
""echom left.":".a:char
"echom string(list)
"echom string(list[start : col - 1]) . " : " . string(list[col :])
"echom opening . " - " . closing . " = " . (opening - closing)
" Return the found balance:
return opening - closing
endfunction "}}}
" }}}
" Doers {{{
function! delimitMate#JumpIn(char) " {{{
function! delimitMate#SkipDelim(char) "{{{
if delimitMate#IsForbidden(a:char)
return a:char
endif
let col = col('.') - 1
let line = getline('.')
if col > 0
let cur = line[col]
let pre = line[col-1]
else
let cur = line[col]
let pre = ""
endif
if pre == "\\"
" Escaped character
return a:char
elseif cur == a:char
" Exit pair
"return delimitMate#WriteBefore(a:char)
return a:char . delimitMate#Del()
elseif delimitMate#IsEmptyPair( pre . a:char )
" Add closing delimiter and jump back to the middle.
call insert(b:_l_delimitMate_buffer, a:char)
return delimitMate#WriteAfter(a:char)
else
" Nothing special here, return the same character.
return a:char
endif
endfunction "}}}
function! delimitMate#ParenDelim(char) " {{{
if delimitMate#IsForbidden(a:char)
return ''
endif
if b:_l_delimitMate_unbalanced_parens &&
\ delimitMate#BalancedParens(a:char) <= 0
return ''
endif
let line = getline('.')
let col = col('.')-2
if (col) < 0
call setline('.',a:char.line)
call insert(b:delimitMate_buffer, a:char)
call insert(b:_l_delimitMate_buffer, a:char)
else
"echom string(col).':'.line[:(col)].'|'.line[(col+1):]
call setline('.',line[:(col)].a:char.line[(col+1):])
call insert(b:delimitMate_buffer, a:char)
call insert(b:_l_delimitMate_buffer, a:char)
endif
return ''
endfunction " }}}
function! delimitMate#QuoteDelim(char) "{{{
if delimitMate#IsForbidden(a:char)
return a:char
endif
let line = getline('.')
let col = col('.') - 2
if line[col] == "\\"
" Seems like a escaped character, insert one quotation mark.
return a:char
elseif line[col + 1] == a:char &&
\ index(b:_l_delimitMate_nesting_quotes, a:char) < 0
" Get out of the string.
return a:char . delimitMate#Del()
elseif (line[col] =~ '[[:alnum:]]' && a:char == "'") ||
\ (b:_l_delimitMate_smart_quotes &&
\ (line[col] =~ '[[:alnum:]]' ||
\ line[col + 1] =~ '[[:alnum:]]'))
" Seems like an apostrophe or a smart quote case, insert a single quote.
return a:char
elseif (line[col] == a:char && line[col + 1 ] != a:char) && b:_l_delimitMate_smart_quotes
" Seems like we have an unbalanced quote, insert one quotation mark and jump to the middle.
call insert(b:_l_delimitMate_buffer, a:char)
return delimitMate#WriteAfter(a:char)
else
" Insert a pair and jump to the middle.
call insert(b:_l_delimitMate_buffer, a:char)
call delimitMate#WriteAfter(a:char)
return a:char
endif
endfunction "}}}
function! delimitMate#JumpOut(char) "{{{
if delimitMate#IsForbidden(a:char)
return a:char
endif
let line = getline('.')
let col = col('.')-2
if line[col+1] == a:char
@@ -245,7 +487,13 @@ function! delimitMate#JumpOut(char) "{{{
endif
endfunction " }}}
function! delimitMate#JumpAny() " {{{
function! delimitMate#JumpAny(key) " {{{
if delimitMate#IsForbidden('')
return a:key
endif
if !delimitMate#ShouldJump()
return a:key
endif
" Let's get the character on the right.
let char = getline('.')[col('.')-1]
if char == " "
@@ -256,7 +504,7 @@ function! delimitMate#JumpAny() " {{{
elseif char == ""
" CR expansion.
"let char = "\<CR>" . getline(line('.') + 1)[0] . "\<Del>"
let b:delimitMate_buffer = []
let b:_l_delimitMate_buffer = []
return "\<CR>" . getline(line('.') + 1)[0] . "\<Del>"
else
"call delimitMate#RmBuffer(1)
@@ -264,54 +512,6 @@ function! delimitMate#JumpAny() " {{{
endif
endfunction " delimitMate#JumpAny() }}}
function! delimitMate#SkipDelim(char) "{{{
let cur = strpart( getline('.'), col('.')-2, 3 )
if cur[0] == "\\"
" Escaped character
return a:char
elseif cur[1] == a:char
" Exit pair
"return delimitMate#WriteBefore(a:char)
return a:char . delimitMate#Del()
"elseif cur[1] == ' ' && cur[2] == a:char
"" I'm leaving this in case someone likes it. Jump an space and delimiter.
"return "\<Right>\<Right>"
elseif delimitMate#IsEmptyPair( cur[0] . a:char )
" Add closing delimiter and jump back to the middle.
call insert(b:delimitMate_buffer, a:char)
return delimitMate#WriteAfter(a:char)
else
" Nothing special here, return the same character.
return a:char
endif
endfunction "}}}
function! delimitMate#QuoteDelim(char) "{{{
let line = getline('.')
let col = col('.') - 2
if line[col] == "\\"
" Seems like a escaped character, insert one quotation mark.
return a:char
elseif line[col + 1] == a:char
" Get out of the string.
"return delimitMate#WriteBefore(a:char)
return a:char . delimitMate#Del()
elseif (line[col] =~ '[a-zA-Z0-9]' && a:char == "'") ||
\(line[col] =~ '[a-zA-Z0-9]' && b:delimitMate_smart_quotes)
" Seems like an apostrophe or a closing, insert a single quote.
return a:char
elseif (line[col] == a:char && line[col + 1 ] != a:char) && b:delimitMate_smart_quotes
" Seems like we have an unbalanced quote, insert one quotation mark and jump to the middle.
call insert(b:delimitMate_buffer, a:char)
return delimitMate#WriteAfter(a:char)
else
" Insert a pair and jump to the middle.
call insert(b:delimitMate_buffer, a:char)
call delimitMate#WriteAfter(a:char)
return a:char
endif
endfunction "}}}
function! delimitMate#MapMsg(msg) "{{{
redraw
echomsg a:msg
@@ -319,21 +519,26 @@ function! delimitMate#MapMsg(msg) "{{{
endfunction "}}}
function! delimitMate#ExpandReturn() "{{{
if delimitMate#WithinEmptyPair() &&
\ b:delimitMate_expand_cr
if delimitMate#IsForbidden("")
return "\<CR>"
endif
if delimitMate#WithinEmptyPair()
" Expand:
call delimitMate#FlushBuffer()
return "\<Esc>a\<CR>x\<CR>\<Esc>k$\"_xa"
"return "\<Esc>a\<CR>x\<CR>\<Esc>k$\"_xa"
return "\<CR>\<UP>\<Esc>o"
else
return "\<CR>"
endif
endfunction "}}}
function! delimitMate#ExpandSpace() "{{{
if delimitMate#WithinEmptyPair() &&
\ b:delimitMate_expand_space
if delimitMate#IsForbidden("\<Space>")
return "\<Space>"
endif
if delimitMate#WithinEmptyPair()
" Expand:
call insert(b:delimitMate_buffer, 's')
call insert(b:_l_delimitMate_buffer, 's')
return delimitMate#WriteAfter(' ') . "\<Space>"
else
return "\<Space>"
@@ -341,16 +546,17 @@ function! delimitMate#ExpandSpace() "{{{
endfunction "}}}
function! delimitMate#BS() " {{{
if delimitMate#IsForbidden("")
return "\<BS>"
endif
if delimitMate#WithinEmptyPair()
"call delimitMate#RmBuffer(1)
return "\<BS>" . delimitMate#Del()
" return "\<Right>\<BS>\<BS>"
elseif b:delimitMate_expand_space &&
\ delimitMate#IsSpaceExpansion()
elseif delimitMate#IsSpaceExpansion()
"call delimitMate#RmBuffer(1)
return "\<BS>" . delimitMate#Del()
elseif b:delimitMate_expand_cr &&
\ delimitMate#IsCRExpansion()
elseif delimitMate#IsCRExpansion()
return "\<BS>\<Del>"
else
return "\<BS>"
@@ -358,7 +564,7 @@ function! delimitMate#BS() " {{{
endfunction " }}} delimitMate#BS()
function! delimitMate#Del() " {{{
if len(b:delimitMate_buffer) > 0
if len(b:_l_delimitMate_buffer) > 0
let line = getline('.')
let col = col('.') - 2
call delimitMate#RmBuffer(1)
@@ -370,15 +576,21 @@ function! delimitMate#Del() " {{{
endfunction " }}}
function! delimitMate#Finish() " {{{
let len = len(b:delimitMate_buffer)
let len = len(b:_l_delimitMate_buffer)
if len > 0
let buffer = join(b:delimitMate_buffer, '')
let buffer = join(b:_l_delimitMate_buffer, '')
" Reset buffer:
let b:_l_delimitMate_buffer = []
let line = getline('.')
let col = col('.') -2
"echom 'col: ' . col . '-' . line[:col] . "|" . line[col+len+1:] . '%' . buffer
call setline('.', line[:col] . line[col+len+1:])
if col < 0
call setline('.', line[col+len+1:])
else
call setline('.', line[:col] . line[col+len+1:])
endif
let i = 1
let lefts = ''
let lefts = "\<Left>"
while i < len
let lefts = lefts . "\<Left>"
let i += 1
@@ -389,8 +601,8 @@ function! delimitMate#Finish() " {{{
endfunction " }}}
function! delimitMate#RmBuffer(num) " {{{
if len(b:delimitMate_buffer) > 0
call remove(b:delimitMate_buffer, 0, (a:num-1))
if len(b:_l_delimitMate_buffer) > 0
call remove(b:_l_delimitMate_buffer, 0, (a:num-1))
endif
return ""
endfunction " }}}
@@ -400,101 +612,107 @@ endfunction " }}}
" Mappers: {{{
function! delimitMate#NoAutoClose() "{{{
" inoremap <buffer> ) <C-R>=delimitMate#SkipDelim('\)')<CR>
for delim in b:delimitMate_right_delims + b:delimitMate_quotes_list
exec 'inoremap <buffer> ' . delim . ' <C-R>=delimitMate#SkipDelim("' . escape(delim,'"') . '")<CR>'
for delim in b:_l_delimitMate_right_delims + b:_l_delimitMate_quotes_list
exec 'inoremap <silent> <buffer> ' . delim . ' <C-R>=delimitMate#SkipDelim("' . escape(delim,'"\|') . '")<CR>'
endfor
endfunction "}}}
function! delimitMate#AutoClose() "{{{
" Add matching pair and jump to the midle:
" inoremap <buffer> ( ()<Left>
" inoremap <silent> <buffer> ( ()<Left>
let i = 0
while i < len(b:delimitMate_matchpairs_list)
let ld = b:delimitMate_left_delims[i]
let rd = b:delimitMate_right_delims[i]
exec 'inoremap <buffer> ' . ld . ' ' . ld . '<C-R>=delimitMate#JumpIn("' . rd . '")<CR>'
while i < len(b:_l_delimitMate_matchpairs_list)
let ld = b:_l_delimitMate_left_delims[i]
let rd = b:_l_delimitMate_right_delims[i]
exec 'inoremap <silent> <buffer> ' . ld . ' ' . ld . '<C-R>=delimitMate#ParenDelim("' . rd . '")<CR>'
let i += 1
endwhile
" Exit from inside the matching pair:
for delim in b:delimitMate_right_delims
exec 'inoremap <buffer> ' . delim . ' <C-R>=delimitMate#JumpOut("\' . delim . '")<CR>'
for delim in b:_l_delimitMate_right_delims
exec 'inoremap <silent> <buffer> ' . delim . ' <C-R>=delimitMate#JumpOut("\' . delim . '")<CR>'
endfor
" Add matching quote and jump to the midle, or exit if inside a pair of matching quotes:
" inoremap <buffer> " <C-R>=delimitMate#QuoteDelim("\"")<CR>
for delim in b:delimitMate_quotes_list
exec 'inoremap <buffer> ' . delim . ' <C-R>=delimitMate#QuoteDelim("\' . delim . '")<CR>'
" inoremap <silent> <buffer> " <C-R>=delimitMate#QuoteDelim("\"")<CR>
for delim in b:_l_delimitMate_quotes_list
exec 'inoremap <silent> <buffer> ' . delim . ' <C-R>=delimitMate#QuoteDelim("\' . delim . '")<CR>'
endfor
" Try to fix the use of apostrophes (de-activated by default):
" inoremap <buffer> n't n't
for map in b:delimitMate_apostrophes_list
exec "inoremap <buffer> " . map . " " . map
" inoremap <silent> <buffer> n't n't
for map in b:_l_delimitMate_apostrophes_list
exec "inoremap <silent> <buffer> " . map . " " . map
endfor
endfunction "}}}
function! delimitMate#VisualMaps() " {{{
let VMapMsg = "delimitMate: delimitMate is disabled on blockwise visual mode."
let vleader = b:delimitMate_visual_leader
let vleader = b:_l_delimitMate_visual_leader
" Wrap the selection with matching pairs, but do nothing if blockwise visual mode is active:
for del in b:delimitMate_right_delims + b:delimitMate_left_delims + b:delimitMate_quotes_list
exec "vnoremap <buffer> <expr> " . vleader . del . ' delimitMate#Visual("' . escape(del, '")') . '")'
for del in b:_l_delimitMate_right_delims + b:_l_delimitMate_left_delims + b:_l_delimitMate_quotes_list
exec "vnoremap <silent> <buffer> <expr> " . vleader . del . ' delimitMate#Visual("' . escape(del, '")') . '")'
endfor
endfunction "}}}
function! delimitMate#ExtraMappings() "{{{
" If pair is empty, delete both delimiters:
inoremap <buffer> <BS> <C-R>=delimitMate#BS()<CR>
inoremap <silent> <buffer> <BS> <C-R>=delimitMate#BS()<CR>
" If pair is empty, delete closing delimiter:
inoremap <buffer> <expr> <S-BS> delimitMate#WithinEmptyPair() ? "\<Del>" : "\<S-BS>"
inoremap <silent> <buffer> <expr> <S-BS> delimitMate#WithinEmptyPair() ? "\<C-R>=delimitMate#Del()\<CR>" : "\<S-BS>"
" Expand return if inside an empty pair:
if b:delimitMate_expand_cr != 0
inoremap <buffer> <expr> <CR> delimitMate#WithinEmptyPair() ? "\<C-R>=delimitMate#ExpandReturn()\<CR>" : "\<CR>"
if b:_l_delimitMate_expand_cr != 0
inoremap <silent> <buffer> <CR> <C-R>=delimitMate#ExpandReturn()<CR>
endif
" Expand space if inside an empty pair:
if b:delimitMate_expand_space != 0
inoremap <buffer> <expr> <Space> delimitMate#WithinEmptyPair() ? "\<C-R>=delimitMate#ExpandSpace()\<CR>" : "\<Space>"
if b:_l_delimitMate_expand_space != 0
inoremap <silent> <buffer> <Space> <C-R>=delimitMate#ExpandSpace()<CR>
endif
" Jump out ot any empty pair:
if b:delimitMate_tab2exit
inoremap <buffer> <expr> <S-Tab> delimitMate#ShouldJump() ? "\<C-R>=delimitMate#JumpAny()\<CR>" : "\<S-Tab>"
if b:_l_delimitMate_tab2exit
inoremap <silent> <buffer> <S-Tab> <C-R>=delimitMate#JumpAny("\<S-Tab>")<CR>
endif
" Fix the re-do feature:
inoremap <buffer> <Esc> <C-R>=delimitMate#Finish()<CR><Esc>
inoremap <silent> <buffer> <Esc> <C-R>=delimitMate#Finish()<CR><Esc>
" Flush the char buffer on mouse click:
inoremap <buffer> <LeftMouse> <C-R>=delimitMate#Finish()<CR><LeftMouse>
inoremap <buffer> <RightMouse> <C-R>=delimitMate#Finish()<CR><RightMouse>
inoremap <silent> <buffer> <LeftMouse> <C-R>=delimitMate#Finish()<CR><LeftMouse>
inoremap <silent> <buffer> <RightMouse> <C-R>=delimitMate#Finish()<CR><RightMouse>
" Flush the char buffer on key movements:
inoremap <buffer> <Left> <C-R>=delimitMate#Finish()<CR><Left>
inoremap <buffer> <Right> <C-R>=delimitMate#Finish()<CR><Right>
inoremap <buffer> <Up> <C-R>=delimitMate#Finish()<CR><Up>
inoremap <buffer> <Down> <C-R>=delimitMate#Finish()<CR><Down>
inoremap <silent> <buffer> <Left> <C-R>=delimitMate#Finish()<CR><Left>
inoremap <silent> <buffer> <Right> <C-R>=delimitMate#Finish()<CR><Right>
inoremap <silent> <buffer> <Up> <C-R>=delimitMate#Finish()<CR><Up>
inoremap <silent> <buffer> <Down> <C-R>=delimitMate#Finish()<CR><Down>
inoremap <buffer> <Del> <C-R>=delimitMate#Del()<CR>
inoremap <silent> <buffer> <Del> <C-R>=delimitMate#Del()<CR>
" The following simply creates an ambiguous mapping so vim fully processes
" the escape sequence for terminal keys, see 'ttimeout' for a rough
" explanation, this just forces it to work
if !has('gui_running')
imap <silent> <C-[>OC <RIGHT>
endif
endfunction "}}}
function! delimitMate#UnMap() " {{{
let imaps =
\ b:delimitMate_right_delims +
\ b:delimitMate_left_delims +
\ b:delimitMate_quotes_list +
\ b:delimitMate_apostrophes_list +
\ b:_l_delimitMate_right_delims +
\ b:_l_delimitMate_left_delims +
\ b:_l_delimitMate_quotes_list +
\ b:_l_delimitMate_apostrophes_list +
\ ['<BS>', '<S-BS>', '<Del>', '<CR>', '<Space>', '<S-Tab>', '<Esc>'] +
\ ['<Up>', '<Down>', '<Left>', '<Right>', '<LeftMouse>', '<RightMouse>']
let vmaps =
\ b:delimitMate_right_delims +
\ b:delimitMate_left_delims +
\ b:delimitMate_quotes_list
\ b:_l_delimitMate_right_delims +
\ b:_l_delimitMate_left_delims +
\ b:_l_delimitMate_quotes_list
for map in imaps
if maparg(map, "i") =~? 'delimitMate'
@@ -502,73 +720,80 @@ function! delimitMate#UnMap() " {{{
endif
endfor
if !exists("b:delimitMate_visual_leader")
if !exists("b:_l_delimitMate_visual_leader")
let vleader = ""
else
let vleader = b:delimitMate_visual_leader
let vleader = b:_l_delimitMate_visual_leader
endif
for map in vmaps
if maparg(vleader . map, "v") =~? "delimitMate"
exec 'silent! vunmap <buffer> ' . vleader . map
endif
endfor
if !has('gui_running')
silent! iunmap <C-[>OC
endif
let b:delimitMate_enabled = 0
endfunction " }}} delimitMate#UnMap()
"}}}
" Tools: {{{
function! delimitMate#TestMappings() "{{{
exec "normal i*b:delimitMate_autoclose = " . b:delimitMate_autoclose . "\<CR>"
exec "normal i*b:delimitMate_expand_space = " . b:delimitMate_expand_space . "\<CR>"
exec "normal i*b:delimitMate_expand_cr = " . b:delimitMate_expand_cr . "\<CR>\<CR>"
if b:delimitMate_autoclose
for i in range(len(b:delimitMate_left_delims))
exec "normal GGAOpen & close: " . b:delimitMate_left_delims[i]. "|"
exec "normal A\<CR>Delete: " . b:delimitMate_left_delims[i] . "\<BS>|"
exec "normal A\<CR>Exit: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . "|"
exec "normal A\<CR>Space: " . b:delimitMate_left_delims[i] . " |"
exec "normal A\<CR>Delete space: " . b:delimitMate_left_delims[i] . " \<BS>|"
exec "normal GGA\<CR>Visual-L: v\<Esc>v" . b:delimitMate_visual_leader . b:delimitMate_left_delims[i]
exec "normal A\<CR>Visual-R: v\<Esc>v" . b:delimitMate_visual_leader . b:delimitMate_right_delims[i]
exec "normal A\<CR>Car return: " . b:delimitMate_left_delims[i] . "\<CR>|"
exec "normal GGA\<CR>Delete car return: " . b:delimitMate_left_delims[i] . "\<CR>\<BS>|\<Esc>GGA\<CR>\<CR>"
exec "normal i*b:_l_delimitMate_autoclose = " . b:_l_delimitMate_autoclose . "\<Esc>o"
exec "normal i*b:_l_delimitMate_expand_space = " . b:_l_delimitMate_expand_space . "\<Esc>o"
exec "normal i*b:_l_delimitMate_expand_cr = " . b:_l_delimitMate_expand_cr . "\<Esc>o\<Esc>o"
echom b:_l_delimitMate_autoclose.b:_l_delimitMate_expand_space.b:_l_delimitMate_expand_cr
if b:_l_delimitMate_autoclose
" {{{
for i in range(len(b:_l_delimitMate_left_delims))
exec "normal GGoOpen & close: " . b:_l_delimitMate_left_delims[i]. "|"
exec "normal oDelete: " . b:_l_delimitMate_left_delims[i] . "\<BS>|"
exec "normal oExit: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . "|"
exec "normal oSpace: " . b:_l_delimitMate_left_delims[i] . " |"
exec "normal oDelete space: " . b:_l_delimitMate_left_delims[i] . " \<BS>|"
exec "normal GGoVisual-L: v\<Esc>v" . b:_l_delimitMate_visual_leader . b:_l_delimitMate_left_delims[i]
exec "normal oVisual-R: v\<Esc>v" . b:_l_delimitMate_visual_leader . b:_l_delimitMate_right_delims[i]
exec "normal oCar return: " . b:_l_delimitMate_left_delims[i] . "\<CR>|"
exec "normal GGoDelete car return: " . b:_l_delimitMate_left_delims[i] . "\<CR>\<BS>|\<Esc>GGA\<Esc>o\<Esc>o"
endfor
for i in range(len(b:delimitMate_quotes_list))
exec "normal GGAOpen & close: " . b:delimitMate_quotes_list[i] . "|"
exec "normal A\<CR>Delete: "
exec "normal A". b:delimitMate_quotes_list[i]
exec "normal a\<BS>|"
exec "normal A\<CR>Exit: " . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . "|"
exec "normal A\<CR>Space: " . b:delimitMate_quotes_list[i] . " |"
exec "normal A\<CR>Delete space: " . b:delimitMate_quotes_list[i] . " \<BS>|"
exec "normal GGA\<CR>Visual: v\<Esc>v" . b:delimitMate_visual_leader . b:delimitMate_quotes_list[i]
exec "normal A\<CR>Car return: " . b:delimitMate_quotes_list[i] . "\<CR>|"
exec "normal GGA\<CR>Delete car return: " . b:delimitMate_quotes_list[i] . "\<CR>\<BS>|\<Esc>GGA\<CR>\<CR>"
for i in range(len(b:_l_delimitMate_quotes_list))
exec "normal GGAOpen & close: " . b:_l_delimitMate_quotes_list[i] . "|"
exec "normal oDelete: "
exec "normal oExit: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "|"
exec "normal oSpace: " . b:_l_delimitMate_quotes_list[i] . " |"
exec "normal oDelete space: " . b:_l_delimitMate_quotes_list[i] . " \<BS>|"
exec "normal GGoVisual: v\<Esc>v" . b:_l_delimitMate_visual_leader . b:_l_delimitMate_quotes_list[i]
exec "normal oCar return: " . b:_l_delimitMate_quotes_list[i] . "\<CR>|"
exec "normal GGoDelete car return: " . b:_l_delimitMate_quotes_list[i] . "\<CR>\<BS>|\<Esc>GGA\<Esc>o\<Esc>o"
endfor
"}}}
else
for i in range(len(b:delimitMate_left_delims))
exec "normal GGAOpen & close: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . "|"
exec "normal A\<CR>Delete: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . "\<BS>|"
exec "normal A\<CR>Exit: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . b:delimitMate_right_delims[i] . "|"
exec "normal A\<CR>Space: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . " |"
exec "normal A\<CR>Delete space: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . " \<BS>|"
exec "normal GGA\<CR>Visual-L: v\<Esc>v" . b:delimitMate_visual_leader . b:delimitMate_left_delims[i]
exec "normal A\<CR>Visual-R: v\<Esc>v" . b:delimitMate_visual_leader . b:delimitMate_right_delims[i]
exec "normal A\<CR>Car return: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . "\<CR>|"
exec "normal GGA\<CR>Delete car return: " . b:delimitMate_left_delims[i] . b:delimitMate_right_delims[i] . "\<CR>\<BS>|\<Esc>GGA\<CR>\<CR>"
"{{{
for i in range(len(b:_l_delimitMate_left_delims))
exec "normal GGoOpen & close: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . "|"
exec "normal oDelete: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . "\<BS>|"
exec "normal oExit: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . b:_l_delimitMate_right_delims[i] . "|"
exec "normal oSpace: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . " |"
exec "normal oDelete space: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . " \<BS>|"
exec "normal GGoVisual-L: v\<Esc>v" . b:_l_delimitMate_visual_leader . b:_l_delimitMate_left_delims[i]
exec "normal oVisual-R: v\<Esc>v" . b:_l_delimitMate_visual_leader . b:_l_delimitMate_right_delims[i]
exec "normal oCar return: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . "\<CR>|"
exec "normal GGoDelete car return: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . "\<CR>\<BS>|\<Esc>GGA\<Esc>o\<Esc>o"
endfor
for i in range(len(b:delimitMate_quotes_list))
exec "normal GGAOpen & close: " . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . "|"
exec "normal A\<CR>Delete: " . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . "\<BS>|"
exec "normal A\<CR>Exit: " . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . "|"
exec "normal A\<CR>Space: " . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . " |"
exec "normal A\<CR>Delete space: " . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . " \<BS>|"
exec "normal GGA\<CR>Visual: v\<Esc>v" . b:delimitMate_visual_leader . b:delimitMate_quotes_list[i]
exec "normal A\<CR>Car return: " . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . "\<CR>|"
exec "normal GGA\<CR>Delete car return: " . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . "\<CR>\<BS>|\<Esc>GGA\<CR>\<CR>"
for i in range(len(b:_l_delimitMate_quotes_list))
exec "normal GGoOpen & close: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "|"
exec "normal oDelete: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "\<BS>|"
exec "normal oExit: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "|"
exec "normal oSpace: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . " |"
exec "normal oDelete space: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . " \<BS>|"
exec "normal GGoVisual: v\<Esc>v" . b:_l_delimitMate_visual_leader . b:_l_delimitMate_quotes_list[i]
exec "normal oCar return: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "\<CR>|"
exec "normal GGoDelete car return: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "\<CR>\<BS>|\<Esc>GGA\<Esc>o\<Esc>o"
endfor
endif
endif "}}}
exec "normal \<Esc>i"
endfunction "}}}

View File

@@ -1,10 +1,18 @@
function! delimitMateTests#Main() " {{{
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
@@ -25,11 +33,24 @@ function! delimitMateTests#Main() " {{{
DelimitMateReload
endfunction " }}}
function! Type(name, input, output, options) " {{{
" Set default options:
call SetOptions(a:options)
normal ggVG"_d
exec "normal i" . a:input . "|\<Esc>"
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
@@ -45,35 +66,32 @@ function! delimitMateTests#Main() " {{{
let text = text . "<cr>" . getline(i)
let i += 1
endwhile
if result == 0
exec "let b:test_results['" . substitute(a:name, "[^a-zA-Z0-9_]", "_", "g") . "'] = 'Passed: ' . text . ' == ' . join(a:output, '<cr>')"
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
exec "let b:test_results['" . substitute(a:name, "[^a-zA-Z0-9_]", "_", "g") . "'] = 'Failed: ' . text . ' != ' . join(a:output, '<cr>')"
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) " {{{
normal gg.
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('1')
let i = 2
while i <= line('$')
let text = text . "<cr>" . getline(i)
let i += 1
endwhile
if result == 0
exec "let b:test_results['" . substitute(a:name, "[^a-zA-Z0-9_]", "_", "g") . "_R'] = 'Passed: ' . text . ' == ' . join(a:output, '<cr>')"
function! RepeatLast(name, output, ...) " {{{
if a:0 > 0
let arg1 = a:1
else
exec "let b:test_results['" . substitute(a:name, "[^a-zA-Z0-9_]", "_", "g") . "_R'] = 'Failed: ' . text . ' != ' . join(a:output, '<cr>')"
let arg1 = ''
endif
call Type(a:name, "\<Esc>.", a:output, [], arg1)
endfunction " }}}
" Test's test {{{
@@ -136,35 +154,35 @@ function! delimitMateTests#Main() " {{{
" Car return expansion
call Type("CR expansion", "(\<CR>", ['(', '|', ')'], ['expand_cr:1'])
call RepeatLast("CR expansion", ['(', '|', ')(', '|', ')'])
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", ['(|)(|)'])
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)'])
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))'])
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)'])
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))'])
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"'])
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""'])
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:","'])
@@ -173,8 +191,8 @@ function! delimitMateTests#Main() " {{{
call Type("Visual line wrapping quote empty line", "\<Esc>V,\"", ['""'], ['visual_leader:","'])
" Smart quotes
call Type("Smart quote alphanumeric", "alpha\"numeric", ['alpha"numeric|'], [])
call RepeatLast("Smart quote alphanumeric", ['alpha"numeric|alpha"numeric|'])
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\"|'], [])
@@ -188,9 +206,12 @@ function! delimitMateTests#Main() " {{{
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", ['(|)(|)'])
call RepeatLast("Backspace inside CR expansion", ['(|)(|)'], 1)
" FileType event
let g:delimitMate_excluded_ft = "vim"
@@ -199,27 +220,62 @@ function! delimitMateTests#Main() " {{{
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
"syntax match failedLine "^.*Failed.*$" contains=ALL
"syn match passedLine ".*Passed.*"
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
" }}}
endfunction " }}}
let &more = nomore
endfunction
" vim:foldmethod=marker:foldcolumn=4

View File

@@ -1,18 +1,20 @@
*delimitMate* Trying to keep those beasts at bay! v.2.1 *delimitMate.txt*
*delimitMate* Trying to keep those beasts at bay! v2.4 *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
========================================================================= ~
==== ========= ========================== ===== ===================== ~
==== ========= ========================== === ===================== ~
==== ========= ===================== === = = ========== ========= ~
==== === === == == = = === == == == == === === === == ~
== == = == ====== ======= === ===== == = === === = = ~
= = == == == == = = == === === ===== ===== === === = ~
= = == ===== == == = = == === === ===== === === === ==== ~
= = == = == == == = = == === === ===== == = === === = = ~
== === === == == = = == === == ===== === === === == ~
========================================================================= ~
REFERENCE MANUAL *
==============================================================================
0.- CONTENTS *delimitMate-contents*
@@ -24,8 +26,10 @@
2.3 Backspace__________________________|delimitMateBackspace|
2.4 Visual wrapping____________________|delimitMateVisualWrapping|
2.5 Smart Quotes_______________________|delimitMateSmartQuotes|
2.6 FileType based configuration_______|delimitMateFileType|
2.7 Syntax awareness___________________|delimitMateSyntax|
3. Customization___________________________|delimitMateOptions|
3.1 Option summary_____________________|delimitMateOptionSummary|
3.1 Options summary____________________|delimitMateOptionSummary|
3.2 Options details____________________|delimitMateOptionDetails|
4. Commands________________________________|delimitMateCommands|
5. Functions_______________________________|delimitMateFunctions|
@@ -38,7 +42,7 @@
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
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
@@ -86,6 +90,9 @@ Without auto-close: >
-|
()<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*
@@ -121,8 +128,9 @@ If you press backspace inside an empty pair, both delimiters are deleted. When
expansions are enabled, <BS> will also delete the expansions. NOTE that
deleting <CR> expansions will brake the redo command.
If you type shift + backspace instead, only the closing delimiter will be
deleted.
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 "|": >
@@ -145,8 +153,9 @@ e.g. typing at the "|": >
When visual mode is active this script allows for the selection to be enclosed
with delimiters. But, since brackets have special meaning in visual mode, a
leader (the value of 'mapleader' by default) should precede the delimiter.
NOTE that this feature brakes the redo command and doesn't currently work on
blockwise visual mode, any suggestions will be welcome.
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): >
@@ -158,9 +167,10 @@ e.g. (selection represented between square brackets): >
------------------------------------------------------------------------------
2.5 SMART QUOTES *delimitMateSmartQuotes*
Only one quote will be inserted following a quote, a "\" or an alphanumeric
character. This should cover closing quotes, escaped quotes and apostrophes.
Except for apostrophes, this feature can be disabled setting the option
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 "|": >
@@ -171,6 +181,40 @@ e.g. typing at the "|": >
" | let i = "| | let i = "|"
' | I| | I'|
<
------------------------------------------------------------------------------
2.6 FILE TYPE BASED CONFIGURATION *delimitMateFileType*
delimitMate options can be set globally for all buffers using global
("regular") variables in your |vimrc| file. But |:autocmd| can be used to set
options for specific file types (see |'filetype'|) using buffer variables in
the following way: >
au FileType mail,text let b:delimitMate_autoclose = 0
^ ^ ^ ^ ^
| | | | |
| | | | - Option value.
| | | - Option name.
| | - Buffer variable.
| - File types for which the option will be set.
- Don't forget to put this event.
<
NOTE that 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.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.
==============================================================================
3. CUSTOMIZATION *delimitMateOptions*
@@ -195,6 +239,10 @@ specific file types, see |delimitMateOptionDetails| for examples.
|'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>.
@@ -203,6 +251,9 @@ specific file types, see |delimitMateOptionDetails| for examples.
|'delimitMate_excluded_ft'| Turns off the script for the given file types.
|'delimitMate_excluded_regions'|Turns off the script for the given regions or
syntax group names.
|'delimitMate_apostrophes'| Tells delimitMate how it should "fix"
balancing of single quotes when used as
apostrophes. NOTE: Not needed any more, kept
@@ -214,8 +265,13 @@ specific file types, see |delimitMateOptionDetails| for examples.
3.2 OPTIONS DETAILS *delimitMateOptionDetails*
Add the shown lines to your vimrc file in order to set the below options.
Local options take precedence over global ones and can be used along with
autocmd to modify delimitMate's behavior for specific file types.
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'*
@@ -240,13 +296,13 @@ e.g.: >
------------------------------------------------------------------------------
*'delimitMate_matchpairs'*
*'b:delimitMate_matchpairs'*
Values: A string with |matchpairs| syntax. ~
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 = "(:),[:],{:},<:>"
let delimitMate_matchpairs = "(:),[:],{:},<:>"
au FileType vim,html let b:delimitMate_matchpairs = "(:),[:],{:},<:>"
<
------------------------------------------------------------------------------
@@ -258,9 +314,21 @@ Default: "\" ' `" ~
Use this option to tell delimitMate which characters should be considered as
quotes. Read |delimitMateAutoClose| for details.
e.g.: >
let b:delimitMate_quotes = "\" ' ` *"
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_quotes = ['"','`']
au FileType python let b:delimitMate_quotes = ['"']
<
------------------------------------------------------------------------------
*'delimitMate_visual_leader'*
*'b:delimitMate_visual_leader'*
@@ -282,20 +350,20 @@ Default: 0 ~
This option turns on/off the expansion of <CR>. Read |delimitMateExpansion|
for details.
e.g.: >
let b:delimitMate_expand_cr = "\<CR>\<CR>\<Up>"
au FileType mail let b:delimitMate_expand_cr = "\<CR>"
let delimitMate_expand_cr = 1
au FileType mail let b:delimitMate_expand_cr = 1
<
------------------------------------------------------------------------------
*'delimitMate_expand_space'*
*'b:delimitMate_expand_space'*
Values: A key mapping. ~
Default: "\<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 = "\<Space>\<Space>\<Left>"
au FileType tcl let b:delimitMate_expand_space = "\<Space>"
let delimitMate_expand_space = 1
au FileType tcl let b:delimitMate_expand_space = 1
<
------------------------------------------------------------------------------
*'delimitMate_excluded_ft'*
@@ -307,6 +375,16 @@ 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_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_apostrophes'*
Values: Strings separated by ":". ~
@@ -332,6 +410,11 @@ e.g.: >
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*
@@ -406,54 +489,63 @@ represented by an "|": >
==============================================================================
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*
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()*
delimitMate#ExpandReturn() *delimitMate#ExpandReturn()*
Returns the expansion for <CR>.
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>" :
\ DelimitMate_WithinEmptyPair ?
\ DelimitMate_ExpandReturn() : "\<CR>"
inoremap <expr> <CR> pumvisible() ?
\"\<c-y>" :
\ "\<C-R>=delimitMate#ExpandReturn()\<CR>"
<
------------------------------------------------------------------------------
DelimitMate_ExpandSpace() *DelimitMate_ExpandSpace()*
delimitMate#ExpandSpace() *delimitMate#ExpandSpace()*
Returns the expansion for <Space>.
Returns the expansion for <Space> if enabled and inside an empty pair, returns
<Space> otherwise.
e.g.: >
inoremap <expr> <Space> DelimitMate_WithinEmptyPair() ?
\ DelimitMate_ExpandSpace() : "\<Space>"
inoremap <Space> <C-R>=delimitMate#ExpandSpace()<CR>
<
------------------------------------------------------------------------------
DelimitMate_ShouldJump() *DelimitMate_ShouldJump()*
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() *DelimitMate_JumpAny()*
delimitMate#JumpAny(key) *delimitMate#JumpAny()*
This function returns a mapping that will make the cursor jump to the right.
This function returns a mapping that will make the cursor jump to the right
when delimitMate#ShouldJump() returns 1, returns the argument "key" otherwise.
e.g.: You can use this to create your own mapping to jump over any delimiter.
>
inoremap <expr> <C-Tab> DelimitMate_ShouldJump() ?
\ DelimitMate_JumpAny() : "\<C-Tab>"
inoremap <C-Tab> <C-R>=delimitMate#JumpAny("\<C-Tab>")<CR>
<
==============================================================================
6. TODO LIST *delimitMateTodo*
- Automatic set-up by file type.
- Make visual wrapping work on blockwise visual mode.
- Limit behaviour by region.
- Make block-wise visual wrapping work on un-even regions.
==============================================================================
7. MAINTAINER *delimitMateMaintainer*
@@ -478,22 +570,61 @@ from the following sources:
From the comments on the previous blog post and from:
http://gist.github.com/144619
- Vim Scripts:
http://www.vim.org/scripts
- Karl Guertin
AutoClose:
http://www.vim.org/scripts/script.php?script_id=1849
This script was inspired by the auto-completion of delimiters of TextMate.
- Thiago Alves
AutoClose:
http://www.vim.org/scripts/script.php?script_id=2009
- Edoardo Vacchi
ClosePairs:
http://www.vim.org/scripts/script.php?script_id=2373
This script was inspired by the auto-completion of delimiters on TextMate.
==============================================================================
9. HISTORY *delimitMateHistory*
Version Date Release notes ~
|---------|------------|-----------------------------------------------------|
2.1 2010-05-10 - Most of the functions have been moved to an
2.4 2010-07-29 * Current release:
- 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:
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
@@ -507,29 +638,28 @@ This script was inspired by the auto-completion of delimiters of TextMate.
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
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
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
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
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
@@ -538,7 +668,7 @@ This script was inspired by the auto-completion of delimiters of TextMate.
- Wrapping a single empty line works as expected.
|---------|------------|-----------------------------------------------------|
1.2 2009-09-07 Fixes:
1.2 2009-09-07 * Fixes:
- When inside nested empty pairs, deleting the
innermost left delimiter would delete all right
contiguous delimiters.
@@ -549,19 +679,21 @@ This script was inspired by the auto-completion of delimiters of TextMate.
have the mappings set.
|---------|------------|-----------------------------------------------------|
1.1 2009-08-25 Fixed an error that ocurred when mapleader wasn't
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.
1.0 2009-08-23 * Initial upload.
|---------|------------|-----------------------------------------------------|
... |"| _ _ . . ___ ~
o,*,(o o) _|_|_ o' \,=./ `o . .:::. /_\ `* ~
8(o o)(_)Ooo (o o) (o o) :(o o): . (o o) ~
---ooO-(_)---Ooo----ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo- ~
`\|||/´ MMM \|/ www __^__ ~
(o o) (o o) @ @ (O-O) /(o o)\\ ~
ooO_(_)_Ooo__ ooO_(_)_Ooo___oOO_(_)_OOo___oOO__(_)__OOo___oOO__(_)__OOo_____ ~
_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|____ ~
__|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_ ~
_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|____ ~
vim:tw=78:ts=8:ft=help:norl:formatoptions+=tcroqn:autoindent:
vim:tw=78:et:ts=2:sw=2:ft=help:norl:formatoptions+=tcroqn:autoindent:

View File

@@ -1,13 +1,15 @@
" ============================================================================
" File: plugin/delimitMate.vim
" Version: 2.1
" Version: 2.4
" Modified: 2010-07-29
" Description: This plugin provides auto-completion for quotes, parens, etc.
" Maintainer: Israel Chauca F. <israelchauca@gmail.com>
" Manual: Read ":help delimitMate".
" Initialization: {{{
if exists("g:loaded_delimitMate") "{{{
" User doesn't want this plugin, let's get out!
if exists("g:loaded_delimitMate") || &cp
" User doesn't want this plugin or compatible is set, let's get out!
finish
endif
let g:loaded_delimitMate = 1
@@ -24,142 +26,27 @@ if v:version < 700
finish
endif
let s:loaded_delimitMate = 1 " }}}
let delimitMate_version = '2.1'
let s:loaded_delimitMate = 1
let delimitMate_version = "2.4"
"}}}
" Tools: {{{
function! s:Init() "{{{
let b:loaded_delimitMate = 1
" delimitMate_autoclose {{{
if !exists("b:delimitMate_autoclose") && !exists("g:delimitMate_autoclose")
let b:delimitMate_autoclose = 1
elseif !exists("b:delimitMate_autoclose") && exists("g:delimitMate_autoclose")
let b:delimitMate_autoclose = g:delimitMate_autoclose
else
" Nothing to do.
endif " }}}
" delimitMate_matchpairs {{{
if !exists("b:delimitMate_matchpairs") && !exists("g:delimitMate_matchpairs")
let s:matchpairs_temp = &matchpairs
elseif exists("b:delimitMate_matchpairs")
let s:matchpairs_temp = b:delimitMate_matchpairs
else
let s:matchpairs_temp = g:delimitMate_matchpairs
endif " }}}
" delimitMate_quotes {{{
if exists("b:delimitMate_quotes")
let s:quotes = split(b:delimitMate_quotes)
elseif exists("g:delimitMate_quotes")
let s:quotes = split(g:delimitMate_quotes)
else
let s:quotes = split("\" ' `")
endif
let b:delimitMate_quotes_list = s:quotes " }}}
" delimitMate_excluded_regions {{{
if exists("b:delimitMate_excluded_regions")
let s:excluded_regions = b:delimitMate_excluded_regions
elseif exists("g:delimitMate_excluded_regions")
let s:excluded_regions = g:delimitMate_excluded_regions
else
let s:excluded_regions = "Comment"
endif
let b:delimitMate_excluded_regions_list = split(s:excluded_regions, ',\s*')
let b:delimitMate_excluded_regions_enabled = len(b:delimitMate_excluded_regions_list) " }}}
" delimitMate_visual_leader {{{
if !exists("b:delimitMate_visual_leader") && !exists("g:delimitMate_visual_leader")
let b:delimitMate_visual_leader = exists('b:maplocalleader') ? b:maplocalleader :
\ exists('g:mapleader') ? g:mapleader : "\\"
elseif !exists("b:delimitMate_visual_leader") && exists("g:delimitMate_visual_leader")
let b:delimitMate_visual_leader = g:delimitMate_visual_leader
else
" Nothing to do.
endif " }}}
" delimitMate_expand_space {{{
if !exists("b:delimitMate_expand_space") && !exists("g:delimitMate_expand_space")
let b:delimitMate_expand_space = 0
elseif !exists("b:delimitMate_expand_space") && exists("g:delimitMate_expand_space")
let b:delimitMate_expand_space = g:delimitMate_expand_space
else
" Nothing to do.
endif " }}}
" delimitMate_expand_cr {{{
if !exists("b:delimitMate_expand_cr") && !exists("g:delimitMate_expand_cr")
let b:delimitMate_expand_cr = 0
elseif !exists("b:delimitMate_expand_cr") && exists("g:delimitMate_expand_cr")
let b:delimitMate_expand_cr = g:delimitMate_expand_cr
else
" Nothing to do.
endif " }}}
" delimitMate_smart_quotes {{{
if !exists("b:delimitMate_smart_quotes") && !exists("g:delimitMate_smart_quotes")
let b:delimitMate_smart_quotes = 1
elseif !exists("b:delimitMate_smart_quotes") && exists("g:delimitMate_smart_quotes")
let b:delimitMate_smart_quotes = split(g:delimitMate_smart_quotes)
else
" Nothing to do.
endif " }}}
" delimitMate_apostrophes {{{
if !exists("b:delimitMate_apostrophes") && !exists("g:delimitMate_apostrophes")
"let s:apostrophes = split("n't:'s:'re:'m:'d:'ll:'ve:s'",':')
let s:apostrophes = []
elseif !exists("b:delimitMate_apostrophes") && exists("g:delimitMate_apostrophes")
let s:apostrophes = split(g:delimitMate_apostrophes)
else
let s:apostrophes = split(b:delimitMate_apostrophes)
endif
let b:delimitMate_apostrophes_list = s:apostrophes " }}}
" delimitMate_tab2exit {{{
if !exists("b:delimitMate_tab2exit") && !exists("g:delimitMate_tab2exit")
let b:delimitMate_tab2exit = 1
elseif !exists("b:delimitMate_tab2exit") && exists("g:delimitMate_tab2exit")
let b:delimitMate_tab2exit = g:delimitMate_tab2exit
else
" Nothing to do.
endif " }}}
let b:delimitMate_matchpairs_list = split(s:matchpairs_temp, ',')
let b:delimitMate_left_delims = split(s:matchpairs_temp, ':.,\=')
let b:delimitMate_right_delims = split(s:matchpairs_temp, ',\=.:')
let b:delimitMate_buffer = []
call delimitMate#UnMap()
if b:delimitMate_autoclose
call delimitMate#AutoClose()
else
call delimitMate#NoAutoClose()
endif
call delimitMate#VisualMaps()
call delimitMate#ExtraMappings()
endfunction "}}} Init()
" Functions: {{{
function! s:TestMappingsDo() "{{{
if !exists("g:delimitMate_testing")
silent call delimitMate#TestMappings()
else
let temp_varsDM = [b:delimitMate_expand_space, b:delimitMate_expand_cr, b:delimitMate_autoclose]
let temp_varsDM = [b:_l_delimitMate_expand_space, b:_l_delimitMate_expand_cr, b:_l_delimitMate_autoclose]
for i in [0,1]
let b:delimitMate_expand_space = i
let b:delimitMate_expand_cr = i
for a in [0,1]
let b:delimitMate_autoclose = a
call s:Init()
call delimitMate#Init()
call delimitMate#UnMap()
call delimitMate#Map()
call delimitMate#TestMappings()
exec "normal i\<CR>"
normal o
endfor
endfor
let b:delimitMate_expand_space = temp_varsDM[0]
@@ -170,55 +57,84 @@ function! s:TestMappingsDo() "{{{
normal gg
endfunction "}}}
function! s:DelimitMateDo() "{{{
if exists("g:delimitMate_excluded_ft")
" Check if this file type is excluded:
for ft in split(g:delimitMate_excluded_ft,',')
if ft ==? &filetype
"echomsg "excluded"
call delimitMate#UnMap()
return 1
endif
endfor
function! s:DelimitMateDo(...) "{{{
" Initialize settings:
call delimitMate#Init()
" Check if this file type is excluded:
if exists("g:delimitMate_excluded_ft") &&
\ index(split(g:delimitMate_excluded_ft, ','), &filetype, 0, 1) >= 0
" Remove any magic:
call delimitMate#UnMap()
" Finish here:
return 1
endif
" First, remove all magic, if needed:
if exists("b:delimitMate_enabled") && b:delimitMate_enabled == 1
call delimitMate#UnMap()
endif
" Now, add magic:
call delimitMate#Map()
if a:0 > 0
echo "delimitMate has been reset."
endif
try
"echomsg "included"
let save_cpo = &cpo
let save_keymap = &keymap
set keymap=
set cpo&vim
call s:Init()
finally
let &cpo = save_cpo
let &keymap = save_keymap
endtry
endfunction "}}}
function! s:DelimitMateSwitch() "{{{
call delimitMate#Init()
if exists("b:delimitMate_enabled") && b:delimitMate_enabled
call delimitMate#UnMap()
echo "delimitMate has been disabled."
else
call delimitMate#UnMap()
call delimitMate#Map()
echo "delimitMate has been enabled."
endif
endfunction "}}}
"}}}
" Commands: {{{
call s:DelimitMateDo()
" Let me refresh without re-loading the buffer:
command! DelimitMateReload call s:DelimitMateDo()
command! DelimitMateReload call s:DelimitMateDo(1)
" Quick test:
command! DelimitMateTest call s:TestMappingsDo()
"command! DelimitMateRegions echo s:excluded_regions
" Turn
" Switch On/Off:
command! DelimitMateSwitch call s:DelimitMateSwitch()
"}}}
" Run on file type events.
"autocmd VimEnter * autocmd FileType * call <SID>DelimitMateDo()
autocmd FileType * call <SID>DelimitMateDo()
" Autocommands: {{{
" Run on new buffers.
autocmd BufNewFile,BufRead,BufEnter * if !exists("b:loaded_delimitMate") | call <SID>DelimitMateDo() | endif
augroup delimitMate
au!
" Run on file type change.
"autocmd VimEnter * autocmd FileType * call <SID>DelimitMateDo()
autocmd FileType * call <SID>DelimitMateDo()
" Flush the char buffer:
autocmd InsertEnter * call delimitMate#FlushBuffer()
autocmd BufEnter * if mode() == 'i' | call delimitMate#FlushBuffer() | endif
" Run on new buffers.
autocmd BufNewFile,BufRead,BufEnter *
\ if !exists("b:loaded_delimitMate") |
\ call <SID>DelimitMateDo() |
\ endif
"function! s:GetSynRegion () | echo synIDattr(synIDtrans(synID(line('.'), col('.'), 1)), 'name') | endfunction
" Flush the char buffer:
autocmd InsertEnter * call delimitMate#FlushBuffer()
autocmd BufEnter *
\ if mode() == 'i' |
\ call delimitMate#FlushBuffer() |
\ endif
augroup END
"}}}