mirror of
https://github.com/Raimondi/delimitMate.git
synced 2025-12-07 21:24:51 +08:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
edeaff4730 | ||
|
|
c85fee6eb5 | ||
|
|
0ccb143a12 | ||
|
|
941beed3b3 | ||
|
|
739a3e606c | ||
|
|
61cc934b68 | ||
|
|
7aec4532f9 | ||
|
|
6f22aab0b8 | ||
|
|
592cf2fea1 | ||
|
|
3d818560eb | ||
|
|
da66a3f7c9 | ||
|
|
e5ce5b0967 | ||
|
|
03342b8d22 |
21
Makefile
21
Makefile
@@ -4,8 +4,8 @@ SCRIPT=$(wildcard plugin/*.vim)
|
|||||||
AUTOL=autoload/$(PLUGIN).vim
|
AUTOL=autoload/$(PLUGIN).vim
|
||||||
DOC=$(wildcard doc/*.txt)
|
DOC=$(wildcard doc/*.txt)
|
||||||
TESTS=$(wildcard autoload/*Tests.vim)
|
TESTS=$(wildcard autoload/*Tests.vim)
|
||||||
VERSION=$(shell perl -ne 'if (/\*\sCurrent\srelease:/) {s/^\s+(\d+\.\d+).*$$/\1/;print}' $(DOC))
|
VERSION=$(shell perl -ne 'if (/\*\sCurrent\srelease:/) {s/^\s+(\d+\.\S+)\s.*$$/\1/;print}' $(DOC))
|
||||||
VIMFOLDER=~/.vim
|
VIMFOLDER=~/.vim/
|
||||||
VIM=/usr/bin/vim
|
VIM=/usr/bin/vim
|
||||||
|
|
||||||
.PHONY: $(PLUGIN).vba README
|
.PHONY: $(PLUGIN).vba README
|
||||||
@@ -13,7 +13,7 @@ VIM=/usr/bin/vim
|
|||||||
install: vimball
|
install: vimball
|
||||||
@echo install
|
@echo install
|
||||||
$(VIM) -N -c ':so %' -c':q!' $(PLUGIN)-$(VERSION).vba
|
$(VIM) -N -c ':so %' -c':q!' $(PLUGIN)-$(VERSION).vba
|
||||||
cp -f autoload/$(PLUGIN)Tests.vim $(VIMFOLDER)/autoload/$(PLUGIN)Tests.vim
|
cp -f $(TESTS) $(VIMFOLDER)$(TESTS)
|
||||||
|
|
||||||
all: uninstall vimball install README zip gzip
|
all: uninstall vimball install README zip gzip
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@ dist-clean: clean
|
|||||||
uninstall:
|
uninstall:
|
||||||
@echo uninstall
|
@echo uninstall
|
||||||
$(VIM) -N -c':RmVimball' -c':q!' $(PLUGIN)-$(VERSION).vba
|
$(VIM) -N -c':RmVimball' -c':q!' $(PLUGIN)-$(VERSION).vba
|
||||||
rm -f $(VIMFOLDER)/autoload/$(PLUGIN)Tests.txt
|
rm -f $(VIMFOLDER)$(TESTS)
|
||||||
|
|
||||||
undo:
|
undo:
|
||||||
for i in */*.orig; do mv -f "$$i" "$${i%.*}"; done
|
for i in */*.orig; do mv -f "$$i" "$${i%.*}"; done
|
||||||
@@ -45,9 +45,12 @@ $(PLUGIN).vba:
|
|||||||
|
|
||||||
zip:
|
zip:
|
||||||
@echo zip
|
@echo zip
|
||||||
|
rm -f *.zip
|
||||||
zip -r $(PLUGIN).zip doc plugin autoload
|
zip -r $(PLUGIN).zip doc plugin autoload
|
||||||
zip $(PLUGIN).zip -d \*.sw\?
|
zip $(PLUGIN).zip -d \*.sw\?
|
||||||
zip $(PLUGIN).zip -d autoload/$(PLUGIN)Tests.vim
|
zip $(PLUGIN).zip -d \*.orig
|
||||||
|
zip $(PLUGIN).zip -d $(TESTS)
|
||||||
|
ln -f $(PLUGIN).zip $(PLUGIN)-$(VERSION).zip
|
||||||
|
|
||||||
gzip: vimball
|
gzip: vimball
|
||||||
@echo vimball
|
@echo vimball
|
||||||
@@ -57,11 +60,11 @@ release: version all
|
|||||||
|
|
||||||
version:
|
version:
|
||||||
@echo version: $(VERSION)
|
@echo version: $(VERSION)
|
||||||
perl -i.orig -pne 'if (/^"\sVersion:/) {s/(\d+\.\d+)/$(VERSION)/e}' $(SCRIPT) $(AUTOL)
|
perl -i.orig -pne 'if (/^"\sVersion:/) {s/(\d+\.\S+)/$(VERSION)/}' $(SCRIPT) $(AUTOL)
|
||||||
perl -i.orig -pne 'if (/let\sdelimitMate_version/) {s/(\d+\.\d+)/$(VERSION)/e}' $(SCRIPT)
|
perl -i.orig -pne 'if (/let\sdelimitMate_version/) {s/"(\d+\.\S+)"/"$(VERSION)"/}' $(SCRIPT)
|
||||||
perl -i.orig -pne 'if (/beasts/) {s/(v\d+\.\d+)/v.$(VERSION)/e}' $(DOC)
|
perl -i.orig -pne 'if (/beasts/) {s/(v\d+\.\S+)/v$(VERSION)/}' $(DOC)
|
||||||
perl -i.orig -MPOSIX -pne 'if (/^"\sModified:/) {$$now_string = strftime "%F", localtime; s/(\d+-\d+-\d+)/$$now_string/e}' $(SCRIPT) $(AUTOL)
|
perl -i.orig -MPOSIX -pne 'if (/^"\sModified:/) {$$now_string = strftime "%F", localtime; s/(\d+-\d+-\d+)/$$now_string/e}' $(SCRIPT) $(AUTOL)
|
||||||
perl -i.orig -MPOSIX -pne 'if (/^\s+$(VERSION)\s+\d+-\d+-\d+\s+\*/) {$$now_string = strftime "%F", localtime; s/(\d+-\d+-\d+)/$$now_string/e}' $(DOC)
|
perl -i.orig -MPOSIX -pne 'if (/^\s+$(VERSION)\s+\d+-\d+-\d+\s+\*/) {$$now_string = strftime "%F", localtime; s/(\d+-\d+-\d+)/$$now_string/}' $(DOC)
|
||||||
@echo Version: $(VERSION)
|
@echo Version: $(VERSION)
|
||||||
|
|
||||||
echo:
|
echo:
|
||||||
|
|||||||
115
README
115
README
@@ -1,18 +1,20 @@
|
|||||||
*delimitMate* Trying to keep those beasts at bay! v2.2 *delimitMate.txt*
|
*delimitMate* Trying to keep those beasts at bay! v2.3.1 *delimitMate.txt*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
|
||||||
|
MMMM MMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMM MMMMM MMMMMMMMMMMMMMMMMMMMM ~
|
||||||
|
MMMM MMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMM MMM MMMMMMMMMMMMMMMMMMMMM
|
||||||
|
MMMM MMMMMMMMM MMMMMMMMMMMMMMMMMMMMM MMM M M MMMMMMMMMM MMMMMMMMM ~
|
||||||
|
MMMM MMM MMM MM MM M M MMM MM MM MM MM MMM MMM MMM MM
|
||||||
|
MM MM M MM MMMMMM MMMMMMM MMM MMMMM MM M MMM MMM M M ~
|
||||||
|
M M MM MM MM MM M M MM MMM MMM MMMMM MMMMM MMM MMM M
|
||||||
|
M M MM MMMMM MM MM M M MM MMM MMM MMMMM MMM MMM MMM MMMM ~
|
||||||
|
M M MM M MM MM MM M M MM MMM MMM MMMMM MM M MMM MMM M M
|
||||||
|
MM MMM MMM MM MM M M MM MMM MM MMMMM MMM MMM MMM MM ~
|
||||||
|
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
|
||||||
|
|
||||||
========================================================================= ~
|
|
||||||
==== ========= ========================== ===== ===================== ~
|
|
||||||
==== ========= ========================== === ===================== ~
|
|
||||||
==== ========= ===================== === = = ========== ========= ~
|
|
||||||
==== === === == == = = === == == == == === === === == ~
|
|
||||||
== == = == ====== ======= === ===== == = === === = = ~
|
|
||||||
= = == == == == = = == === === ===== ===== === === = ~
|
|
||||||
= = == ===== == == = = == === === ===== === === === ==== ~
|
|
||||||
= = == = == == == = = == === === ===== == = === === = = ~
|
|
||||||
== === === == == = = == === == ===== === === === == ~
|
|
||||||
========================================================================= ~
|
|
||||||
|
|
||||||
REFERENCE MANUAL *
|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
0.- CONTENTS *delimitMate-contents*
|
0.- CONTENTS *delimitMate-contents*
|
||||||
@@ -25,6 +27,7 @@
|
|||||||
2.4 Visual wrapping____________________|delimitMateVisualWrapping|
|
2.4 Visual wrapping____________________|delimitMateVisualWrapping|
|
||||||
2.5 Smart Quotes_______________________|delimitMateSmartQuotes|
|
2.5 Smart Quotes_______________________|delimitMateSmartQuotes|
|
||||||
2.6 FileType based configuration_______|delimitMateFileType|
|
2.6 FileType based configuration_______|delimitMateFileType|
|
||||||
|
2.7 Syntax awareness___________________|delimitMateSyntax|
|
||||||
3. Customization___________________________|delimitMateOptions|
|
3. Customization___________________________|delimitMateOptions|
|
||||||
3.1 Options summary____________________|delimitMateOptionSummary|
|
3.1 Options summary____________________|delimitMateOptionSummary|
|
||||||
3.2 Options details____________________|delimitMateOptionDetails|
|
3.2 Options details____________________|delimitMateOptionDetails|
|
||||||
@@ -39,7 +42,7 @@
|
|||||||
1.- INTRODUCTION *delimitMateIntro*
|
1.- INTRODUCTION *delimitMateIntro*
|
||||||
|
|
||||||
This plug-in provides automatic closing of quotes, parenthesis, brackets,
|
This plug-in provides automatic closing of quotes, parenthesis, brackets,
|
||||||
etc., besides some other related features that should make your time in insert
|
etc.; besides some other related features that should make your time in insert
|
||||||
mode a little bit easier.
|
mode a little bit easier.
|
||||||
|
|
||||||
Most of the features can be modified or disabled permanently, using global
|
Most of the features can be modified or disabled permanently, using global
|
||||||
@@ -147,7 +150,7 @@ 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
|
with delimiters. But, since brackets have special meaning in visual mode, a
|
||||||
leader (the value of 'mapleader' by default) should precede the delimiter.
|
leader (the value of 'mapleader' by default) should precede the delimiter.
|
||||||
NOTE that this feature brakes the redo command and doesn't currently work on
|
NOTE that this feature brakes the redo command and doesn't currently work on
|
||||||
blockwise visual mode, any suggestions will be welcome.
|
blockwise visual mode, any suggestions to fix this will be very welcome.
|
||||||
|
|
||||||
e.g. (selection represented between square brackets): >
|
e.g. (selection represented between square brackets): >
|
||||||
|
|
||||||
@@ -189,9 +192,23 @@ the following way: >
|
|||||||
| - File types for which the option will be set.
|
| - File types for which the option will be set.
|
||||||
- Don't forget to put this event.
|
- Don't forget to put this event.
|
||||||
<
|
<
|
||||||
NOTE that if you use buffer variables (|b:vars|) to set global settings in
|
NOTE that you should use buffer variables (|b:var|) only to set options with
|
||||||
your vimrc, those settings will be set for the first buffer, but they'll be
|
|:autocmd|, for global options use regular variables (|g:var|) in your vimrc.
|
||||||
ignored for new buffers and default values will be set.
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
2.7 SYNTAX AWARENESS *delimitMateSyntax*
|
||||||
|
|
||||||
|
The features of this plug-in might not be always helpful, comments and strings
|
||||||
|
usualy don't need auto-completion. delimitMate monitors which region is being
|
||||||
|
edited and if it detects that the cursor is in a comment it'll turn itself off
|
||||||
|
until the cursor leaves the comment. The excluded regions can be set using the
|
||||||
|
option |'delimitMate_excluded_regions'|. Read |group-name| for a list of
|
||||||
|
regions or syntax group names.
|
||||||
|
|
||||||
|
NOTE that this feature relies on a proper syntax file for the current file
|
||||||
|
type, if the appropiate syntax file doesn't define a region, delimitMate won't
|
||||||
|
know about it.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
3. CUSTOMIZATION *delimitMateOptions*
|
3. CUSTOMIZATION *delimitMateOptions*
|
||||||
|
|
||||||
@@ -224,6 +241,9 @@ specific file types, see |delimitMateOptionDetails| for examples.
|
|||||||
|
|
||||||
|'delimitMate_excluded_ft'| Turns off the script for the given file types.
|
|'delimitMate_excluded_ft'| Turns off the script for the given file types.
|
||||||
|
|
||||||
|
|'delimitMate_excluded_regions'|Turns off the script for the given regions or
|
||||||
|
syntax group names.
|
||||||
|
|
||||||
|'delimitMate_apostrophes'| Tells delimitMate how it should "fix"
|
|'delimitMate_apostrophes'| Tells delimitMate how it should "fix"
|
||||||
balancing of single quotes when used as
|
balancing of single quotes when used as
|
||||||
apostrophes. NOTE: Not needed any more, kept
|
apostrophes. NOTE: Not needed any more, kept
|
||||||
@@ -333,6 +353,16 @@ only if you don't want any of the features it provides on those file types.
|
|||||||
e.g.: >
|
e.g.: >
|
||||||
let delimitMate_excluded_ft = "mail,txt"
|
let delimitMate_excluded_ft = "mail,txt"
|
||||||
<
|
<
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
*'delimitMate_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'*
|
*'delimitMate_apostrophes'*
|
||||||
Values: Strings separated by ":". ~
|
Values: Strings separated by ":". ~
|
||||||
@@ -437,6 +467,9 @@ represented by an "|": >
|
|||||||
==============================================================================
|
==============================================================================
|
||||||
5. FUNCTIONS *delimitMateFunctions*
|
5. FUNCTIONS *delimitMateFunctions*
|
||||||
|
|
||||||
|
Functions should be used enclosed between <C-R>= and <CR>, otherwise they
|
||||||
|
might not work as expected or at all.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
delimitMate#WithinEmptyPair() *delimitMate_WithinEmptyPair*
|
delimitMate#WithinEmptyPair() *delimitMate_WithinEmptyPair*
|
||||||
|
|
||||||
@@ -445,23 +478,23 @@ Returns 1 if the cursor is inside an empty pair, 0 otherwise.
|
|||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
delimitMate#ExpandReturn() *delimitMate#ExpandReturn()*
|
delimitMate#ExpandReturn() *delimitMate#ExpandReturn()*
|
||||||
|
|
||||||
Returns the expansion for <CR>.
|
Returns the expansion for <CR> if enabled and inside an empty pair, returns
|
||||||
|
<CR> otherwise.
|
||||||
|
|
||||||
e.g.: This mapping could be used to select an item on a pop-up menu or expand
|
e.g.: This mapping could be used to select an item on a pop-up menu or expand
|
||||||
<CR> inside an empty pair: >
|
<CR> inside an empty pair: >
|
||||||
|
|
||||||
inoremap <expr> <CR> pumvisible() ? "\<c-y>" :
|
inoremap <expr> <CR> pumvisible() ? "\<c-y>" :
|
||||||
\ delimitMate#WithinEmptyPair() ?
|
\ "\<C-R>=delimitMate#ExpandReturn()\<CR>"
|
||||||
\ delimitMate#ExpandReturn() : "\<CR>"
|
|
||||||
<
|
<
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
delimitMate#ExpandSpace() *delimitMate#ExpandSpace()*
|
delimitMate#ExpandSpace() *delimitMate#ExpandSpace()*
|
||||||
|
|
||||||
Returns the expansion for <Space>.
|
Returns the expansion for <Space> if enabled and inside an empty pair, returns
|
||||||
|
<Space> otherwise.
|
||||||
e.g.: >
|
e.g.: >
|
||||||
|
|
||||||
inoremap <expr> <Space> delimitMate#WithinEmptyPair() ?
|
inoremap <Space> <C-R>=delimitMate#ExpandSpace()<CR>
|
||||||
\ delimitMate#ExpandSpace() : "\<Space>"
|
|
||||||
<
|
<
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
delimitMate#ShouldJump() *delimitMate#ShouldJump()*
|
delimitMate#ShouldJump() *delimitMate#ShouldJump()*
|
||||||
@@ -470,13 +503,13 @@ Returns 1 if there is a closing delimiter or a quote to the right of the
|
|||||||
cursor, 0 otherwise.
|
cursor, 0 otherwise.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
delimitMate#JumpAny() *delimitMate#JumpAny()*
|
delimitMate#JumpAny(key) *delimitMate#JumpAny()*
|
||||||
|
|
||||||
This function returns a mapping that will make the cursor jump to the right.
|
This function returns a mapping that will make the cursor jump to the right
|
||||||
|
when delimitMate#ShouldJump() returns 1, returns the argument "key" otherwise.
|
||||||
e.g.: You can use this to create your own mapping to jump over any delimiter.
|
e.g.: You can use this to create your own mapping to jump over any delimiter.
|
||||||
>
|
>
|
||||||
inoremap <expr> <C-Tab> delimitMate#ShouldJump() ?
|
inoremap <C-Tab> <C-R>=delimitMate#JumpAny("\<S-Tab>")<CR>
|
||||||
\ delimitMate#JumpAny() : "\<C-Tab>"
|
|
||||||
<
|
<
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
@@ -484,7 +517,6 @@ e.g.: You can use this to create your own mapping to jump over any delimiter.
|
|||||||
|
|
||||||
- Automatic set-up by file type.
|
- Automatic set-up by file type.
|
||||||
- Make visual wrapping work on blockwise visual mode.
|
- Make visual wrapping work on blockwise visual mode.
|
||||||
- Limit behaviour by region.
|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
7. MAINTAINER *delimitMateMaintainer*
|
7. MAINTAINER *delimitMateMaintainer*
|
||||||
@@ -519,8 +551,19 @@ This script was inspired by the auto-completion of delimiters of TextMate.
|
|||||||
|
|
||||||
Version Date Release notes ~
|
Version Date Release notes ~
|
||||||
|---------|------------|-----------------------------------------------------|
|
|---------|------------|-----------------------------------------------------|
|
||||||
2.2 2010-05-16 * Current release:
|
2.3.1 2010-06-06 * Current release:
|
||||||
- Added command to switch the plug-in on and off.
|
- Fix: an extra <Space> is inserted after <Space>
|
||||||
|
expansion.
|
||||||
|
|---------|------------|-----------------------------------------------------|
|
||||||
|
2.3 2010-06-06 * - Syntax aware: Will turn off when editing comments
|
||||||
|
or other regions, customizable.
|
||||||
|
- Changed format of most mappings.
|
||||||
|
- Fix: <CR> expansion doesn't brake automatic
|
||||||
|
indentation adjustments anymore.
|
||||||
|
- Fix: Arrow keys would insert A, B, C or D instead
|
||||||
|
of moving the cursor when using Vim on a terminal.
|
||||||
|
|---------|------------|-----------------------------------------------------|
|
||||||
|
2.2 2010-05-16 * - Added command to switch the plug-in on and off.
|
||||||
- Fix: some problems with <Left>, <Right> and <CR>.
|
- Fix: some problems with <Left>, <Right> and <CR>.
|
||||||
- Fix: A small problem when inserting a delimiter at
|
- Fix: A small problem when inserting a delimiter at
|
||||||
the beginning of the line.
|
the beginning of the line.
|
||||||
@@ -596,9 +639,11 @@ This script was inspired by the auto-completion of delimiters of TextMate.
|
|||||||
|---------|------------|-----------------------------------------------------|
|
|---------|------------|-----------------------------------------------------|
|
||||||
|
|
||||||
|
|
||||||
... |"| _ _ . . ___ ~
|
`\|||/´ MMM \|/ www __^__ ~
|
||||||
o,*,(o o) _|_|_ o' \,=./ `o . .:::. /_\ `* ~
|
(o o) (o o) @ @ (O-O) /(o o)\\ ~
|
||||||
8(o o)(_)Ooo (o o) (o o) :(o o): . (o o) ~
|
ooO_(_)_Ooo__ ooO_(_)_Ooo___oOO_(_)_OOo___oOO__(_)__OOo___oOO__(_)__OOo_____ ~
|
||||||
---ooO-(_)---Ooo----ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo- ~
|
_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|____ ~
|
||||||
|
__|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_ ~
|
||||||
|
_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|____ ~
|
||||||
|
|
||||||
vim:tw=78:ts=8:ft=help:norl:formatoptions+=tcroqn:autoindent:
|
vim:tw=78:ts=8:ft=help:norl:formatoptions+=tcroqn:autoindent:
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
" ============================================================================
|
" ============================================================================
|
||||||
" File: autoload/delimitMate.vim
|
" File: autoload/delimitMate.vim
|
||||||
" Version: 2.2
|
" Version: 2.3.1
|
||||||
" Modified: 2010-05-16
|
" Modified: 2010-06-06
|
||||||
" Description: This plugin provides auto-completion for quotes, parens, etc.
|
" Description: This plugin provides auto-completion for quotes, parens, etc.
|
||||||
" Maintainer: Israel Chauca F. <israelchauca@gmail.com>
|
" Maintainer: Israel Chauca F. <israelchauca@gmail.com>
|
||||||
" Manual: Read ":help delimitMate".
|
" Manual: Read ":help delimitMate".
|
||||||
|
|
||||||
" Utilities {{{
|
" Utilities {{{
|
||||||
function! delimitMate#Init() "{{{
|
function! delimitMate#Init() "{{{
|
||||||
|
" Initialize variables:
|
||||||
|
|
||||||
" delimitMate_autoclose {{{
|
" delimitMate_autoclose {{{
|
||||||
if !exists("b:delimitMate_autoclose") && !exists("g:delimitMate_autoclose")
|
if !exists("b:delimitMate_autoclose") && !exists("g:delimitMate_autoclose")
|
||||||
@@ -125,11 +126,10 @@ function! delimitMate#Init() "{{{
|
|||||||
endfunction "}}} Init()
|
endfunction "}}} Init()
|
||||||
|
|
||||||
function! delimitMate#ShouldJump() "{{{
|
function! delimitMate#ShouldJump() "{{{
|
||||||
|
" Returns 1 if the next character is a closing delimiter.
|
||||||
let col = col('.')
|
let col = col('.')
|
||||||
let lcol = col('$')
|
let lcol = col('$')
|
||||||
let char = getline('.')[col - 1]
|
let char = getline('.')[col - 1]
|
||||||
let nchar = getline('.')[col]
|
|
||||||
let uchar = getline(line('.') + 1)[0]
|
|
||||||
|
|
||||||
for cdel in b:delimitMate_right_delims + b:delimitMate_quotes_list
|
for cdel in b:delimitMate_right_delims + b:delimitMate_quotes_list
|
||||||
if char == cdel
|
if char == cdel
|
||||||
@@ -138,6 +138,7 @@ function! delimitMate#ShouldJump() "{{{
|
|||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
|
let nchar = getline('.')[col]
|
||||||
if b:delimitMate_expand_space && char == " "
|
if b:delimitMate_expand_space && char == " "
|
||||||
for cdel in b:delimitMate_right_delims + b:delimitMate_quotes_list
|
for cdel in b:delimitMate_right_delims + b:delimitMate_quotes_list
|
||||||
if nchar == cdel
|
if nchar == cdel
|
||||||
@@ -147,6 +148,7 @@ function! delimitMate#ShouldJump() "{{{
|
|||||||
endfor
|
endfor
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
let uchar = getline(line('.') + 1)[0]
|
||||||
if b:delimitMate_expand_cr && char == ""
|
if b:delimitMate_expand_cr && char == ""
|
||||||
for cdel in b:delimitMate_right_delims + b:delimitMate_quotes_list
|
for cdel in b:delimitMate_right_delims + b:delimitMate_quotes_list
|
||||||
if uchar == cdel
|
if uchar == cdel
|
||||||
@@ -304,8 +306,16 @@ function! delimitMate#RestoreRegister() " {{{
|
|||||||
echo ""
|
echo ""
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
|
|
||||||
|
function! delimitMate#GetSyntaxRegion(line, col) "{{{
|
||||||
|
return synIDattr(synIDtrans(synID(a:line, a:col, 1)), 'name')
|
||||||
|
endfunction " }}}
|
||||||
|
|
||||||
function! delimitMate#GetCurrentSyntaxRegion() "{{{
|
function! delimitMate#GetCurrentSyntaxRegion() "{{{
|
||||||
return synIDattr(synIDtrans(synID(line('.'), col('.'), 1)), 'name')
|
let col = col('.')
|
||||||
|
if col == col('$')
|
||||||
|
let col = col - 1
|
||||||
|
endif
|
||||||
|
return delimitMate#GetSyntaxRegion(line('.'), col)
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
|
|
||||||
function! delimitMate#GetCurrentSyntaxRegionIf(char) "{{{
|
function! delimitMate#GetCurrentSyntaxRegionIf(char) "{{{
|
||||||
@@ -313,23 +323,25 @@ function! delimitMate#GetCurrentSyntaxRegionIf(char) "{{{
|
|||||||
let origin_line = getline('.')
|
let origin_line = getline('.')
|
||||||
let changed_line = strpart(origin_line, 0, col - 1) . a:char . strpart(origin_line, col - 1)
|
let changed_line = strpart(origin_line, 0, col - 1) . a:char . strpart(origin_line, col - 1)
|
||||||
call setline('.', changed_line)
|
call setline('.', changed_line)
|
||||||
let region = synIDattr(synIDtrans(synID(line('.'), col, 1)), 'name')
|
let region = delimitMate#GetSyntaxRegion(line('.'), col)
|
||||||
call setline('.', origin_line)
|
call setline('.', origin_line)
|
||||||
return region
|
return region
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! delimitMate#IsForbidden(char) "{{{
|
function! delimitMate#IsForbidden(char) "{{{
|
||||||
if b:delimitMate_excluded_regions_enabled = 0
|
if b:delimitMate_excluded_regions_enabled == 0
|
||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
let result = index(b:delimitMate_excluded_regions_list, delimitMate#GetCurrentSyntaxRegion()) >= 0
|
"let result = index(b:delimitMate_excluded_regions_list, delimitMate#GetCurrentSyntaxRegion()) >= 0
|
||||||
if result >= 0
|
if index(b:delimitMate_excluded_regions_list, delimitMate#GetCurrentSyntaxRegion()) >= 0
|
||||||
return result + 1
|
"echom "Forbidden 1!"
|
||||||
|
return 1
|
||||||
endif
|
endif
|
||||||
let region = delimitMate#GetCurrentSyntaxRegionIf(a:char)
|
let region = delimitMate#GetCurrentSyntaxRegionIf(a:char)
|
||||||
let result = index(b:delimitMate_excluded_regions_list, region) >= 0
|
"let result = index(b:delimitMate_excluded_regions_list, region) >= 0
|
||||||
"return result || region == 'Comment'
|
"return result || region == 'Comment'
|
||||||
return result + 1
|
"echom "Forbidden 2!"
|
||||||
|
return index(b:delimitMate_excluded_regions_list, region) >= 0
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! delimitMate#FlushBuffer() " {{{
|
function! delimitMate#FlushBuffer() " {{{
|
||||||
@@ -340,6 +352,9 @@ endfunction " }}}
|
|||||||
|
|
||||||
" Doers {{{
|
" Doers {{{
|
||||||
function! delimitMate#JumpIn(char) " {{{
|
function! delimitMate#JumpIn(char) " {{{
|
||||||
|
if delimitMate#IsForbidden(a:char)
|
||||||
|
return ''
|
||||||
|
endif
|
||||||
let line = getline('.')
|
let line = getline('.')
|
||||||
let col = col('.')-2
|
let col = col('.')-2
|
||||||
if (col) < 0
|
if (col) < 0
|
||||||
@@ -354,6 +369,9 @@ function! delimitMate#JumpIn(char) " {{{
|
|||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
|
|
||||||
function! delimitMate#JumpOut(char) "{{{
|
function! delimitMate#JumpOut(char) "{{{
|
||||||
|
if delimitMate#IsForbidden(a:char)
|
||||||
|
return a:char
|
||||||
|
endif
|
||||||
let line = getline('.')
|
let line = getline('.')
|
||||||
let col = col('.')-2
|
let col = col('.')-2
|
||||||
if line[col+1] == a:char
|
if line[col+1] == a:char
|
||||||
@@ -363,7 +381,13 @@ function! delimitMate#JumpOut(char) "{{{
|
|||||||
endif
|
endif
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
|
|
||||||
function! delimitMate#JumpAny() " {{{
|
function! delimitMate#JumpAny(key) " {{{
|
||||||
|
if delimitMate#IsForbidden('')
|
||||||
|
return a:key
|
||||||
|
endif
|
||||||
|
if !delimitMate#ShouldJump()
|
||||||
|
return a:key
|
||||||
|
endif
|
||||||
" Let's get the character on the right.
|
" Let's get the character on the right.
|
||||||
let char = getline('.')[col('.')-1]
|
let char = getline('.')[col('.')-1]
|
||||||
if char == " "
|
if char == " "
|
||||||
@@ -383,6 +407,9 @@ function! delimitMate#JumpAny() " {{{
|
|||||||
endfunction " delimitMate#JumpAny() }}}
|
endfunction " delimitMate#JumpAny() }}}
|
||||||
|
|
||||||
function! delimitMate#SkipDelim(char) "{{{
|
function! delimitMate#SkipDelim(char) "{{{
|
||||||
|
if delimitMate#IsForbidden(a:char)
|
||||||
|
return a:char
|
||||||
|
endif
|
||||||
let col = col('.') - 1
|
let col = col('.') - 1
|
||||||
let line = getline('.')
|
let line = getline('.')
|
||||||
if col > 0
|
if col > 0
|
||||||
@@ -410,6 +437,9 @@ function! delimitMate#SkipDelim(char) "{{{
|
|||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! delimitMate#QuoteDelim(char) "{{{
|
function! delimitMate#QuoteDelim(char) "{{{
|
||||||
|
if delimitMate#IsForbidden(a:char)
|
||||||
|
return a:char
|
||||||
|
endif
|
||||||
let line = getline('.')
|
let line = getline('.')
|
||||||
let col = col('.') - 2
|
let col = col('.') - 2
|
||||||
if line[col] == "\\"
|
if line[col] == "\\"
|
||||||
@@ -442,19 +472,24 @@ function! delimitMate#MapMsg(msg) "{{{
|
|||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! delimitMate#ExpandReturn() "{{{
|
function! delimitMate#ExpandReturn() "{{{
|
||||||
if delimitMate#WithinEmptyPair() &&
|
if delimitMate#IsForbidden("")
|
||||||
\ b:delimitMate_expand_cr
|
return "\<CR>"
|
||||||
|
endif
|
||||||
|
if delimitMate#WithinEmptyPair()
|
||||||
" Expand:
|
" Expand:
|
||||||
call delimitMate#FlushBuffer()
|
call delimitMate#FlushBuffer()
|
||||||
return "\<Esc>a\<CR>x\<CR>\<Esc>k$\"_xa"
|
"return "\<Esc>a\<CR>x\<CR>\<Esc>k$\"_xa"
|
||||||
|
return "\<CR>\<UP>\<Esc>o"
|
||||||
else
|
else
|
||||||
return "\<CR>"
|
return "\<CR>"
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! delimitMate#ExpandSpace() "{{{
|
function! delimitMate#ExpandSpace() "{{{
|
||||||
if delimitMate#WithinEmptyPair() &&
|
if delimitMate#IsForbidden("\<Space>")
|
||||||
\ b:delimitMate_expand_space
|
return "\<Space>"
|
||||||
|
endif
|
||||||
|
if delimitMate#WithinEmptyPair()
|
||||||
" Expand:
|
" Expand:
|
||||||
call insert(b:delimitMate_buffer, 's')
|
call insert(b:delimitMate_buffer, 's')
|
||||||
return delimitMate#WriteAfter(' ') . "\<Space>"
|
return delimitMate#WriteAfter(' ') . "\<Space>"
|
||||||
@@ -464,16 +499,17 @@ function! delimitMate#ExpandSpace() "{{{
|
|||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! delimitMate#BS() " {{{
|
function! delimitMate#BS() " {{{
|
||||||
|
if delimitMate#IsForbidden("")
|
||||||
|
return "\<BS>"
|
||||||
|
endif
|
||||||
if delimitMate#WithinEmptyPair()
|
if delimitMate#WithinEmptyPair()
|
||||||
"call delimitMate#RmBuffer(1)
|
"call delimitMate#RmBuffer(1)
|
||||||
return "\<BS>" . delimitMate#Del()
|
return "\<BS>" . delimitMate#Del()
|
||||||
" return "\<Right>\<BS>\<BS>"
|
" return "\<Right>\<BS>\<BS>"
|
||||||
elseif b:delimitMate_expand_space &&
|
elseif delimitMate#IsSpaceExpansion()
|
||||||
\ delimitMate#IsSpaceExpansion()
|
|
||||||
"call delimitMate#RmBuffer(1)
|
"call delimitMate#RmBuffer(1)
|
||||||
return "\<BS>" . delimitMate#Del()
|
return "\<BS>" . delimitMate#Del()
|
||||||
elseif b:delimitMate_expand_cr &&
|
elseif delimitMate#IsCRExpansion()
|
||||||
\ delimitMate#IsCRExpansion()
|
|
||||||
return "\<BS>\<Del>"
|
return "\<BS>\<Del>"
|
||||||
else
|
else
|
||||||
return "\<BS>"
|
return "\<BS>"
|
||||||
@@ -500,7 +536,7 @@ function! delimitMate#Finish() " {{{
|
|||||||
let b:delimitMate_buffer = []
|
let b:delimitMate_buffer = []
|
||||||
let line = getline('.')
|
let line = getline('.')
|
||||||
let col = col('.') -2
|
let col = col('.') -2
|
||||||
echom 'col: ' . col . '-' . line[:col] . "|" . line[col+len+1:] . '%' . buffer
|
"echom 'col: ' . col . '-' . line[:col] . "|" . line[col+len+1:] . '%' . buffer
|
||||||
if col < 0
|
if col < 0
|
||||||
call setline('.', line[col+len+1:])
|
call setline('.', line[col+len+1:])
|
||||||
else
|
else
|
||||||
@@ -530,7 +566,7 @@ endfunction " }}}
|
|||||||
function! delimitMate#NoAutoClose() "{{{
|
function! delimitMate#NoAutoClose() "{{{
|
||||||
" inoremap <buffer> ) <C-R>=delimitMate#SkipDelim('\)')<CR>
|
" inoremap <buffer> ) <C-R>=delimitMate#SkipDelim('\)')<CR>
|
||||||
for delim in b:delimitMate_right_delims + b:delimitMate_quotes_list
|
for delim in b:delimitMate_right_delims + b:delimitMate_quotes_list
|
||||||
exec 'inoremap <buffer> ' . delim . ' <C-R>=delimitMate#SkipDelim("' . escape(delim,'"') . '")<CR>'
|
exec 'inoremap <buffer> ' . delim . ' <C-R>=delimitMate#SkipDelim("' . escape(delim,'"\|') . '")<CR>'
|
||||||
endfor
|
endfor
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
@@ -577,21 +613,21 @@ function! delimitMate#ExtraMappings() "{{{
|
|||||||
inoremap <buffer> <BS> <C-R>=delimitMate#BS()<CR>
|
inoremap <buffer> <BS> <C-R>=delimitMate#BS()<CR>
|
||||||
|
|
||||||
" If pair is empty, delete closing delimiter:
|
" If pair is empty, delete closing delimiter:
|
||||||
inoremap <buffer> <expr> <S-BS> delimitMate#WithinEmptyPair() ? "\<Del>" : "\<S-BS>"
|
inoremap <buffer> <expr> <S-BS> delimitMate#WithinEmptyPair() && !delimitMate#IsForbidden("") ? "\<Del>" : "\<S-BS>"
|
||||||
|
|
||||||
" Expand return if inside an empty pair:
|
" Expand return if inside an empty pair:
|
||||||
if b:delimitMate_expand_cr != 0
|
if b:delimitMate_expand_cr != 0
|
||||||
inoremap <buffer> <expr> <CR> delimitMate#WithinEmptyPair() ? "\<C-R>=delimitMate#ExpandReturn()\<CR>" : "\<CR>"
|
inoremap <buffer> <CR> <C-R>=delimitMate#ExpandReturn()<CR>
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Expand space if inside an empty pair:
|
" Expand space if inside an empty pair:
|
||||||
if b:delimitMate_expand_space != 0
|
if b:delimitMate_expand_space != 0
|
||||||
inoremap <buffer> <expr> <Space> delimitMate#WithinEmptyPair() ? "\<C-R>=delimitMate#ExpandSpace()\<CR>" : "\<Space>"
|
inoremap <buffer> <Space> <C-R>=delimitMate#ExpandSpace()<CR>
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Jump out ot any empty pair:
|
" Jump out ot any empty pair:
|
||||||
if b:delimitMate_tab2exit
|
if b:delimitMate_tab2exit
|
||||||
inoremap <buffer> <expr> <S-Tab> delimitMate#ShouldJump() ? "\<C-R>=delimitMate#JumpAny()\<CR>" : "\<S-Tab>"
|
inoremap <buffer> <S-Tab> <C-R>=delimitMate#JumpAny("\<S-Tab>")<CR>
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Fix the re-do feature:
|
" Fix the re-do feature:
|
||||||
@@ -609,6 +645,12 @@ function! delimitMate#ExtraMappings() "{{{
|
|||||||
|
|
||||||
inoremap <buffer> <Del> <C-R>=delimitMate#Del()<CR>
|
inoremap <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 &term[:4] == "xterm"
|
||||||
|
inoremap <silent> <C-[>OC <RIGHT>
|
||||||
|
endif
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! delimitMate#UnMap() " {{{
|
function! delimitMate#UnMap() " {{{
|
||||||
@@ -668,8 +710,6 @@ function! delimitMate#TestMappings() "{{{
|
|||||||
for i in range(len(b:delimitMate_quotes_list))
|
for i in range(len(b:delimitMate_quotes_list))
|
||||||
exec "normal GGAOpen & close: " . b:delimitMate_quotes_list[i] . "|"
|
exec "normal GGAOpen & close: " . b:delimitMate_quotes_list[i] . "|"
|
||||||
exec "normal A\<CR>Delete: "
|
exec "normal A\<CR>Delete: "
|
||||||
exec "normal A". b:delimitMate_quotes_list[i]
|
|
||||||
exec "normal a\<BS>|"
|
|
||||||
exec "normal A\<CR>Exit: " . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . "|"
|
exec "normal A\<CR>Exit: " . b:delimitMate_quotes_list[i] . b:delimitMate_quotes_list[i] . "|"
|
||||||
exec "normal A\<CR>Space: " . b:delimitMate_quotes_list[i] . " |"
|
exec "normal A\<CR>Space: " . b:delimitMate_quotes_list[i] . " |"
|
||||||
exec "normal A\<CR>Delete space: " . b:delimitMate_quotes_list[i] . " \<BS>|"
|
exec "normal A\<CR>Delete space: " . b:delimitMate_quotes_list[i] . " \<BS>|"
|
||||||
|
|||||||
@@ -226,7 +226,12 @@ function! delimitMateTests#Main() " {{{
|
|||||||
" Deactivate parens on comments: The first call to a closing delimiter
|
" Deactivate parens on comments: The first call to a closing delimiter
|
||||||
" will not work here as expected, but it does in real life tests.
|
" will not work here as expected, but it does in real life tests.
|
||||||
set ft=vim
|
set ft=vim
|
||||||
call Type("Deactivate parens on comments", "\"()", ["\"()"], ["autoclose:0"], 1)
|
call Type("Deactivate parens on comments", "\"()[]", ["\"()[]|"], ["autoclose:0"], 1)
|
||||||
|
set ft=
|
||||||
|
|
||||||
|
" Deactivate quotes on comments: See previous note.
|
||||||
|
set ft=vim
|
||||||
|
call Type("Deactivate parens on comments", "\"(`", ["\"(``|"], [], 1)
|
||||||
set ft=
|
set ft=
|
||||||
|
|
||||||
" Manual close at start of line
|
" Manual close at start of line
|
||||||
|
|||||||
@@ -1,18 +1,20 @@
|
|||||||
*delimitMate* Trying to keep those beasts at bay! v2.2 *delimitMate.txt*
|
*delimitMate* Trying to keep those beasts at bay! v2.3.1 *delimitMate.txt*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
|
||||||
|
MMMM MMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMM MMMMM MMMMMMMMMMMMMMMMMMMMM ~
|
||||||
|
MMMM MMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMM MMM MMMMMMMMMMMMMMMMMMMMM
|
||||||
|
MMMM MMMMMMMMM MMMMMMMMMMMMMMMMMMMMM MMM M M MMMMMMMMMM MMMMMMMMM ~
|
||||||
|
MMMM MMM MMM MM MM M M MMM MM MM MM MM MMM MMM MMM MM
|
||||||
|
MM MM M MM MMMMMM MMMMMMM MMM MMMMM MM M MMM MMM M M ~
|
||||||
|
M M MM MM MM MM M M MM MMM MMM MMMMM MMMMM MMM MMM M
|
||||||
|
M M MM MMMMM MM MM M M MM MMM MMM MMMMM MMM MMM MMM MMMM ~
|
||||||
|
M M MM M MM MM MM M M MM MMM MMM MMMMM MM M MMM MMM M M
|
||||||
|
MM MMM MMM MM MM M M MM MMM MM MMMMM MMM MMM MMM MM ~
|
||||||
|
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
|
||||||
|
|
||||||
========================================================================= ~
|
|
||||||
==== ========= ========================== ===== ===================== ~
|
|
||||||
==== ========= ========================== === ===================== ~
|
|
||||||
==== ========= ===================== === = = ========== ========= ~
|
|
||||||
==== === === == == = = === == == == == === === === == ~
|
|
||||||
== == = == ====== ======= === ===== == = === === = = ~
|
|
||||||
= = == == == == = = == === === ===== ===== === === = ~
|
|
||||||
= = == ===== == == = = == === === ===== === === === ==== ~
|
|
||||||
= = == = == == == = = == === === ===== == = === === = = ~
|
|
||||||
== === === == == = = == === == ===== === === === == ~
|
|
||||||
========================================================================= ~
|
|
||||||
|
|
||||||
REFERENCE MANUAL *
|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
0.- CONTENTS *delimitMate-contents*
|
0.- CONTENTS *delimitMate-contents*
|
||||||
@@ -25,6 +27,7 @@
|
|||||||
2.4 Visual wrapping____________________|delimitMateVisualWrapping|
|
2.4 Visual wrapping____________________|delimitMateVisualWrapping|
|
||||||
2.5 Smart Quotes_______________________|delimitMateSmartQuotes|
|
2.5 Smart Quotes_______________________|delimitMateSmartQuotes|
|
||||||
2.6 FileType based configuration_______|delimitMateFileType|
|
2.6 FileType based configuration_______|delimitMateFileType|
|
||||||
|
2.7 Syntax awareness___________________|delimitMateSyntax|
|
||||||
3. Customization___________________________|delimitMateOptions|
|
3. Customization___________________________|delimitMateOptions|
|
||||||
3.1 Options summary____________________|delimitMateOptionSummary|
|
3.1 Options summary____________________|delimitMateOptionSummary|
|
||||||
3.2 Options details____________________|delimitMateOptionDetails|
|
3.2 Options details____________________|delimitMateOptionDetails|
|
||||||
@@ -39,7 +42,7 @@
|
|||||||
1.- INTRODUCTION *delimitMateIntro*
|
1.- INTRODUCTION *delimitMateIntro*
|
||||||
|
|
||||||
This plug-in provides automatic closing of quotes, parenthesis, brackets,
|
This plug-in provides automatic closing of quotes, parenthesis, brackets,
|
||||||
etc., besides some other related features that should make your time in insert
|
etc.; besides some other related features that should make your time in insert
|
||||||
mode a little bit easier.
|
mode a little bit easier.
|
||||||
|
|
||||||
Most of the features can be modified or disabled permanently, using global
|
Most of the features can be modified or disabled permanently, using global
|
||||||
@@ -147,7 +150,7 @@ 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
|
with delimiters. But, since brackets have special meaning in visual mode, a
|
||||||
leader (the value of 'mapleader' by default) should precede the delimiter.
|
leader (the value of 'mapleader' by default) should precede the delimiter.
|
||||||
NOTE that this feature brakes the redo command and doesn't currently work on
|
NOTE that this feature brakes the redo command and doesn't currently work on
|
||||||
blockwise visual mode, any suggestions will be welcome.
|
blockwise visual mode, any suggestions to fix this will be very welcome.
|
||||||
|
|
||||||
e.g. (selection represented between square brackets): >
|
e.g. (selection represented between square brackets): >
|
||||||
|
|
||||||
@@ -189,9 +192,23 @@ the following way: >
|
|||||||
| - File types for which the option will be set.
|
| - File types for which the option will be set.
|
||||||
- Don't forget to put this event.
|
- Don't forget to put this event.
|
||||||
<
|
<
|
||||||
NOTE that if you use buffer variables (|b:vars|) to set global settings in
|
NOTE that you should use buffer variables (|b:var|) only to set options with
|
||||||
your vimrc, those settings will be set for the first buffer, but they'll be
|
|:autocmd|, for global options use regular variables (|g:var|) in your vimrc.
|
||||||
ignored for new buffers and default values will be set.
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
2.7 SYNTAX AWARENESS *delimitMateSyntax*
|
||||||
|
|
||||||
|
The features of this plug-in might not be always helpful, comments and strings
|
||||||
|
usualy don't need auto-completion. delimitMate monitors which region is being
|
||||||
|
edited and if it detects that the cursor is in a comment it'll turn itself off
|
||||||
|
until the cursor leaves the comment. The excluded regions can be set using the
|
||||||
|
option |'delimitMate_excluded_regions'|. Read |group-name| for a list of
|
||||||
|
regions or syntax group names.
|
||||||
|
|
||||||
|
NOTE that this feature relies on a proper syntax file for the current file
|
||||||
|
type, if the appropiate syntax file doesn't define a region, delimitMate won't
|
||||||
|
know about it.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
3. CUSTOMIZATION *delimitMateOptions*
|
3. CUSTOMIZATION *delimitMateOptions*
|
||||||
|
|
||||||
@@ -224,6 +241,9 @@ specific file types, see |delimitMateOptionDetails| for examples.
|
|||||||
|
|
||||||
|'delimitMate_excluded_ft'| Turns off the script for the given file types.
|
|'delimitMate_excluded_ft'| Turns off the script for the given file types.
|
||||||
|
|
||||||
|
|'delimitMate_excluded_regions'|Turns off the script for the given regions or
|
||||||
|
syntax group names.
|
||||||
|
|
||||||
|'delimitMate_apostrophes'| Tells delimitMate how it should "fix"
|
|'delimitMate_apostrophes'| Tells delimitMate how it should "fix"
|
||||||
balancing of single quotes when used as
|
balancing of single quotes when used as
|
||||||
apostrophes. NOTE: Not needed any more, kept
|
apostrophes. NOTE: Not needed any more, kept
|
||||||
@@ -333,6 +353,16 @@ only if you don't want any of the features it provides on those file types.
|
|||||||
e.g.: >
|
e.g.: >
|
||||||
let delimitMate_excluded_ft = "mail,txt"
|
let delimitMate_excluded_ft = "mail,txt"
|
||||||
<
|
<
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
*'delimitMate_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'*
|
*'delimitMate_apostrophes'*
|
||||||
Values: Strings separated by ":". ~
|
Values: Strings separated by ":". ~
|
||||||
@@ -437,6 +467,9 @@ represented by an "|": >
|
|||||||
==============================================================================
|
==============================================================================
|
||||||
5. FUNCTIONS *delimitMateFunctions*
|
5. FUNCTIONS *delimitMateFunctions*
|
||||||
|
|
||||||
|
Functions should be used enclosed between <C-R>= and <CR>, otherwise they
|
||||||
|
might not work as expected or at all.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
delimitMate#WithinEmptyPair() *delimitMate_WithinEmptyPair*
|
delimitMate#WithinEmptyPair() *delimitMate_WithinEmptyPair*
|
||||||
|
|
||||||
@@ -445,23 +478,23 @@ Returns 1 if the cursor is inside an empty pair, 0 otherwise.
|
|||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
delimitMate#ExpandReturn() *delimitMate#ExpandReturn()*
|
delimitMate#ExpandReturn() *delimitMate#ExpandReturn()*
|
||||||
|
|
||||||
Returns the expansion for <CR>.
|
Returns the expansion for <CR> if enabled and inside an empty pair, returns
|
||||||
|
<CR> otherwise.
|
||||||
|
|
||||||
e.g.: This mapping could be used to select an item on a pop-up menu or expand
|
e.g.: This mapping could be used to select an item on a pop-up menu or expand
|
||||||
<CR> inside an empty pair: >
|
<CR> inside an empty pair: >
|
||||||
|
|
||||||
inoremap <expr> <CR> pumvisible() ? "\<c-y>" :
|
inoremap <expr> <CR> pumvisible() ? "\<c-y>" :
|
||||||
\ delimitMate#WithinEmptyPair() ?
|
\ "\<C-R>=delimitMate#ExpandReturn()\<CR>"
|
||||||
\ delimitMate#ExpandReturn() : "\<CR>"
|
|
||||||
<
|
<
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
delimitMate#ExpandSpace() *delimitMate#ExpandSpace()*
|
delimitMate#ExpandSpace() *delimitMate#ExpandSpace()*
|
||||||
|
|
||||||
Returns the expansion for <Space>.
|
Returns the expansion for <Space> if enabled and inside an empty pair, returns
|
||||||
|
<Space> otherwise.
|
||||||
e.g.: >
|
e.g.: >
|
||||||
|
|
||||||
inoremap <expr> <Space> delimitMate#WithinEmptyPair() ?
|
inoremap <Space> <C-R>=delimitMate#ExpandSpace()<CR>
|
||||||
\ delimitMate#ExpandSpace() : "\<Space>"
|
|
||||||
<
|
<
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
delimitMate#ShouldJump() *delimitMate#ShouldJump()*
|
delimitMate#ShouldJump() *delimitMate#ShouldJump()*
|
||||||
@@ -470,13 +503,13 @@ Returns 1 if there is a closing delimiter or a quote to the right of the
|
|||||||
cursor, 0 otherwise.
|
cursor, 0 otherwise.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
delimitMate#JumpAny() *delimitMate#JumpAny()*
|
delimitMate#JumpAny(key) *delimitMate#JumpAny()*
|
||||||
|
|
||||||
This function returns a mapping that will make the cursor jump to the right.
|
This function returns a mapping that will make the cursor jump to the right
|
||||||
|
when delimitMate#ShouldJump() returns 1, returns the argument "key" otherwise.
|
||||||
e.g.: You can use this to create your own mapping to jump over any delimiter.
|
e.g.: You can use this to create your own mapping to jump over any delimiter.
|
||||||
>
|
>
|
||||||
inoremap <expr> <C-Tab> delimitMate#ShouldJump() ?
|
inoremap <C-Tab> <C-R>=delimitMate#JumpAny("\<S-Tab>")<CR>
|
||||||
\ delimitMate#JumpAny() : "\<C-Tab>"
|
|
||||||
<
|
<
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
@@ -484,7 +517,6 @@ e.g.: You can use this to create your own mapping to jump over any delimiter.
|
|||||||
|
|
||||||
- Automatic set-up by file type.
|
- Automatic set-up by file type.
|
||||||
- Make visual wrapping work on blockwise visual mode.
|
- Make visual wrapping work on blockwise visual mode.
|
||||||
- Limit behaviour by region.
|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
7. MAINTAINER *delimitMateMaintainer*
|
7. MAINTAINER *delimitMateMaintainer*
|
||||||
@@ -519,8 +551,19 @@ This script was inspired by the auto-completion of delimiters of TextMate.
|
|||||||
|
|
||||||
Version Date Release notes ~
|
Version Date Release notes ~
|
||||||
|---------|------------|-----------------------------------------------------|
|
|---------|------------|-----------------------------------------------------|
|
||||||
2.2 2010-05-16 * Current release:
|
2.3.1 2010-06-06 * Current release:
|
||||||
- Added command to switch the plug-in on and off.
|
- Fix: an extra <Space> is inserted after <Space>
|
||||||
|
expansion.
|
||||||
|
|---------|------------|-----------------------------------------------------|
|
||||||
|
2.3 2010-06-06 * - Syntax aware: Will turn off when editing comments
|
||||||
|
or other regions, customizable.
|
||||||
|
- Changed format of most mappings.
|
||||||
|
- Fix: <CR> expansion doesn't brake automatic
|
||||||
|
indentation adjustments anymore.
|
||||||
|
- Fix: Arrow keys would insert A, B, C or D instead
|
||||||
|
of moving the cursor when using Vim on a terminal.
|
||||||
|
|---------|------------|-----------------------------------------------------|
|
||||||
|
2.2 2010-05-16 * - Added command to switch the plug-in on and off.
|
||||||
- Fix: some problems with <Left>, <Right> and <CR>.
|
- Fix: some problems with <Left>, <Right> and <CR>.
|
||||||
- Fix: A small problem when inserting a delimiter at
|
- Fix: A small problem when inserting a delimiter at
|
||||||
the beginning of the line.
|
the beginning of the line.
|
||||||
@@ -596,9 +639,11 @@ This script was inspired by the auto-completion of delimiters of TextMate.
|
|||||||
|---------|------------|-----------------------------------------------------|
|
|---------|------------|-----------------------------------------------------|
|
||||||
|
|
||||||
|
|
||||||
... |"| _ _ . . ___ ~
|
`\|||/´ MMM \|/ www __^__ ~
|
||||||
o,*,(o o) _|_|_ o' \,=./ `o . .:::. /_\ `* ~
|
(o o) (o o) @ @ (O-O) /(o o)\\ ~
|
||||||
8(o o)(_)Ooo (o o) (o o) :(o o): . (o o) ~
|
ooO_(_)_Ooo__ ooO_(_)_Ooo___oOO_(_)_OOo___oOO__(_)__OOo___oOO__(_)__OOo_____ ~
|
||||||
---ooO-(_)---Ooo----ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo- ~
|
_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|____ ~
|
||||||
|
__|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_ ~
|
||||||
|
_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|____ ~
|
||||||
|
|
||||||
vim:tw=78:ts=8:ft=help:norl:formatoptions+=tcroqn:autoindent:
|
vim:tw=78:ts=8:ft=help:norl:formatoptions+=tcroqn:autoindent:
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
" ============================================================================
|
" ============================================================================
|
||||||
" File: plugin/delimitMate.vim
|
" File: plugin/delimitMate.vim
|
||||||
" Version: 2.2
|
" Version: 2.3.1
|
||||||
" Modified: 2010-05-16
|
" Modified: 2010-06-06
|
||||||
" Description: This plugin provides auto-completion for quotes, parens, etc.
|
" Description: This plugin provides auto-completion for quotes, parens, etc.
|
||||||
" Maintainer: Israel Chauca F. <israelchauca@gmail.com>
|
" Maintainer: Israel Chauca F. <israelchauca@gmail.com>
|
||||||
" Manual: Read ":help delimitMate".
|
" Manual: Read ":help delimitMate".
|
||||||
@@ -26,7 +26,7 @@ if v:version < 700
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
let s:loaded_delimitMate = 1 " }}}
|
let s:loaded_delimitMate = 1 " }}}
|
||||||
let delimitMate_version = '2.2'
|
let delimitMate_version = "2.3.1"
|
||||||
|
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
@@ -54,7 +54,7 @@ function! s:TestMappingsDo() "{{{
|
|||||||
normal gg
|
normal gg
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! s:DelimitMateDo() "{{{
|
function! s:DelimitMateDo(...) "{{{
|
||||||
if exists("g:delimitMate_excluded_ft")
|
if exists("g:delimitMate_excluded_ft")
|
||||||
" Check if this file type is excluded:
|
" Check if this file type is excluded:
|
||||||
for ft in split(g:delimitMate_excluded_ft,',')
|
for ft in split(g:delimitMate_excluded_ft,',')
|
||||||
@@ -76,13 +76,18 @@ function! s:DelimitMateDo() "{{{
|
|||||||
let &cpo = save_cpo
|
let &cpo = save_cpo
|
||||||
let &keymap = save_keymap
|
let &keymap = save_keymap
|
||||||
endtry
|
endtry
|
||||||
|
if a:0 > 0
|
||||||
|
echo "delimitMate has been reset."
|
||||||
|
endif
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! s:DelimitMateSwitch() "{{{
|
function! s:DelimitMateSwitch() "{{{
|
||||||
if b:delimitMate_enabled
|
if b:delimitMate_enabled
|
||||||
call delimitMate#UnMap()
|
call delimitMate#UnMap()
|
||||||
|
echo "delimitMate has been disabled."
|
||||||
else
|
else
|
||||||
call delimitMate#Init()
|
call delimitMate#Init()
|
||||||
|
echo "delimitMate has been enabled."
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
@@ -92,7 +97,7 @@ endfunction "}}}
|
|||||||
call s:DelimitMateDo()
|
call s:DelimitMateDo()
|
||||||
|
|
||||||
" Let me refresh without re-loading the buffer:
|
" Let me refresh without re-loading the buffer:
|
||||||
command! DelimitMateReload call s:DelimitMateDo()
|
command! DelimitMateReload call s:DelimitMateDo(1)
|
||||||
|
|
||||||
" Quick test:
|
" Quick test:
|
||||||
command! DelimitMateTest call s:TestMappingsDo()
|
command! DelimitMateTest call s:TestMappingsDo()
|
||||||
|
|||||||
Reference in New Issue
Block a user