mirror of
https://github.com/Raimondi/delimitMate.git
synced 2025-12-06 12:44:27 +08:00
Compare commits
31 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1d423ab2b9 | ||
|
|
7f5df4bf6e | ||
|
|
9f1fdc418d | ||
|
|
64cf4beb8a | ||
|
|
119174b7dd | ||
|
|
b3a7728299 | ||
|
|
2266a19900 | ||
|
|
1b587bee9a | ||
|
|
31b289adfe | ||
|
|
efadb34c84 | ||
|
|
58d63b4e5b | ||
|
|
0441a03bb9 | ||
|
|
90cb449ada | ||
|
|
a678d7baab | ||
|
|
2911bf33c9 | ||
|
|
221daf6e6a | ||
|
|
8f5a45f9e7 | ||
|
|
6f5fd80e0e | ||
|
|
1caeda0799 | ||
|
|
3fb33b8e47 | ||
|
|
e6288a7313 | ||
|
|
7dd7edff64 | ||
|
|
4b94c38f95 | ||
|
|
217adb3d8e | ||
|
|
e63e373ae1 | ||
|
|
9c11c5cc82 | ||
|
|
8b24f0fd9f | ||
|
|
701e14f72f | ||
|
|
c9c1464075 | ||
|
|
e831d89acf | ||
|
|
133c125f93 |
10
Makefile
10
Makefile
@@ -10,11 +10,6 @@ VIM=/usr/bin/vim
|
||||
|
||||
.PHONY: $(PLUGIN).vba README
|
||||
|
||||
#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
|
||||
@@ -25,11 +20,6 @@ clean:
|
||||
|
||||
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
|
||||
|
||||
|
||||
582
README
582
README
@@ -1,4 +1,4 @@
|
||||
*delimitMate* Trying to keep those beasts at bay! v2.4 *delimitMate.txt*
|
||||
*delimitMate.txt* Trying to keep those beasts at bay! v2.5 *delimitMate*
|
||||
|
||||
|
||||
|
||||
@@ -20,23 +20,25 @@
|
||||
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|
|
||||
2. Customization___________________________|delimitMateOptions|
|
||||
2.1 Options summary____________________|delimitMateOptionSummary|
|
||||
2.2 Options details____________________|delimitMateOptionDetails|
|
||||
3. Functionality___________________________|delimitMateFunctionality|
|
||||
3.1 Automatic closing & exiting________|delimitMateAutoClose|
|
||||
3.2 Expansion of space and CR__________|delimitMateExpansion|
|
||||
3.3 Backspace__________________________|delimitMateBackspace|
|
||||
3.4 Visual wrapping____________________|delimitMateVisualWrapping|
|
||||
3.5 Smart Quotes_______________________|delimitMateSmartQuotes|
|
||||
3.6 Balancing matching pairs___________|delimitMateBalance|
|
||||
3.7 FileType based configuration_______|delimitMateFileType|
|
||||
3.8 Syntax awareness___________________|delimitMateSyntax|
|
||||
4. Commands________________________________|delimitMateCommands|
|
||||
5. Functions_______________________________|delimitMateFunctions|
|
||||
6. TODO list_______________________________|delimitMateTodo|
|
||||
7. Maintainer______________________________|delimitMateMaintainer|
|
||||
8. Credits_________________________________|delimitMateCredits|
|
||||
9. History_________________________________|delimitMateHistory|
|
||||
5. Mappings________________________________|delimitMateMappings|
|
||||
6. Functions_______________________________|delimitMateFunctions|
|
||||
7. TODO list_______________________________|delimitMateTodo|
|
||||
8. Maintainer______________________________|delimitMateMaintainer|
|
||||
9. Credits_________________________________|delimitMateCredits|
|
||||
10. History_________________________________|delimitMateHistory|
|
||||
|
||||
==============================================================================
|
||||
1.- INTRODUCTION *delimitMateIntro*
|
||||
@@ -49,11 +51,234 @@ 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.
|
||||
|
||||
NOTE 1: If you have any trouble with this plugin, please run |:DelimitMateTest|
|
||||
in a new buffer to see what is not working.
|
||||
|
||||
NOTE 2: |'timeout'| needs to be set when working in the terminal, otherwise you
|
||||
might find weird behaviour with mappings including <Esc> or arrow keys.
|
||||
|
||||
NOTE 3: Abbreiations set with |:iabbrev| will not be expanded by delimiters
|
||||
used on delimitMate, you should use <C-]> (read |i_CTRL-]|) to expand them on
|
||||
the go.
|
||||
|
||||
==============================================================================
|
||||
2. FUNCTIONALITY *delimitMateFunctionality*
|
||||
2. CUSTOMIZATION *delimitMateOptions*
|
||||
|
||||
You can create your own mappings for some features using the global functions.
|
||||
Read |DelimitMateFunctions| for more info.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.1 AUTOMATIC CLOSING AND EXITING *delimitMateAutoClose*
|
||||
2.1 OPTIONS SUMMARY *delimitMateOptionSummary*
|
||||
|
||||
The behaviour of this script can be customized setting the following options
|
||||
in your vimrc file. You can use local options to set the configuration for
|
||||
specific file types, see |delimitMateOptionDetails| for examples.
|
||||
|
||||
|'loaded_delimitMate'| Turns off the script.
|
||||
|
||||
|'delimitMate_autoclose'| Tells delimitMate whether to automagically
|
||||
insert the closing delimiter.
|
||||
|
||||
|'delimitMate_matchpairs'| Tells delimitMate which characters are
|
||||
matching pairs.
|
||||
|
||||
|'delimitMate_quotes'| Tells delimitMate which quotes should be
|
||||
used.
|
||||
|
||||
|'delimitMate_nesting_quotes'| Tells delimitMate which quotes should be
|
||||
allowed to be nested.
|
||||
|
||||
|'delimitMate_visual_leader'| Sets the leader to be used in visual mode.
|
||||
|
||||
|'delimitMate_expand_cr'| Turns on/off the expansion of <CR>.
|
||||
|
||||
|'delimitMate_expand_space'| Turns on/off the expansion of <Space>.
|
||||
|
||||
|'delimitMate_smart_quotes'| Turns on/off the "smart quotes" feature.
|
||||
|
||||
|'delimitMate_balance_matchpairs'|Turns on/off the "balance matching pairs"
|
||||
feature.
|
||||
|
||||
|'delimitMate_excluded_regions'| Turns off the script for the given regions or
|
||||
syntax group names.
|
||||
|
||||
|'delimitMate_excluded_ft'| Turns off the script for the given file types.
|
||||
|
||||
|'delimitMate_apostrophes'| Tells delimitMate how it should "fix"
|
||||
balancing of single quotes when used as
|
||||
apostrophes. NOTE: Not needed any more, kept
|
||||
for compatibility with older versions.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.2 OPTIONS DETAILS *delimitMateOptionDetails*
|
||||
|
||||
Add the shown lines to your vimrc file in order to set the below options.
|
||||
Buffer variables take precedence over global ones and can be used along with
|
||||
autocmd to modify delimitMate's behavior for specific file types, read more in
|
||||
|delimitMateFileType|.
|
||||
|
||||
Note: Use buffer variables only to set options for specific file types using
|
||||
:autocmd, use global variables to set options for every buffer. Read more in
|
||||
|g:var| and |b:var|.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*'loaded_delimitMate'*
|
||||
*'b:loaded_delimitMate'*
|
||||
This option prevents delimitMate from loading.
|
||||
e.g.: >
|
||||
let loaded_delimitMate = 1
|
||||
au FileType mail let b:loaded_delimitMate = 1
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'delimitMate_autoclose'*
|
||||
*'b:delimitMate_autoclose'*
|
||||
Values: 0 or 1. ~
|
||||
Default: 1 ~
|
||||
|
||||
If this option is set to 0, delimitMate will not add a closing delimiter
|
||||
automagically. See |delimitMateAutoClose| for details.
|
||||
e.g.: >
|
||||
let delimitMate_autoclose = 0
|
||||
au FileType mail let b:delimitMate_autoclose = 0
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'delimitMate_matchpairs'*
|
||||
*'b:delimitMate_matchpairs'*
|
||||
Values: A string with |'matchpairs'| syntax, plus support for multi-byte~
|
||||
characters.~
|
||||
Default: &matchpairs ~
|
||||
|
||||
Use this option to tell delimitMate which characters should be considered
|
||||
matching pairs. Read |delimitMateAutoClose| for details.
|
||||
e.g: >
|
||||
let delimitMate_matchpairs = "(:),[:],{:},<:>"
|
||||
au FileType vim,html let b:delimitMate_matchpairs = "(:),[:],{:},<:>"
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'delimitMate_quotes'*
|
||||
*'b:delimitMate_quotes'*
|
||||
Values: A string of characters separated by spaces. ~
|
||||
Default: "\" ' `" ~
|
||||
|
||||
Use this option to tell delimitMate which characters should be considered as
|
||||
quotes. Read |delimitMateAutoClose| for details.
|
||||
e.g.: >
|
||||
let delimitMate_quotes = "\" ' ` *"
|
||||
au FileType html let b:delimitMate_quotes = "\" '"
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'delimitMate_nesting_quotes'*
|
||||
*'b:delimitMate_nesting_quotes'*
|
||||
Values: A list of quotes. ~
|
||||
Default: [] ~
|
||||
|
||||
Quotes listed here will not be able to jump out of the empty pair, thus
|
||||
allowing the autoclosed quotes to be nested.
|
||||
e.g.: >
|
||||
let delimitMate_nesting_quotes = ['"','`']
|
||||
au FileType python let b:delimitMate_nesting_quotes = ['"']
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'delimitMate_visual_leader'*
|
||||
*'b:delimitMate_visual_leader'*
|
||||
Values: Any character. ~
|
||||
Default: q ~
|
||||
|
||||
The value of this option will be used to wrap the selection in visual mode
|
||||
when followed by a delimiter. Read |delimitMateVisualWrap| for details.
|
||||
e.g: >
|
||||
let delimitMate_visual_leader = "f"
|
||||
au FileType html let b:delimitMate_visual_leader = "f"
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'delimitMate_expand_cr'*
|
||||
*'b:delimitMate_expand_cr'*
|
||||
Values: 1 or 0 ~
|
||||
Default: 0 ~
|
||||
|
||||
This option turns on/off the expansion of <CR>. Read |delimitMateExpansion|
|
||||
for details.
|
||||
e.g.: >
|
||||
let delimitMate_expand_cr = 1
|
||||
au FileType mail let b:delimitMate_expand_cr = 1
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'delimitMate_expand_space'*
|
||||
*'b:delimitMate_expand_space'*
|
||||
Values: 1 or 0 ~
|
||||
Default: 0 ~
|
||||
|
||||
This option turns on/off the expansion of <Space>. Read |delimitMateExpansion|
|
||||
for details.
|
||||
e.g.: >
|
||||
let delimitMate_expand_space = 1
|
||||
au FileType tcl let b:delimitMate_expand_space = 1
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'delimitMate_smart_quotes'*
|
||||
*'b:delimitMate_smart_quotes'*
|
||||
Values: 1 or 0 ~
|
||||
Default: 1 ~
|
||||
|
||||
This option turns on/off the smart quotes feature. Read
|
||||
|delimitMateSmartQuotes| for details.
|
||||
e.g.: >
|
||||
let delimitMate_smart_quotes = 0
|
||||
au FileType tcl let b:delimitMate_smart_quotes = 0
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'delimitMate_balance_matchpairs'*
|
||||
*'b:delimitMate_balance_matchpairs'*
|
||||
Values: 1 or 0 ~
|
||||
Default: 0 ~
|
||||
|
||||
This option turns on/off the balancing of matching pairs. Read
|
||||
|delimitMateBalance| for details.
|
||||
e.g.: >
|
||||
let delimitMate_balance_matchpairs = 1
|
||||
au FileType tcl let b:delimitMate_balance_matchpairs = 1
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'delimitMate_excluded_regions'*
|
||||
Values: A string of syntax group names names separated by single commas. ~
|
||||
Default: Comment ~
|
||||
|
||||
This options turns delimitMate off for the listed regions, read |group-name|
|
||||
for more info about what is a region.
|
||||
e.g.: >
|
||||
let delimitMate_excluded_regions = "Comments,String"
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'delimitMate_excluded_ft'*
|
||||
Values: A string of file type names separated by single commas. ~
|
||||
Default: Empty. ~
|
||||
|
||||
This options turns delimitMate off for the listed file types, use this option
|
||||
only if you don't want any of the features it provides on those file types.
|
||||
e.g.: >
|
||||
let delimitMate_excluded_ft = "mail,txt"
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'delimitMate_apostrophes'*
|
||||
Values: Strings separated by ":". ~
|
||||
Default: No longer used. ~
|
||||
|
||||
NOTE: This feature is turned off by default, it's been kept for compatibility
|
||||
with older version, read |delimitMateSmartQuotes| for details.
|
||||
If auto-close is enabled, this option tells delimitMate how to try to fix the
|
||||
balancing of single quotes when used as apostrophes. The values of this option
|
||||
are strings of text where a single quote would be used as an apostrophe (e.g.:
|
||||
the "n't" of wouldn't or can't) separated by ":". Set it to an empty string to
|
||||
disable this feature.
|
||||
e.g.: >
|
||||
let delimitMate_apostrophes = ""
|
||||
au FileType tcl let delimitMate_apostrophes = ""
|
||||
<
|
||||
==============================================================================
|
||||
3. FUNCTIONALITY *delimitMateFunctionality*
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
3.1 AUTOMATIC CLOSING AND EXITING *delimitMateAutoClose*
|
||||
|
||||
With automatic closing enabled, if an opening delimiter is inserted the plugin
|
||||
inserts the closing delimiter and places the cursor between the pair. With
|
||||
@@ -94,7 +319,7 @@ NOTE: Abbreviations will not be expanded by delimiters used on delimitMate,
|
||||
you should use <C-]> (read |i_CTRL-]|) to expand them on the go.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.2 EXPANSION OF SPACE AND CAR RETURN *delimitMateExpansion*
|
||||
3.2 EXPANSION OF SPACE AND CAR RETURN *delimitMateExpansion*
|
||||
|
||||
When the cursor is inside an empty pair of delimiters, <Space> and <CR> can be
|
||||
expanded, see |'delimitMate_expand_space'| and
|
||||
@@ -122,7 +347,7 @@ in expansions global, so they can be used to make custom mappings. Read
|
||||
|delimitMateFunctions| for more details.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.3 BACKSPACE *delimitMateBackspace*
|
||||
3.3 BACKSPACE *delimitMateBackspace*
|
||||
|
||||
If you press backspace inside an empty pair, both delimiters are deleted. When
|
||||
expansions are enabled, <BS> will also delete the expansions. NOTE that
|
||||
@@ -148,14 +373,14 @@ e.g. typing at the "|": >
|
||||
<
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.4 WRAPPING OF VISUAL SELECTION *delimitMateVisualWrapping*
|
||||
3.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.
|
||||
NOTE that this feature brakes the repeat 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): >
|
||||
|
||||
@@ -165,7 +390,7 @@ e.g. (selection represented between square brackets): >
|
||||
<
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.5 SMART QUOTES *delimitMateSmartQuotes*
|
||||
3.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
|
||||
@@ -177,12 +402,28 @@ e.g. typing at the "|": >
|
||||
|
||||
What | Before | After
|
||||
=======================================
|
||||
" | Text | | Text "|"
|
||||
" | "String| | "String"|
|
||||
" | let i = "| | let i = "|"
|
||||
' | I| | I'|
|
||||
'm | I| | I'm|
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
2.6 FILE TYPE BASED CONFIGURATION *delimitMateFileType*
|
||||
3.6 BALANCING MATCHING PAIRS *delimitMateBalance*
|
||||
|
||||
When inserting an opening paren and |'delimitMate_balance_matchpairs'| is
|
||||
enabled, delimitMate will try to balance the closing pairs in the current
|
||||
line.
|
||||
|
||||
e.g. typing at the "|": >
|
||||
|
||||
What | Before | After
|
||||
=======================================
|
||||
( | |) | (|)
|
||||
( | | | (|)
|
||||
( | (|) | ((|))
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
3.7 FILE TYPE BASED CONFIGURATION *delimitMateFileType*
|
||||
|
||||
delimitMate options can be set globally for all buffers using global
|
||||
("regular") variables in your |vimrc| file. But |:autocmd| can be used to set
|
||||
@@ -202,7 +443,7 @@ 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*
|
||||
3.8 SYNTAX AWARENESS *delimitMateSyntax*
|
||||
|
||||
The features of this plug-in might not be always helpful, comments and strings
|
||||
usualy don't need auto-completion. delimitMate monitors which region is being
|
||||
@@ -215,192 +456,6 @@ 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*
|
||||
|
||||
@@ -487,10 +542,56 @@ represented by an "|": >
|
||||
<
|
||||
|
||||
==============================================================================
|
||||
5. FUNCTIONS *delimitMateFunctions*
|
||||
5. MAPPINGS *delimitMateMappings*
|
||||
|
||||
Functions should be used enclosed between <C-R>= and <CR>, otherwise they
|
||||
might not work as expected or at all.
|
||||
delimitMate doesn't override any existing map, so you may encounter that it
|
||||
doesn't work as expected because a mapping is missing. In that case, the
|
||||
conflicting mappings should be resolved by either disabling the conflicting
|
||||
mapping or creating a custom mappings.
|
||||
|
||||
In order to make custom mappings easier and prevent overwritting existing
|
||||
ones, delimitMate uses the |<Plug>| + |hasmapto()| (|usr_41.txt|) construct
|
||||
for its mappings.
|
||||
|
||||
The following are the mappings alway set by delimitMate:
|
||||
|
||||
<BS> is mapped to <Plug>delimitMateBS
|
||||
<S-BS> is mapped to <Plug>delimitMateS-BS
|
||||
<S-Tab> is mapped to <Plug>delimitMateS-Tab
|
||||
<Del> is mapped to <Plug>delimitMateDel
|
||||
<Esc> is mapped to <Plug>delimitMateEsc
|
||||
<Left> is mapped to <Plug>delimitMateLeft
|
||||
<Right> is mapped to <Plug>delimitMateRight
|
||||
<Home> is mapped to <Plug>delimitMateHome
|
||||
<End> is mapped to <Plug>delimitMateEnd
|
||||
<Up> is mapped to <Plug>delimitMateUp
|
||||
<Down> is mapped to <Plug>delimitMateDown
|
||||
<PageUp> is mapped to <Plug>delimitMatePageUp
|
||||
<PageDown> is mapped to <Plug>delimitMatePageDown
|
||||
<S-Down> is mapped to <Plug>delimitMateS-Down
|
||||
<S-Up> is mapped to <Plug>delimitMateS-Up
|
||||
<LeftMouse> is mapped to <Plug>delimitMateMLeftMouse
|
||||
<RightMouse> is mapped to <Plug>delimitMateMRightMouse
|
||||
|
||||
The rest of the mappings correspond to parens, quotes, CR, Space, etc. and they
|
||||
depend on the values of the delimitMate options, they have the following form:
|
||||
|
||||
<Plug>delimitMate + char
|
||||
|
||||
e.g.: for "(":
|
||||
|
||||
( is mapped to <Plug>delimitMate(
|
||||
|
||||
e.g.: If you have <CR> expansion enabled, you might want to skip it on pop-up
|
||||
menus:
|
||||
|
||||
imap <expr> <CR> pumvisible() ?
|
||||
\"\<c-y>" :
|
||||
\ "<Plug>delimitMateCR"
|
||||
|
||||
|
||||
==============================================================================
|
||||
6. FUNCTIONS *delimitMateFunctions*
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
delimitMate#WithinEmptyPair() *delimitMate_WithinEmptyPair()*
|
||||
@@ -503,28 +604,6 @@ e.g.: >
|
||||
\ "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()*
|
||||
|
||||
@@ -542,13 +621,13 @@ e.g.: You can use this to create your own mapping to jump over any delimiter.
|
||||
<
|
||||
|
||||
==============================================================================
|
||||
6. TODO LIST *delimitMateTodo*
|
||||
7. TODO LIST *delimitMateTodo*
|
||||
|
||||
- Automatic set-up by file type.
|
||||
- Make block-wise visual wrapping work on un-even regions.
|
||||
|
||||
==============================================================================
|
||||
7. MAINTAINER *delimitMateMaintainer*
|
||||
8. MAINTAINER *delimitMateMaintainer*
|
||||
|
||||
Hi there! My name is Israel Chauca F. and I can be reached at:
|
||||
mailto:israelchauca@gmail.com
|
||||
@@ -557,7 +636,7 @@ Feel free to send me any suggestions and/or comments about this plugin, I'll
|
||||
be very pleased to read them.
|
||||
|
||||
==============================================================================
|
||||
8. CREDITS *delimitMateCredits*
|
||||
9. CREDITS *delimitMateCredits*
|
||||
|
||||
Some of the code that make this script is modified or just shamelessly copied
|
||||
from the following sources:
|
||||
@@ -585,12 +664,23 @@ from the following sources:
|
||||
This script was inspired by the auto-completion of delimiters on TextMate.
|
||||
|
||||
==============================================================================
|
||||
9. HISTORY *delimitMateHistory*
|
||||
10. HISTORY *delimitMateHistory*
|
||||
|
||||
Version Date Release notes ~
|
||||
|---------|------------|-----------------------------------------------------|
|
||||
2.4 2010-07-29 * Current release:
|
||||
- Unbalanced parens: see :help delimitMateBalance.
|
||||
2.5 2010-09-22 * Current release:
|
||||
- Better handling of mappings.
|
||||
- Add report for mappings in |:DelimitMateTest|.
|
||||
- Allow the use of "|" and multi-byte characters in
|
||||
|'delimitMate_quotes'| and |'delimitMate_matchpairs'|.
|
||||
- Allow commands to be concatenated using |.
|
||||
|---------|------------|-----------------------------------------------------|
|
||||
2.4.1 2010-07-31 * - Fix problem with <Home> and <End>.
|
||||
- Add missing doc on |'delimitMate_smart_quotes'|,
|
||||
|delimitMateBalance| and
|
||||
|'delimitMate_balance_matchpairs'|.
|
||||
|---------|------------|-----------------------------------------------------|
|
||||
2.4 2010-07-29 * - Unbalanced parens: see :help delimitMateBalance.
|
||||
- Visual wrapping now works on block-wise visual
|
||||
with some limitations.
|
||||
- Arrow keys didn't work on terminal.
|
||||
|
||||
@@ -1,141 +1,14 @@
|
||||
" ============================================================================
|
||||
" File: autoload/delimitMate.vim
|
||||
" Version: 2.4
|
||||
" Modified: 2010-07-29
|
||||
" Version: 2.5
|
||||
" Modified: 2010-09-22
|
||||
" 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()
|
||||
let delimitMate_loaded = 1
|
||||
|
||||
function! delimitMate#ShouldJump() "{{{
|
||||
" Returns 1 if the next character is a closing delimiter.
|
||||
@@ -426,7 +299,7 @@ function! delimitMate#ParenDelim(char) " {{{
|
||||
if delimitMate#IsForbidden(a:char)
|
||||
return ''
|
||||
endif
|
||||
if b:_l_delimitMate_unbalanced_parens &&
|
||||
if b:_l_delimitMate_balance_matchpairs &&
|
||||
\ delimitMate#BalancedParens(a:char) <= 0
|
||||
return ''
|
||||
endif
|
||||
@@ -579,15 +452,16 @@ function! delimitMate#Finish() " {{{
|
||||
let len = len(b:_l_delimitMate_buffer)
|
||||
if len > 0
|
||||
let buffer = join(b:_l_delimitMate_buffer, '')
|
||||
let len2 = len(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
|
||||
if col < 0
|
||||
call setline('.', line[col+len+1:])
|
||||
call setline('.', line[col+len2+1:])
|
||||
else
|
||||
call setline('.', line[:col] . line[col+len+1:])
|
||||
call setline('.', line[:col] . line[col+len2+1:])
|
||||
endif
|
||||
let i = 1
|
||||
let lefts = "\<Left>"
|
||||
@@ -609,147 +483,18 @@ endfunction " }}}
|
||||
|
||||
" }}}
|
||||
|
||||
" Mappers: {{{
|
||||
function! delimitMate#NoAutoClose() "{{{
|
||||
" inoremap <buffer> ) <C-R>=delimitMate#SkipDelim('\)')<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 <silent> <buffer> ( ()<Left>
|
||||
let i = 0
|
||||
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:_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 <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 <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:_l_delimitMate_visual_leader
|
||||
" Wrap the selection with matching pairs, but do nothing if blockwise visual mode is active:
|
||||
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 <silent> <buffer> <BS> <C-R>=delimitMate#BS()<CR>
|
||||
|
||||
" If pair is empty, delete closing delimiter:
|
||||
inoremap <silent> <buffer> <expr> <S-BS> delimitMate#WithinEmptyPair() ? "\<C-R>=delimitMate#Del()\<CR>" : "\<S-BS>"
|
||||
|
||||
" Expand return if inside an empty pair:
|
||||
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:_l_delimitMate_expand_space != 0
|
||||
inoremap <silent> <buffer> <Space> <C-R>=delimitMate#ExpandSpace()<CR>
|
||||
endif
|
||||
|
||||
" Jump out ot any empty pair:
|
||||
if b:_l_delimitMate_tab2exit
|
||||
inoremap <silent> <buffer> <S-Tab> <C-R>=delimitMate#JumpAny("\<S-Tab>")<CR>
|
||||
endif
|
||||
|
||||
" Fix the re-do feature:
|
||||
inoremap <silent> <buffer> <Esc> <C-R>=delimitMate#Finish()<CR><Esc>
|
||||
|
||||
" Flush the char buffer on mouse click:
|
||||
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 <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 <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:_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:_l_delimitMate_right_delims +
|
||||
\ b:_l_delimitMate_left_delims +
|
||||
\ b:_l_delimitMate_quotes_list
|
||||
|
||||
for map in imaps
|
||||
if maparg(map, "i") =~? 'delimitMate'
|
||||
exec 'silent! iunmap <buffer> ' . map
|
||||
endif
|
||||
endfor
|
||||
|
||||
if !exists("b:_l_delimitMate_visual_leader")
|
||||
let vleader = ""
|
||||
else
|
||||
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:_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
|
||||
let options = sort(keys(delimitMate#OptionsList()))
|
||||
let optoutput = ['delimitMate Report', '', 'Options:']
|
||||
for option in options
|
||||
exec 'call add(optoutput, ''delimitMate_''.option.'' = ''.string(b:_l_delimitMate_'.option.'))'
|
||||
endfor
|
||||
call append(line('$'), optoutput + ['','Showcase:', ''])
|
||||
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 GGoOpen: " . 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] . " |"
|
||||
@@ -757,17 +502,17 @@ function! delimitMate#TestMappings() "{{{
|
||||
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"
|
||||
exec "normal GGoDelete car return: " . b:_l_delimitMate_left_delims[i] . "\<CR>\<BS>|\<Esc>GG\<Esc>o"
|
||||
endfor
|
||||
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 GGAOpen: " . b:_l_delimitMate_quotes_list[i] . "|"
|
||||
exec "normal oDelete: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . "\<BS>|"
|
||||
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"
|
||||
exec "normal GGoDelete car return: " . b:_l_delimitMate_quotes_list[i] . "\<CR>\<BS>|\<Esc>GG\<Esc>o"
|
||||
endfor
|
||||
"}}}
|
||||
else
|
||||
@@ -781,7 +526,7 @@ function! delimitMate#TestMappings() "{{{
|
||||
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"
|
||||
exec "normal GGoDelete car return: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . "\<CR>\<BS>|\<Esc>GG\<Esc>o"
|
||||
endfor
|
||||
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] . "|"
|
||||
@@ -791,12 +536,71 @@ function! delimitMate#TestMappings() "{{{
|
||||
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"
|
||||
exec "normal GGoDelete car return: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "\<CR>\<BS>|\<Esc>GG\<Esc>o"
|
||||
endfor
|
||||
endif "}}}
|
||||
exec "normal \<Esc>i"
|
||||
|
||||
" Check if mappings were set. {{{
|
||||
let imaps = b:_l_delimitMate_right_delims
|
||||
let imaps = imaps + ( b:_l_delimitMate_autoclose ? b:_l_delimitMate_left_delims : [] )
|
||||
let imaps = imaps +
|
||||
\ b:_l_delimitMate_quotes_list +
|
||||
\ b:_l_delimitMate_apostrophes_list +
|
||||
\ ['<BS>', '<S-BS>', '<Del>', '<S-Tab>', '<Esc>'] +
|
||||
\ ['<Up>', '<Down>', '<Left>', '<Right>', '<LeftMouse>', '<RightMouse>'] +
|
||||
\ ['<Home>', '<End>', '<PageUp>', '<PageDown>', '<S-Down>', '<S-Up>']
|
||||
let imaps = imaps + ( b:_l_delimitMate_expand_cr ? ['<CR>'] : [] )
|
||||
let imaps = imaps + ( b:_l_delimitMate_expand_space ? ['<Space>'] : [] )
|
||||
|
||||
let vmaps =
|
||||
\ b:_l_delimitMate_right_delims +
|
||||
\ b:_l_delimitMate_left_delims +
|
||||
\ b:_l_delimitMate_quotes_list
|
||||
|
||||
let ibroken = []
|
||||
for map in imaps
|
||||
if maparg(map, "i") !~? 'delimitMate'
|
||||
let output = ''
|
||||
if map == '|'
|
||||
let map = '<Bar>'
|
||||
endif
|
||||
redir => output | execute "verbose imap ".map | redir END
|
||||
let ibroken = ibroken + [map.": is not set:"] + split(output, '\n')
|
||||
endif
|
||||
endfor
|
||||
let ibroken = len(ibroken) > 0 ? ['IMAP'] + ibroken : []
|
||||
|
||||
let vbroken = []
|
||||
if !exists("b:_l_delimitMate_visual_leader")
|
||||
let vleader = ""
|
||||
else
|
||||
let vleader = b:_l_delimitMate_visual_leader
|
||||
endif
|
||||
for map in vmaps
|
||||
if maparg(vleader . map, "v") !~? "delimitMate"
|
||||
let output = ''
|
||||
if map == '|'
|
||||
let map = '<Bar>'
|
||||
endif
|
||||
redir => output | execute "verbose imap ".map | redir END
|
||||
let vbroken = vbroken + [vleader.map.": is not set:"] + split(output,'\n')
|
||||
endif
|
||||
endfor
|
||||
let vbroken = len(vbroken) > 0 ? ['VMAP'] + vbroken : []
|
||||
|
||||
unlet! output
|
||||
if ibroken == [] && vbroken == []
|
||||
let output = ['Mappings:', '', 'All mappings were set-up.', '--------------------', '', '']
|
||||
else
|
||||
let output = ['Mappings:', ''] + ibroken + vbroken + ['--------------------', '', '']
|
||||
endif
|
||||
call append('$', output)
|
||||
" }}}
|
||||
endfunction "}}}
|
||||
|
||||
function! delimitMate#OptionsList() "{{{
|
||||
return {'autoclose' : 1,'matchpairs': &matchpairs, 'quotes' : '" '' `', 'nesting_quotes' : [], 'visual_leader' : ( exists('mapleader') ? mapleader : exists('b:maplocalleader') ? b:maplocalleader : '\' ), 'expand_cr' : 0, 'expand_space' : 0, 'smart_quotes' : 1, 'balance_matchpairs' : 0, 'excluded_regions' : 'Comment', 'excluded_ft' : '', 'apostrophes' : ''}
|
||||
endfunction " delimitMate#OptionsList }}}
|
||||
"}}}
|
||||
|
||||
" vim:foldmethod=marker:foldcolumn=4
|
||||
|
||||
@@ -27,8 +27,12 @@ function! delimitMateTests#Main()
|
||||
let b:delimitMate_tab2exit = 1
|
||||
" Set current test options:
|
||||
for str in a:list
|
||||
let pair = split(str, ':')
|
||||
exec "let b:delimitMate_" . pair[0] . " = " . pair[1]
|
||||
"echom '1:'.str
|
||||
let op = strpart(str, 0, stridx(str,':'))
|
||||
"echom op
|
||||
let val = strpart(str, stridx(str, ':' ) + 1)
|
||||
"echom val
|
||||
exec "let b:delimitMate_" . op . " = " . val
|
||||
endfor
|
||||
DelimitMateReload
|
||||
endfunction " }}}
|
||||
@@ -243,6 +247,12 @@ function! delimitMateTests#Main()
|
||||
" Manual close at start of line
|
||||
call Type("Manual close at start of line", "m)\<Left>\<Left>)", [')|m)'], ["autoclose:0"])
|
||||
|
||||
" Use | in quotes
|
||||
call Type("Use <Bar> in quotes", "\<Bar>bars", ['|bars|'], ["quotes:'|'"])
|
||||
|
||||
" Use | in matchpairs
|
||||
call Type("Use <Bar> in matchpairs", "\<Bar>bars", ['|bars|$$'], ["matchpairs:'|:$'"])
|
||||
|
||||
"}}}
|
||||
|
||||
" Show results: {{{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
*delimitMate* Trying to keep those beasts at bay! v2.4 *delimitMate.txt*
|
||||
*delimitMate.txt* Trying to keep those beasts at bay! v2.5 *delimitMate*
|
||||
|
||||
|
||||
|
||||
@@ -20,23 +20,25 @@
|
||||
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|
|
||||
2. Customization___________________________|delimitMateOptions|
|
||||
2.1 Options summary____________________|delimitMateOptionSummary|
|
||||
2.2 Options details____________________|delimitMateOptionDetails|
|
||||
3. Functionality___________________________|delimitMateFunctionality|
|
||||
3.1 Automatic closing & exiting________|delimitMateAutoClose|
|
||||
3.2 Expansion of space and CR__________|delimitMateExpansion|
|
||||
3.3 Backspace__________________________|delimitMateBackspace|
|
||||
3.4 Visual wrapping____________________|delimitMateVisualWrapping|
|
||||
3.5 Smart Quotes_______________________|delimitMateSmartQuotes|
|
||||
3.6 Balancing matching pairs___________|delimitMateBalance|
|
||||
3.7 FileType based configuration_______|delimitMateFileType|
|
||||
3.8 Syntax awareness___________________|delimitMateSyntax|
|
||||
4. Commands________________________________|delimitMateCommands|
|
||||
5. Functions_______________________________|delimitMateFunctions|
|
||||
6. TODO list_______________________________|delimitMateTodo|
|
||||
7. Maintainer______________________________|delimitMateMaintainer|
|
||||
8. Credits_________________________________|delimitMateCredits|
|
||||
9. History_________________________________|delimitMateHistory|
|
||||
5. Mappings________________________________|delimitMateMappings|
|
||||
6. Functions_______________________________|delimitMateFunctions|
|
||||
7. TODO list_______________________________|delimitMateTodo|
|
||||
8. Maintainer______________________________|delimitMateMaintainer|
|
||||
9. Credits_________________________________|delimitMateCredits|
|
||||
10. History_________________________________|delimitMateHistory|
|
||||
|
||||
==============================================================================
|
||||
1.- INTRODUCTION *delimitMateIntro*
|
||||
@@ -49,11 +51,234 @@ 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.
|
||||
|
||||
NOTE 1: If you have any trouble with this plugin, please run |:DelimitMateTest|
|
||||
in a new buffer to see what is not working.
|
||||
|
||||
NOTE 2: |'timeout'| needs to be set when working in the terminal, otherwise you
|
||||
might find weird behaviour with mappings including <Esc> or arrow keys.
|
||||
|
||||
NOTE 3: Abbreiations set with |:iabbrev| will not be expanded by delimiters
|
||||
used on delimitMate, you should use <C-]> (read |i_CTRL-]|) to expand them on
|
||||
the go.
|
||||
|
||||
==============================================================================
|
||||
2. FUNCTIONALITY *delimitMateFunctionality*
|
||||
2. CUSTOMIZATION *delimitMateOptions*
|
||||
|
||||
You can create your own mappings for some features using the global functions.
|
||||
Read |DelimitMateFunctions| for more info.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.1 AUTOMATIC CLOSING AND EXITING *delimitMateAutoClose*
|
||||
2.1 OPTIONS SUMMARY *delimitMateOptionSummary*
|
||||
|
||||
The behaviour of this script can be customized setting the following options
|
||||
in your vimrc file. You can use local options to set the configuration for
|
||||
specific file types, see |delimitMateOptionDetails| for examples.
|
||||
|
||||
|'loaded_delimitMate'| Turns off the script.
|
||||
|
||||
|'delimitMate_autoclose'| Tells delimitMate whether to automagically
|
||||
insert the closing delimiter.
|
||||
|
||||
|'delimitMate_matchpairs'| Tells delimitMate which characters are
|
||||
matching pairs.
|
||||
|
||||
|'delimitMate_quotes'| Tells delimitMate which quotes should be
|
||||
used.
|
||||
|
||||
|'delimitMate_nesting_quotes'| Tells delimitMate which quotes should be
|
||||
allowed to be nested.
|
||||
|
||||
|'delimitMate_visual_leader'| Sets the leader to be used in visual mode.
|
||||
|
||||
|'delimitMate_expand_cr'| Turns on/off the expansion of <CR>.
|
||||
|
||||
|'delimitMate_expand_space'| Turns on/off the expansion of <Space>.
|
||||
|
||||
|'delimitMate_smart_quotes'| Turns on/off the "smart quotes" feature.
|
||||
|
||||
|'delimitMate_balance_matchpairs'|Turns on/off the "balance matching pairs"
|
||||
feature.
|
||||
|
||||
|'delimitMate_excluded_regions'| Turns off the script for the given regions or
|
||||
syntax group names.
|
||||
|
||||
|'delimitMate_excluded_ft'| Turns off the script for the given file types.
|
||||
|
||||
|'delimitMate_apostrophes'| Tells delimitMate how it should "fix"
|
||||
balancing of single quotes when used as
|
||||
apostrophes. NOTE: Not needed any more, kept
|
||||
for compatibility with older versions.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.2 OPTIONS DETAILS *delimitMateOptionDetails*
|
||||
|
||||
Add the shown lines to your vimrc file in order to set the below options.
|
||||
Buffer variables take precedence over global ones and can be used along with
|
||||
autocmd to modify delimitMate's behavior for specific file types, read more in
|
||||
|delimitMateFileType|.
|
||||
|
||||
Note: Use buffer variables only to set options for specific file types using
|
||||
:autocmd, use global variables to set options for every buffer. Read more in
|
||||
|g:var| and |b:var|.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*'loaded_delimitMate'*
|
||||
*'b:loaded_delimitMate'*
|
||||
This option prevents delimitMate from loading.
|
||||
e.g.: >
|
||||
let loaded_delimitMate = 1
|
||||
au FileType mail let b:loaded_delimitMate = 1
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'delimitMate_autoclose'*
|
||||
*'b:delimitMate_autoclose'*
|
||||
Values: 0 or 1. ~
|
||||
Default: 1 ~
|
||||
|
||||
If this option is set to 0, delimitMate will not add a closing delimiter
|
||||
automagically. See |delimitMateAutoClose| for details.
|
||||
e.g.: >
|
||||
let delimitMate_autoclose = 0
|
||||
au FileType mail let b:delimitMate_autoclose = 0
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'delimitMate_matchpairs'*
|
||||
*'b:delimitMate_matchpairs'*
|
||||
Values: A string with |'matchpairs'| syntax, plus support for multi-byte~
|
||||
characters.~
|
||||
Default: &matchpairs ~
|
||||
|
||||
Use this option to tell delimitMate which characters should be considered
|
||||
matching pairs. Read |delimitMateAutoClose| for details.
|
||||
e.g: >
|
||||
let delimitMate_matchpairs = "(:),[:],{:},<:>"
|
||||
au FileType vim,html let b:delimitMate_matchpairs = "(:),[:],{:},<:>"
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'delimitMate_quotes'*
|
||||
*'b:delimitMate_quotes'*
|
||||
Values: A string of characters separated by spaces. ~
|
||||
Default: "\" ' `" ~
|
||||
|
||||
Use this option to tell delimitMate which characters should be considered as
|
||||
quotes. Read |delimitMateAutoClose| for details.
|
||||
e.g.: >
|
||||
let delimitMate_quotes = "\" ' ` *"
|
||||
au FileType html let b:delimitMate_quotes = "\" '"
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'delimitMate_nesting_quotes'*
|
||||
*'b:delimitMate_nesting_quotes'*
|
||||
Values: A list of quotes. ~
|
||||
Default: [] ~
|
||||
|
||||
Quotes listed here will not be able to jump out of the empty pair, thus
|
||||
allowing the autoclosed quotes to be nested.
|
||||
e.g.: >
|
||||
let delimitMate_nesting_quotes = ['"','`']
|
||||
au FileType python let b:delimitMate_nesting_quotes = ['"']
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'delimitMate_visual_leader'*
|
||||
*'b:delimitMate_visual_leader'*
|
||||
Values: Any character. ~
|
||||
Default: q ~
|
||||
|
||||
The value of this option will be used to wrap the selection in visual mode
|
||||
when followed by a delimiter. Read |delimitMateVisualWrap| for details.
|
||||
e.g: >
|
||||
let delimitMate_visual_leader = "f"
|
||||
au FileType html let b:delimitMate_visual_leader = "f"
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'delimitMate_expand_cr'*
|
||||
*'b:delimitMate_expand_cr'*
|
||||
Values: 1 or 0 ~
|
||||
Default: 0 ~
|
||||
|
||||
This option turns on/off the expansion of <CR>. Read |delimitMateExpansion|
|
||||
for details.
|
||||
e.g.: >
|
||||
let delimitMate_expand_cr = 1
|
||||
au FileType mail let b:delimitMate_expand_cr = 1
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'delimitMate_expand_space'*
|
||||
*'b:delimitMate_expand_space'*
|
||||
Values: 1 or 0 ~
|
||||
Default: 0 ~
|
||||
|
||||
This option turns on/off the expansion of <Space>. Read |delimitMateExpansion|
|
||||
for details.
|
||||
e.g.: >
|
||||
let delimitMate_expand_space = 1
|
||||
au FileType tcl let b:delimitMate_expand_space = 1
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'delimitMate_smart_quotes'*
|
||||
*'b:delimitMate_smart_quotes'*
|
||||
Values: 1 or 0 ~
|
||||
Default: 1 ~
|
||||
|
||||
This option turns on/off the smart quotes feature. Read
|
||||
|delimitMateSmartQuotes| for details.
|
||||
e.g.: >
|
||||
let delimitMate_smart_quotes = 0
|
||||
au FileType tcl let b:delimitMate_smart_quotes = 0
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'delimitMate_balance_matchpairs'*
|
||||
*'b:delimitMate_balance_matchpairs'*
|
||||
Values: 1 or 0 ~
|
||||
Default: 0 ~
|
||||
|
||||
This option turns on/off the balancing of matching pairs. Read
|
||||
|delimitMateBalance| for details.
|
||||
e.g.: >
|
||||
let delimitMate_balance_matchpairs = 1
|
||||
au FileType tcl let b:delimitMate_balance_matchpairs = 1
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'delimitMate_excluded_regions'*
|
||||
Values: A string of syntax group names names separated by single commas. ~
|
||||
Default: Comment ~
|
||||
|
||||
This options turns delimitMate off for the listed regions, read |group-name|
|
||||
for more info about what is a region.
|
||||
e.g.: >
|
||||
let delimitMate_excluded_regions = "Comments,String"
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'delimitMate_excluded_ft'*
|
||||
Values: A string of file type names separated by single commas. ~
|
||||
Default: Empty. ~
|
||||
|
||||
This options turns delimitMate off for the listed file types, use this option
|
||||
only if you don't want any of the features it provides on those file types.
|
||||
e.g.: >
|
||||
let delimitMate_excluded_ft = "mail,txt"
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'delimitMate_apostrophes'*
|
||||
Values: Strings separated by ":". ~
|
||||
Default: No longer used. ~
|
||||
|
||||
NOTE: This feature is turned off by default, it's been kept for compatibility
|
||||
with older version, read |delimitMateSmartQuotes| for details.
|
||||
If auto-close is enabled, this option tells delimitMate how to try to fix the
|
||||
balancing of single quotes when used as apostrophes. The values of this option
|
||||
are strings of text where a single quote would be used as an apostrophe (e.g.:
|
||||
the "n't" of wouldn't or can't) separated by ":". Set it to an empty string to
|
||||
disable this feature.
|
||||
e.g.: >
|
||||
let delimitMate_apostrophes = ""
|
||||
au FileType tcl let delimitMate_apostrophes = ""
|
||||
<
|
||||
==============================================================================
|
||||
3. FUNCTIONALITY *delimitMateFunctionality*
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
3.1 AUTOMATIC CLOSING AND EXITING *delimitMateAutoClose*
|
||||
|
||||
With automatic closing enabled, if an opening delimiter is inserted the plugin
|
||||
inserts the closing delimiter and places the cursor between the pair. With
|
||||
@@ -94,7 +319,7 @@ NOTE: Abbreviations will not be expanded by delimiters used on delimitMate,
|
||||
you should use <C-]> (read |i_CTRL-]|) to expand them on the go.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.2 EXPANSION OF SPACE AND CAR RETURN *delimitMateExpansion*
|
||||
3.2 EXPANSION OF SPACE AND CAR RETURN *delimitMateExpansion*
|
||||
|
||||
When the cursor is inside an empty pair of delimiters, <Space> and <CR> can be
|
||||
expanded, see |'delimitMate_expand_space'| and
|
||||
@@ -122,7 +347,7 @@ in expansions global, so they can be used to make custom mappings. Read
|
||||
|delimitMateFunctions| for more details.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.3 BACKSPACE *delimitMateBackspace*
|
||||
3.3 BACKSPACE *delimitMateBackspace*
|
||||
|
||||
If you press backspace inside an empty pair, both delimiters are deleted. When
|
||||
expansions are enabled, <BS> will also delete the expansions. NOTE that
|
||||
@@ -148,14 +373,14 @@ e.g. typing at the "|": >
|
||||
<
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.4 WRAPPING OF VISUAL SELECTION *delimitMateVisualWrapping*
|
||||
3.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.
|
||||
NOTE that this feature brakes the repeat 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): >
|
||||
|
||||
@@ -165,7 +390,7 @@ e.g. (selection represented between square brackets): >
|
||||
<
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.5 SMART QUOTES *delimitMateSmartQuotes*
|
||||
3.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
|
||||
@@ -177,12 +402,28 @@ e.g. typing at the "|": >
|
||||
|
||||
What | Before | After
|
||||
=======================================
|
||||
" | Text | | Text "|"
|
||||
" | "String| | "String"|
|
||||
" | let i = "| | let i = "|"
|
||||
' | I| | I'|
|
||||
'm | I| | I'm|
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
2.6 FILE TYPE BASED CONFIGURATION *delimitMateFileType*
|
||||
3.6 BALANCING MATCHING PAIRS *delimitMateBalance*
|
||||
|
||||
When inserting an opening paren and |'delimitMate_balance_matchpairs'| is
|
||||
enabled, delimitMate will try to balance the closing pairs in the current
|
||||
line.
|
||||
|
||||
e.g. typing at the "|": >
|
||||
|
||||
What | Before | After
|
||||
=======================================
|
||||
( | |) | (|)
|
||||
( | | | (|)
|
||||
( | (|) | ((|))
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
3.7 FILE TYPE BASED CONFIGURATION *delimitMateFileType*
|
||||
|
||||
delimitMate options can be set globally for all buffers using global
|
||||
("regular") variables in your |vimrc| file. But |:autocmd| can be used to set
|
||||
@@ -202,7 +443,7 @@ 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*
|
||||
3.8 SYNTAX AWARENESS *delimitMateSyntax*
|
||||
|
||||
The features of this plug-in might not be always helpful, comments and strings
|
||||
usualy don't need auto-completion. delimitMate monitors which region is being
|
||||
@@ -215,192 +456,6 @@ 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*
|
||||
|
||||
@@ -487,10 +542,56 @@ represented by an "|": >
|
||||
<
|
||||
|
||||
==============================================================================
|
||||
5. FUNCTIONS *delimitMateFunctions*
|
||||
5. MAPPINGS *delimitMateMappings*
|
||||
|
||||
Functions should be used enclosed between <C-R>= and <CR>, otherwise they
|
||||
might not work as expected or at all.
|
||||
delimitMate doesn't override any existing map, so you may encounter that it
|
||||
doesn't work as expected because a mapping is missing. In that case, the
|
||||
conflicting mappings should be resolved by either disabling the conflicting
|
||||
mapping or creating a custom mappings.
|
||||
|
||||
In order to make custom mappings easier and prevent overwritting existing
|
||||
ones, delimitMate uses the |<Plug>| + |hasmapto()| (|usr_41.txt|) construct
|
||||
for its mappings.
|
||||
|
||||
The following are the mappings alway set by delimitMate:
|
||||
|
||||
<BS> is mapped to <Plug>delimitMateBS
|
||||
<S-BS> is mapped to <Plug>delimitMateS-BS
|
||||
<S-Tab> is mapped to <Plug>delimitMateS-Tab
|
||||
<Del> is mapped to <Plug>delimitMateDel
|
||||
<Esc> is mapped to <Plug>delimitMateEsc
|
||||
<Left> is mapped to <Plug>delimitMateLeft
|
||||
<Right> is mapped to <Plug>delimitMateRight
|
||||
<Home> is mapped to <Plug>delimitMateHome
|
||||
<End> is mapped to <Plug>delimitMateEnd
|
||||
<Up> is mapped to <Plug>delimitMateUp
|
||||
<Down> is mapped to <Plug>delimitMateDown
|
||||
<PageUp> is mapped to <Plug>delimitMatePageUp
|
||||
<PageDown> is mapped to <Plug>delimitMatePageDown
|
||||
<S-Down> is mapped to <Plug>delimitMateS-Down
|
||||
<S-Up> is mapped to <Plug>delimitMateS-Up
|
||||
<LeftMouse> is mapped to <Plug>delimitMateMLeftMouse
|
||||
<RightMouse> is mapped to <Plug>delimitMateMRightMouse
|
||||
|
||||
The rest of the mappings correspond to parens, quotes, CR, Space, etc. and they
|
||||
depend on the values of the delimitMate options, they have the following form:
|
||||
|
||||
<Plug>delimitMate + char
|
||||
|
||||
e.g.: for "(":
|
||||
|
||||
( is mapped to <Plug>delimitMate(
|
||||
|
||||
e.g.: If you have <CR> expansion enabled, you might want to skip it on pop-up
|
||||
menus:
|
||||
|
||||
imap <expr> <CR> pumvisible() ?
|
||||
\"\<c-y>" :
|
||||
\ "<Plug>delimitMateCR"
|
||||
|
||||
|
||||
==============================================================================
|
||||
6. FUNCTIONS *delimitMateFunctions*
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
delimitMate#WithinEmptyPair() *delimitMate_WithinEmptyPair()*
|
||||
@@ -503,28 +604,6 @@ e.g.: >
|
||||
\ "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()*
|
||||
|
||||
@@ -542,13 +621,13 @@ e.g.: You can use this to create your own mapping to jump over any delimiter.
|
||||
<
|
||||
|
||||
==============================================================================
|
||||
6. TODO LIST *delimitMateTodo*
|
||||
7. TODO LIST *delimitMateTodo*
|
||||
|
||||
- Automatic set-up by file type.
|
||||
- Make block-wise visual wrapping work on un-even regions.
|
||||
|
||||
==============================================================================
|
||||
7. MAINTAINER *delimitMateMaintainer*
|
||||
8. MAINTAINER *delimitMateMaintainer*
|
||||
|
||||
Hi there! My name is Israel Chauca F. and I can be reached at:
|
||||
mailto:israelchauca@gmail.com
|
||||
@@ -557,7 +636,7 @@ Feel free to send me any suggestions and/or comments about this plugin, I'll
|
||||
be very pleased to read them.
|
||||
|
||||
==============================================================================
|
||||
8. CREDITS *delimitMateCredits*
|
||||
9. CREDITS *delimitMateCredits*
|
||||
|
||||
Some of the code that make this script is modified or just shamelessly copied
|
||||
from the following sources:
|
||||
@@ -585,12 +664,23 @@ from the following sources:
|
||||
This script was inspired by the auto-completion of delimiters on TextMate.
|
||||
|
||||
==============================================================================
|
||||
9. HISTORY *delimitMateHistory*
|
||||
10. HISTORY *delimitMateHistory*
|
||||
|
||||
Version Date Release notes ~
|
||||
|---------|------------|-----------------------------------------------------|
|
||||
2.4 2010-07-29 * Current release:
|
||||
- Unbalanced parens: see :help delimitMateBalance.
|
||||
2.5 2010-09-22 * Current release:
|
||||
- Better handling of mappings.
|
||||
- Add report for mappings in |:DelimitMateTest|.
|
||||
- Allow the use of "|" and multi-byte characters in
|
||||
|'delimitMate_quotes'| and |'delimitMate_matchpairs'|.
|
||||
- Allow commands to be concatenated using |.
|
||||
|---------|------------|-----------------------------------------------------|
|
||||
2.4.1 2010-07-31 * - Fix problem with <Home> and <End>.
|
||||
- Add missing doc on |'delimitMate_smart_quotes'|,
|
||||
|delimitMateBalance| and
|
||||
|'delimitMate_balance_matchpairs'|.
|
||||
|---------|------------|-----------------------------------------------------|
|
||||
2.4 2010-07-29 * - Unbalanced parens: see :help delimitMateBalance.
|
||||
- Visual wrapping now works on block-wise visual
|
||||
with some limitations.
|
||||
- Arrow keys didn't work on terminal.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
" ============================================================================
|
||||
" File: plugin/delimitMate.vim
|
||||
" Version: 2.4
|
||||
" Modified: 2010-07-29
|
||||
" Version: 2.5
|
||||
" Modified: 2010-09-22
|
||||
" Description: This plugin provides auto-completion for quotes, parens, etc.
|
||||
" Maintainer: Israel Chauca F. <israelchauca@gmail.com>
|
||||
" Manual: Read ":help delimitMate".
|
||||
@@ -27,12 +27,193 @@ if v:version < 700
|
||||
endif
|
||||
|
||||
let s:loaded_delimitMate = 1
|
||||
let delimitMate_version = "2.4"
|
||||
let delimitMate_version = "2.5"
|
||||
|
||||
function! s:option_init(name, default) "{{{
|
||||
let b = exists("b:delimitMate_" . a:name)
|
||||
let g = exists("g:delimitMate_" . a:name)
|
||||
let prefix = "_l_delimitMate_"
|
||||
|
||||
if !b && !g
|
||||
let sufix = a:default
|
||||
elseif !b && g
|
||||
exec "let sufix = g:delimitMate_" . a:name
|
||||
else
|
||||
exec "let sufix = b:delimitMate_" . a:name
|
||||
endif
|
||||
if exists("b:" . prefix . a:name)
|
||||
exec "unlockvar! b:" . prefix . a:name
|
||||
endif
|
||||
exec "let b:" . prefix . a:name . " = " . string(sufix)
|
||||
exec "lockvar! b:" . prefix . a:name
|
||||
endfunction "}}}
|
||||
|
||||
function! s:init() "{{{
|
||||
" Initialize variables:
|
||||
|
||||
" autoclose
|
||||
call s:option_init("autoclose", 1)
|
||||
|
||||
" matchpairs
|
||||
call s:option_init("matchpairs", string(&matchpairs)[1:-2])
|
||||
call s:option_init("matchpairs_list", split(b:_l_delimitMate_matchpairs, ','))
|
||||
call s:option_init("left_delims", split(b:_l_delimitMate_matchpairs, ':.,\='))
|
||||
call s:option_init("right_delims", split(b:_l_delimitMate_matchpairs, ',\=.:'))
|
||||
|
||||
" quotes
|
||||
call s:option_init("quotes", "\" ' `")
|
||||
call s:option_init("quotes_list", split(b:_l_delimitMate_quotes))
|
||||
|
||||
" nesting_quotes
|
||||
call s:option_init("nesting_quotes", [])
|
||||
|
||||
" excluded_regions
|
||||
call s:option_init("excluded_regions", "Comment")
|
||||
call s:option_init("excluded_regions_list", split(b:_l_delimitMate_excluded_regions, ',\s*'))
|
||||
let enabled = len(b:_l_delimitMate_excluded_regions_list) > 0
|
||||
call s:option_init("excluded_regions_enabled", enabled)
|
||||
|
||||
" excluded filetypes
|
||||
call s:option_init("excluded_ft", "")
|
||||
|
||||
" visual_leader
|
||||
let leader = exists('b:maplocalleader') ? b:maplocalleader :
|
||||
\ exists('g:mapleader') ? g:mapleader : "\\"
|
||||
call s: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 s:option_init("expand_space", 0)
|
||||
|
||||
" expand_cr
|
||||
if exists("b:delimitMate_expand_cr") && type(b:delimitMate_expand_cr) == type("")
|
||||
echom "b:delimitMate_expand_cr is '".b:delimitMate_expand_cr."' but it must be either 1 or 0!"
|
||||
echom "Read :help 'delimitMate_expand_cr' for more details."
|
||||
unlet b:delimitMate_expand_cr
|
||||
let b:delimitMate_expand_cr = 1
|
||||
endif
|
||||
if exists("g:delimitMate_expand_cr") && type(g:delimitMate_expand_cr) == type("")
|
||||
echom "delimitMate_expand_cr is '".g:delimitMate_expand_cr."' but it must be either 1 or 0!"
|
||||
echom "Read :help 'delimitMate_expand_cr' for more details."
|
||||
unlet g:delimitMate_expand_cr
|
||||
let g:delimitMate_expand_cr = 1
|
||||
endif
|
||||
if (&backspace !~ 'eol' || &backspace !~ 'start') &&
|
||||
\ ((exists('b:delimitMate_expand_cr') && b:delimitMate_expand_cr == 1) ||
|
||||
\ (exists('g:delimitMate_expand_cr') && g:delimitMate_expand_cr == 1))
|
||||
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 s:option_init("expand_cr", 0)
|
||||
|
||||
" smart_quotes
|
||||
call s:option_init("smart_quotes", 1)
|
||||
|
||||
" apostrophes
|
||||
call s:option_init("apostrophes", "")
|
||||
call s:option_init("apostrophes_list", split(b:_l_delimitMate_apostrophes, ":\s*"))
|
||||
|
||||
" tab2exit
|
||||
call s:option_init("tab2exit", 1)
|
||||
|
||||
" balance_matchpairs
|
||||
call s:option_init("balance_matchpairs", 0)
|
||||
|
||||
let b:_l_delimitMate_buffer = []
|
||||
|
||||
let b:loaded_delimitMate = 1
|
||||
|
||||
endfunction "}}} Init()
|
||||
|
||||
"}}}
|
||||
|
||||
" Functions: {{{
|
||||
|
||||
function! s:Map() "{{{
|
||||
" Set mappings:
|
||||
try
|
||||
let save_cpo = &cpo
|
||||
let save_keymap = &keymap
|
||||
let save_iminsert = &iminsert
|
||||
let save_imsearch = &imsearch
|
||||
set keymap=
|
||||
set cpo&vim
|
||||
if b:_l_delimitMate_autoclose
|
||||
call s:AutoClose()
|
||||
else
|
||||
call s:NoAutoClose()
|
||||
endif
|
||||
call s:VisualMaps()
|
||||
call s:ExtraMappings()
|
||||
finally
|
||||
let &cpo = save_cpo
|
||||
let &keymap = save_keymap
|
||||
let &iminsert = save_iminsert
|
||||
let &imsearch = save_imsearch
|
||||
endtry
|
||||
|
||||
let b:delimitMate_enabled = 1
|
||||
|
||||
endfunction "}}} Map()
|
||||
|
||||
function! s:Unmap() " {{{
|
||||
let imaps =
|
||||
\ b:_l_delimitMate_right_delims +
|
||||
\ b:_l_delimitMate_left_delims +
|
||||
\ b:_l_delimitMate_quotes_list +
|
||||
\ b:_l_delimitMate_apostrophes_list +
|
||||
\ ['<BS>', '<S-BS>', '<Del>', '<CR>', '<Space>', '<S-Tab>', '<Esc>'] +
|
||||
\ ['<Up>', '<Down>', '<Left>', '<Right>', '<LeftMouse>', '<RightMouse>'] +
|
||||
\ ['<Home>', '<End>', '<PageUp>', '<PageDown>', '<S-Down>', '<S-Up>']
|
||||
|
||||
let vmaps =
|
||||
\ b:_l_delimitMate_right_delims +
|
||||
\ b:_l_delimitMate_left_delims +
|
||||
\ b:_l_delimitMate_quotes_list
|
||||
|
||||
for map in imaps
|
||||
if maparg(map, "i") =~? 'delimitMate'
|
||||
if map == '|'
|
||||
let map = '<Bar>'
|
||||
endif
|
||||
exec 'silent! iunmap <buffer> ' . map
|
||||
endif
|
||||
endfor
|
||||
|
||||
if !exists("b:_l_delimitMate_visual_leader")
|
||||
let vleader = ""
|
||||
else
|
||||
let vleader = b:_l_delimitMate_visual_leader
|
||||
endif
|
||||
for map in vmaps
|
||||
if map == '|'
|
||||
let map = '<Bar>'
|
||||
endif
|
||||
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 " }}} s:Unmap()
|
||||
|
||||
function! s:TestMappingsDo() "{{{
|
||||
%d
|
||||
if !exists("g:delimitMate_testing")
|
||||
silent call delimitMate#TestMappings()
|
||||
else
|
||||
@@ -42,9 +223,9 @@ function! s:TestMappingsDo() "{{{
|
||||
let b:delimitMate_expand_cr = i
|
||||
for a in [0,1]
|
||||
let b:delimitMate_autoclose = a
|
||||
call delimitMate#Init()
|
||||
call delimitMate#UnMap()
|
||||
call delimitMate#Map()
|
||||
call s:init()
|
||||
call s:Unmap()
|
||||
call s:Map()
|
||||
call delimitMate#TestMappings()
|
||||
normal o
|
||||
endfor
|
||||
@@ -59,14 +240,14 @@ endfunction "}}}
|
||||
|
||||
function! s:DelimitMateDo(...) "{{{
|
||||
" Initialize settings:
|
||||
call delimitMate#Init()
|
||||
call s: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()
|
||||
call s:Unmap()
|
||||
|
||||
" Finish here:
|
||||
return 1
|
||||
@@ -74,11 +255,11 @@ function! s:DelimitMateDo(...) "{{{
|
||||
|
||||
" First, remove all magic, if needed:
|
||||
if exists("b:delimitMate_enabled") && b:delimitMate_enabled == 1
|
||||
call delimitMate#UnMap()
|
||||
call s:Unmap()
|
||||
endif
|
||||
|
||||
" Now, add magic:
|
||||
call delimitMate#Map()
|
||||
call s:Map()
|
||||
|
||||
if a:0 > 0
|
||||
echo "delimitMate has been reset."
|
||||
@@ -86,17 +267,153 @@ function! s:DelimitMateDo(...) "{{{
|
||||
endfunction "}}}
|
||||
|
||||
function! s:DelimitMateSwitch() "{{{
|
||||
call delimitMate#Init()
|
||||
call s:init()
|
||||
if exists("b:delimitMate_enabled") && b:delimitMate_enabled
|
||||
call delimitMate#UnMap()
|
||||
call s:Unmap()
|
||||
echo "delimitMate has been disabled."
|
||||
else
|
||||
call delimitMate#UnMap()
|
||||
call delimitMate#Map()
|
||||
call s:Unmap()
|
||||
call s:Map()
|
||||
echo "delimitMate has been enabled."
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! s:Finish()
|
||||
if exists('g:delimitMate_loaded')
|
||||
return delimitMate#Finish()
|
||||
endif
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! s:FlushBuffer()
|
||||
if exists('g:delimitMate_loaded')
|
||||
return delimitMate#FlushBuffer()
|
||||
endif
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
"}}}
|
||||
|
||||
" Mappers: {{{
|
||||
function! s:NoAutoClose() "{{{
|
||||
" inoremap <buffer> ) <C-R>=delimitMate#SkipDelim('\)')<CR>
|
||||
for delim in b:_l_delimitMate_right_delims + b:_l_delimitMate_quotes_list
|
||||
if delim == '|'
|
||||
let delim = '<Bar>'
|
||||
endif
|
||||
exec 'inoremap <silent> <Plug>delimitMate' . delim . ' <C-R>=delimitMate#SkipDelim("' . escape(delim,'"') . '")<CR>'
|
||||
exec 'silent! imap <unique> <buffer> '.delim.' <Plug>delimitMate'.delim
|
||||
endfor
|
||||
endfunction "}}}
|
||||
|
||||
function! s:AutoClose() "{{{
|
||||
" Add matching pair and jump to the midle:
|
||||
" inoremap <silent> <buffer> ( ()<Left>
|
||||
let i = 0
|
||||
while i < len(b:_l_delimitMate_matchpairs_list)
|
||||
let ld = b:_l_delimitMate_left_delims[i] == '|' ? '<bar>' : b:_l_delimitMate_left_delims[i]
|
||||
let rd = b:_l_delimitMate_right_delims[i] == '|' ? '<bar>' : b:_l_delimitMate_right_delims[i]
|
||||
exec 'inoremap <silent> <Plug>delimitMate' . ld . ' ' . ld . '<C-R>=delimitMate#ParenDelim("' . escape(rd, '|') . '")<CR>'
|
||||
exec 'silent! imap <unique> <buffer> '.ld.' <Plug>delimitMate'.ld
|
||||
let i += 1
|
||||
endwhile
|
||||
|
||||
" Exit from inside the matching pair:
|
||||
for delim in b:_l_delimitMate_right_delims
|
||||
exec 'inoremap <silent> <Plug>delimitMate' . delim . ' <C-R>=delimitMate#JumpOut("\' . delim . '")<CR>'
|
||||
exec 'silent! imap <unique> <buffer> ' . delim . ' <Plug>delimitMate'. delim
|
||||
endfor
|
||||
|
||||
" Add matching quote and jump to the midle, or exit if inside a pair of matching quotes:
|
||||
" inoremap <silent> <buffer> " <C-R>=delimitMate#QuoteDelim("\"")<CR>
|
||||
for delim in b:_l_delimitMate_quotes_list
|
||||
if delim == '|'
|
||||
let delim = '<Bar>'
|
||||
endif
|
||||
exec 'inoremap <silent> <Plug>delimitMate' . delim . ' <C-R>=delimitMate#QuoteDelim("\' . delim . '")<CR>'
|
||||
exec 'silent! imap <unique> <buffer> ' . delim . ' <Plug>delimitMate' . delim
|
||||
endfor
|
||||
|
||||
" Try to fix the use of apostrophes (kept for backward compatibility):
|
||||
" inoremap <silent> <buffer> n't n't
|
||||
for map in b:_l_delimitMate_apostrophes_list
|
||||
exec "inoremap <silent> " . map . " " . map
|
||||
exec 'silent! imap <unique> <buffer> ' . map . ' <Plug>delimitMate' . map
|
||||
endfor
|
||||
endfunction "}}}
|
||||
|
||||
function! s:VisualMaps() " {{{
|
||||
let VMapMsg = "delimitMate: delimitMate is disabled on blockwise visual mode."
|
||||
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:_l_delimitMate_right_delims + b:_l_delimitMate_left_delims + b:_l_delimitMate_quotes_list
|
||||
exec "vnoremap <silent> <expr> <Plug>delimitMateVisual" . del . ' delimitMate#Visual("' . escape(del, '")|') . '")'
|
||||
exec 'silent! vmap <unique> <buffer> ' . vleader . del . ' <Plug>delimitMateVisual' . del
|
||||
endfor
|
||||
endfunction "}}}
|
||||
|
||||
function! s:ExtraMappings() "{{{
|
||||
" If pair is empty, delete both delimiters:
|
||||
inoremap <silent> <Plug>delimitMateBS <C-R>=delimitMate#BS()<CR>
|
||||
" If pair is empty, delete closing delimiter:
|
||||
inoremap <silent> <expr> <Plug>delimitMateS-BS delimitMate#WithinEmptyPair() ? "\<C-R>=delimitMate#Del()\<CR>" : "\<S-BS>"
|
||||
" Expand return if inside an empty pair:
|
||||
inoremap <silent> <Plug>delimitMateCR <C-R>=delimitMate#ExpandReturn()<CR>
|
||||
" Expand space if inside an empty pair:
|
||||
inoremap <silent> <Plug>delimitMateSpace <C-R>=delimitMate#ExpandSpace()<CR>
|
||||
" Jump out ot any empty pair:
|
||||
inoremap <silent> <Plug>delimitMateS-Tab <C-R>=delimitMate#JumpAny("\<S-Tab>")<CR>
|
||||
" Change char buffer on Del:
|
||||
inoremap <silent> <Plug>delimitMateDel <C-R>=delimitMate#Del()<CR>
|
||||
" Flush the char buffer on movement keystrokes or when leaving insert mode:
|
||||
for map in ['Esc', 'Left', 'Right', 'Home', 'End']
|
||||
exec 'inoremap <silent> <Plug>delimitMate'.map.' <C-R>=<SID>Finish()<CR><'.map.'>'
|
||||
if !hasmapto('<Plug>delimitMate'.map, 'i')
|
||||
exec 'silent! imap <unique> <buffer> <'.map.'> <Plug>delimitMate'.map
|
||||
endif
|
||||
endfor
|
||||
" Except when pop-up menu is active:
|
||||
for map in ['Up', 'Down', 'PageUp', 'PageDown', 'S-Down', 'S-Up']
|
||||
exec 'inoremap <silent> <expr> <Plug>delimitMate'.map.' pumvisible() ? "\<'.map.'>" : "\<C-R>=\<SID>Finish()\<CR>\<'.map.'>"'
|
||||
if !hasmapto('<Plug>delimitMate'.map, 'i')
|
||||
exec 'silent! imap <unique> <buffer> <'.map.'> <Plug>delimitMate'.map
|
||||
endif
|
||||
endfor
|
||||
" Avoid ambiguous mappings:
|
||||
for map in ['LeftMouse', 'RightMouse']
|
||||
exec 'inoremap <silent> <Plug>delimitMateM'.map.' <C-R>=delimitMate#Finish()<CR><'.map.'>'
|
||||
if !hasmapto('<Plug>delimitMate'.map, 'i')
|
||||
exec 'silent! imap <unique> <buffer> <'.map.'> <Plug>delimitMateM'.map
|
||||
endif
|
||||
endfor
|
||||
|
||||
" Map away!
|
||||
if !hasmapto('<Plug>delimitMateDel', 'i')
|
||||
silent! imap <unique> <buffer> <Del> <Plug>delimitMateDel
|
||||
endif
|
||||
if !hasmapto('<Plug>delimitMateBS','i')
|
||||
silent! imap <unique> <buffer> <BS> <Plug>delimitMateBS
|
||||
endif
|
||||
if !hasmapto('<Plug>delimitMateS-BS','i')
|
||||
silent! imap <unique> <buffer> <S-BS> <Plug>delimitMateS-BS
|
||||
endif
|
||||
if b:_l_delimitMate_expand_cr != 0 && !hasmapto('<Plug>delimitMateCR', 'i')
|
||||
silent! imap <unique> <buffer> <CR> <Plug>delimitMateCR
|
||||
endif
|
||||
if b:_l_delimitMate_expand_space != 0 && !hasmapto('<Plug>delimitMateSpace', 'i')
|
||||
silent! imap <unique> <buffer> <Space> <Plug>delimitMateSpace
|
||||
endif
|
||||
if b:_l_delimitMate_tab2exit && !hasmapto('<Plug>delimitMateS-Tab', 'i')
|
||||
silent! imap <unique> <buffer> <S-Tab> <Plug>delimitMateS-Tab
|
||||
endif
|
||||
" The following simply creates an ambiguous mapping so vim fully processes
|
||||
" the escape sequence for terminal keys, see 'ttimeout' for a rough
|
||||
" explanation, this just forces it to work
|
||||
if !has('gui_running')
|
||||
imap <silent> <C-[>OC <RIGHT>
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
"}}}
|
||||
|
||||
" Commands: {{{
|
||||
@@ -104,13 +421,13 @@ endfunction "}}}
|
||||
call s:DelimitMateDo()
|
||||
|
||||
" Let me refresh without re-loading the buffer:
|
||||
command! DelimitMateReload call s:DelimitMateDo(1)
|
||||
command! -bar DelimitMateReload call s:DelimitMateDo(1)
|
||||
|
||||
" Quick test:
|
||||
command! DelimitMateTest call s:TestMappingsDo()
|
||||
command! -bar DelimitMateTest silent call s:TestMappingsDo()
|
||||
|
||||
" Switch On/Off:
|
||||
command! DelimitMateSwitch call s:DelimitMateSwitch()
|
||||
command! -bar DelimitMateSwitch call s:DelimitMateSwitch()
|
||||
"}}}
|
||||
|
||||
" Autocommands: {{{
|
||||
@@ -124,14 +441,14 @@ augroup delimitMate
|
||||
" Run on new buffers.
|
||||
autocmd BufNewFile,BufRead,BufEnter *
|
||||
\ if !exists("b:loaded_delimitMate") |
|
||||
\ call <SID>DelimitMateDo() |
|
||||
\ call <SID>DelimitMateDo() |
|
||||
\ endif
|
||||
|
||||
" Flush the char buffer:
|
||||
autocmd InsertEnter * call delimitMate#FlushBuffer()
|
||||
autocmd InsertEnter * call <SID>FlushBuffer()
|
||||
autocmd BufEnter *
|
||||
\ if mode() == 'i' |
|
||||
\ call delimitMate#FlushBuffer() |
|
||||
\ call <SID>FlushBuffer() |
|
||||
\ endif
|
||||
|
||||
augroup END
|
||||
|
||||
Reference in New Issue
Block a user