Permalink
Browse files

*** 1.0 First Release ***

- Last changes to documentation (for now).
- Now the presence of delimitMate_testing will let me work better.
- Changed some variables from global to local.
- Changed how visual wrap finish:
	* If left delimiter is used then finish in normal mode.
	* If right delimiter is used then finish in insert mode.
  • Loading branch information...
1 parent 00b9182 commit c57035cba3a099e6fe97a3539bd0e1f72a698bf6 @Raimondi committed Aug 23, 2009
Showing with 91 additions and 85 deletions.
  1. +57 −42 delimitMate.txt
  2. +34 −42 delimitMate.vim
  3. +0 −1 install.txt
View
@@ -16,21 +16,29 @@
3. Customization___________________________|delimitMateOptions|
3.1 Option summary_____________________|delimitMateOptionSummary|
3.2 Options details____________________|delimitMateOptionDetails|
- 4. Public command__________________________|delimitMatePublicCommand|
+ 4. Public commands_________________________|delimitMatePublicCommands|
5. TODO list_______________________________|delimitMateTodo|
- 6. The Maintainer__________________________|delimitMateMaintainer|
+ 6. Maintainer______________________________|delimitMateMaintainer|
7. Credits_________________________________|delimitMateCredits|
==============================================================================
1.- INTRODUCTION *delimitMate*
-What is this "delimitMate"?
+The delimitMate plugin tries to provide some not so dumb help in the work with
+delimiters (brackets, quotes, etc.), with some optional auto-completions and
+expansions.
-The delimitMate plugin tries to emulate the auto-completion of delimiters that
-TextMate provides. The characters used as delimiters can be easily modified,
-this allows great flexibility; for example, one set can be used for Tcl and a
-different one for HTML.
+When automatic closing is enabled, if an opening delimiter is inserted
+delimitMate inserts the closing pair and places the cursor between them. When
+automatic closing is disabled, no closing delimiters is inserted by
+delimitMate, but if a pair of delimiters is typed, the cursor is placed in the
+middle. Also, to get out of a pair of delimiters just type the right delimiter
+and the cursor will jump to the right.
+
+If the cursor is inside an empty pair of delimiters <Space> and <CR> can be
+expanded to follow your coding style, you just need to define a couple of
+options with the desired mappings for them.
==============================================================================
2. FUNCTIONALITY PROVIDED *delimitMateFunctionality*
@@ -43,13 +51,13 @@ inserts the closing delimiter and places the cursor between the pair. With
automatic closing disabled, no closing delimiters is inserted by delimitMate,
but when a pair of delimiters is typed, the cursor is placed in the middle.
-When the cursor is inside an empty pair or located next to the left ofo a
+When the cursor is inside an empty pair or located next to the left of a
closing delimiter, the cursor is placed outside the pair to the right of the
closing delimiter.
-Unless |delimitMate_matchpairs| is set, this script uses the values in
-'&matchpirs' to identify the pairs, and the default value for quotes is
-"\" ' ` ", which can also be modified.
+Unless |'b:delimitMate_matchpairs'| and |'b:delimitMate_quotes'|is set, this
+script uses the values in '&matchpirs' to identify the pairs, and "\" ' ` "
+for quotes respectively.
The following table shows the behaviour, this applies to quotes too (the final
position of the cursor is represented by a "|"):
@@ -72,9 +80,9 @@ Without auto-close: >
------------------------------------------------------------------------------
2.2 EXPANSION OF SPACE AND CAR RETURN *delimitMateExpansion*
-When the cursor is inside an empty pair of delimiters, space and car return
-can be expanded to follow your coding style using |'delimitMate_expand_space'|
-and |'delimitMate_expand_return'|. e.g. (cursor represented by a "|"):
+When the cursor is inside an empty pair of delimiters, <Space> and <CR> can be
+expanded to follow your coding style with |'b:delimitMate_expand_space'| and
+|'b:delimitMate_expand_cr'|. e.g. (cursor represented by a "|"):
Expand <Space> to: >
@@ -108,8 +116,9 @@ e.g.: >
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 ("q" by default) should precede the delimiter. This feature doesn't
-currently work on blockwise visual mode, any sugestions are welcome.
+leader (the value of 'mapleader' by default) should precede the delimiter.
+This feature doesn't currently work on blockwise visual mode, any suggestions
+will be welcome.
e.g. (selection represented between square brackets): >
@@ -128,21 +137,21 @@ in your vimrc file.
|'loaded_delimitMate'| Turns off the script.
-|'delimitMate_autoclose'| Tells delimitMate wether to automagically
+|'delimitMate_autoclose'| Tells delimitMate whether to automagically
insert the closing delimiter.
-|'delimitMate_matchpairs'| Tells delimitMate which characters are
+|'b:delimitMate_matchpairs'| Tells delimitMate which characters are
matching pairs.
-|'delimitMate_quotes'| Tells delimitMate which quotes should be
+|'b:delimitMate_quotes'| Tells delimitMate which quotes should be
used.
|'delimitMate_visual_leader'| Sets the leader to be used in visual mode.
-|'delimitMate_expand_return'| Sets the expansion for <CR> inside an empty
+|'b:delimitMate_expand_cr'| Sets the expansion for <CR> inside an empty
pair of matching delimiters or quotes.
-|'delimitMate_expand_space'| Sets the expansion for <Space> inside an
+|'b:delimitMate_expand_space'| Sets the expansion for <Space> inside an
empty pair of matching delimiters or quotes.
------------------------------------------------------------------------------
@@ -152,34 +161,37 @@ Add the shown lines to your vimrc files in order to set the below options.
*'loaded_delimitMate'*
You can turn off this plugin using this line in your vimrc: >
- let loaded_delimitMate = 1
+ let loaded_delimitMate = 1
<
------------------------------------------------------------------------------
*'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
+automagically. See |delimitMateAutoClose| for details.
+e.g.: >
+ let 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 = "(:),[:],{:},<:>"
+matching pairs. Read |delimitMateAutoClose| for details.
+e.g: >
+ let delimitMate = "(:),[:],{:},<:>"
<
------------------------------------------------------------------------------
- *'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 = "\" ' ` *"
+quotes. Read |delimitMateAutoClose| for details.
+e.g.: >
+ let b:delimitMate_quotes = "\" ' ` *"
<
------------------------------------------------------------------------------
*'delimitMate_visual_leader'*
@@ -189,31 +201,31 @@ 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"
+ let delimitMate_visual_leader = "f"
<
------------------------------------------------------------------------------
- *'delimitMate_expand_return'*
+ *'b:delimitMate_expand_cr'*
Values: A key mapping.
Default: "\<CR>"
The value of this option will be used to expand the car return character when
typed inside an empty delimiter pair. Read |delimitMateExpansion| for details.
e.g.: >
- let delimitMate_expand_return = "\<CR>\<CR>\<Up>"
+ let b:delimitMate_expand_cr = "\<CR>\<CR>\<Up>"
<
------------------------------------------------------------------------------
- *'delimitMate_expand_space'*
+ *'b:delimitMate_expand_space'*
Values: A key mapping.
Default: "\<Space>"
The value of this option will be used to expand the space character when typed
inside an empty delimiter pair. Read |delimitMateExpansion| for details.
e.g.: >
- let delimitMate_expand_space = "\<Space>\<Space>\<Left>"
+ let b:delimitMate_expand_space = "\<Space>\<Space>\<Left>"
<
==============================================================================
- 4. PUBLIC COMMANDS *delimitMatePublicCommand*
+ 4. PUBLIC COMMANDS *delimitMatePublicCommands*
------------------------------------------------------------------------------
:DelimitMateReload *:DelimitMateReload*
@@ -295,14 +307,16 @@ represented by an "|": >
==============================================================================
5. TODO LIST *delimitMateTodo*
-- Automatic file type set-up.
+- Automatic set-up by file type.
- Make visual wrapping work on blockwise visual mode.
+- Limit behaviour by region.
+- Fix some problems wrapping a single empty line in visual mode.
==============================================================================
- 6. THE MAINTAINER *delimitMateMaintainer*
+ 6. MAINTAINER *delimitMateMaintainer*
Hi there! My name is Israel Chauca F. and I can be reached at:
-israelchauca@gmail.com
+ mailto:israelchauca@gmail.com
Feel free to send me any suggestions and/or comments about this plugin, I'll
be very pleased to read them.
@@ -321,8 +335,9 @@ from the following sources:
From the comments on the previous blog post and from:
http://gist.github.com/144619
- - Orestis Markou
- Script: simple pairs:
- http://www.vim.org/scripts/script.php?script_id=2339
+ - Vim Scripts:
+ http://www.vim.org/scripts
+
+This script was inspired by the auto-completion of delimiters of TextMate.
vim:tw=78:ts=8:ft=help:norl:
View
@@ -1,24 +1,24 @@
" ============================================================================
" File: delimitMate.vim
+" Version: 1.0
" Description: This plugin tries to emulate the auto-completion of delimiters
" that TextMate provides.
" Maintainer: Israel Chauca F. <israelchauca@gmail.com>
" Credits: Some of the code is modified or just copied from the following:
"
-" - Ian McCracken
-" Post titled: Vim, Part II: Matching Pairs:
-" http://concisionandconcinnity.blogspot.com/
+" - Ian McCracken
+" Post titled: Vim, Part II: Matching Pairs:
+" http://concisionandconcinnity.blogspot.com/
"
-" - Aristotle Pagaltzis
-" From the comments on the previous blog post and from:
-" http://gist.github.com/144619
+" - Aristotle Pagaltzis
+" From the comments on the previous blog post and from:
+" http://gist.github.com/144619
"
-" - Orestis Markou
-" Script 'simple pairs':
-" http://www.vim.org/scripts/script.php?script_id=2339
+" - Vim Scripts:
+" http://www.vim.org/scripts/
-if exists("g:loaded_delimitMate") "{{{1
- " Don't define the functions if they already exist: just do the work:
+if exists("g:loaded_delimitMate") && !exists("g:delimitMate_testing") "{{{1
+ " Don't define the functions if they already exist: just do the work (unless we are testing):
call s:DelimitMateDo()
finish
endif
@@ -38,60 +38,58 @@ function! s:Init() "{{{1
let s:autoclose = g:delimitMate_autoclose
endif
- if !exists("g:delimitMate_matchpairs")
+ if !exists("b:delimitMate_matchpairs")
if s:ValidMatchpairs(&matchpairs) == 1
let s:matchpairs_temp = &matchpairs
else
- echoerr "There seems to be a problem with 'matchpairs', read ':help matchpairs' and fix it or notify the maintainer of this script if this is a bug."
+ echoerr "delimitMate: There seems to be a problem with 'matchpairs', read ':help matchpairs' and fix it or notify the maintainer of this script if this is a bug."
finish
endif
else
- if s:ValidMatchpairs(g:delimitMate_matchpairs) || g:delimitMate_matchpairs == ""
- let s:matchpairs_temp = g:delimitMate_matchpairs
+ if s:ValidMatchpairs(b:delimitMate_matchpairs) || b:delimitMate_matchpairs == ""
+ let s:matchpairs_temp = b:delimitMate_matchpairs
else
- echoerr "Invalid format in 'g:delimitMate_matchpairs', falling back to matchpairs."
- echoerr "Fix the error and use the command :DelimitMateReload to try again."
+ echoerr "delimitMate: Invalid format in 'b:delimitMate_matchpairs', falling back to matchpairs. Fix the error and use the command :DelimitMateReload to try again."
if s:ValidMatchpairs(&matchpairs) == 1
let s:matchpairs_temp = &matchpairs
else
- echoerr "There seems to be a problem with 'matchpairs', read ':help matchpairs' and fix it or notify the maintainer of this script if this is a bug."
+ echoerr "delimitMate: There seems to be a problem with 'matchpairs', read ':help matchpairs' and fix it or notify the maintainer of this script if this is a bug."
let s:matchpairs_temp = ""
endif
-
endif
endif
- if exists("g:delimitMate_quotes")
- if g:delimitMate_quotes =~ '^\(\S\)\(\s\S\)*$' || g:delimitMate_quotes == ""
- let s:quotes = split(g:delimitMate_quotes)
+ if exists("b:delimitMate_quotes")
+ if b:delimitMate_quotes =~ '^\(\S\)\(\s\S\)*$' || b:delimitMate_quotes == ""
+ let s:quotes = split(b:delimitMate_quotes)
else
let s:quotes = split("\" ' `")
- echoerr "delimitMate: There is a problem with the format of 'delimitMate_quotes', it should be a string of single characters separated by spaces."
+ echoerr "delimitMate: There is a problem with the format of 'b:delimitMate_quotes', it should be a string of single characters separated by spaces. Falling back to default values."
endif
else
let s:quotes = split("\" ' `")
endif
if !exists("g:delimitMate_visual_leader")
- let s:visual_leader = "q"
+ let s:visual_leader = g:mapleader
else
let s:visual_leader = g:delimitMate_visual_leader
endif
- if !exists("g:delimitMate_expand_space")
+ if !exists("b:delimitMate_expand_space")
let s:expand_space = "\<Space>"
- elseif g:delimitMate_expand_space == ""
+ elseif b:delimitMate_expand_space == ""
let s:expand_space = "\<Space>"
else
- let s:expand_space = g:delimitMate_expand_space
+ let s:expand_space = b:delimitMate_expand_space
endif
- if !exists("g:delimitMate_expand_return")
+ if !exists("b:delimitMate_expand_cr")
let s:expand_return = "\<CR>"
- elseif g:delimitMate_expand_return == ""
+ elseif b:delimitMate_expand_cr == ""
let s:expand_return = "\<CR>"
else
- let s:expand_return = g:delimitMate_expand_return
+ let s:expand_return = b:delimitMate_expand_cr
endif
let s:matchpairs = split(s:matchpairs_temp, ',')
@@ -192,18 +190,15 @@ function! s:NoAutoClose() "{{{1
exec 'imap <buffer> ' . delim . ' <C-R>=<SID>SkipDelim("' . escape(delim,'"') . '")<CR>'
endfor
- " Wrap the selection with delimiters, but do nothing if blockwise visual
- " mode is active:
- ""let s:i = 0
- ""while s:i < len(s:matchpairs)
+ " Wrap the selection with delimiters, but do nothing if blockwise visual mode is active:
for i in range(len(s:matchpairs))
" Map left delimiter:
" vmap <buffer> <expr> q( visualmode() == "<C-V>" ? <SID>MapMsg(VMapMsg) : "s(\<C-R>\")\<Esc>"
exec 'vmap <buffer> <expr> ' . s:visual_leader . s:left_delims[i] . ' visualmode() == "<C-V>" ? <SID>MapMsg("' . s:VMapMsg . '") : "s' . s:left_delims[i] . '\<C-R>\"' . s:right_delims[i] . '\<Esc>"'
" Map right delimiter:
" vmap <buffer> <expr> q) visualmode() == "<C-V>" ? <SID>MapMsg(VMapMsg) : "s(\<C-R>\")\<Esc>"
- exec 'vmap <buffer> <expr> ' . s:visual_leader . s:right_delims[i] . ' visualmode() == "<C-V>" ? <SID>MapMsg("' . s:VMapMsg . '") : "s' . s:left_delims[i] . '\<C-R>\"' . s:right_delims[i] . '\<Esc>"'
+ exec 'vmap <buffer> <expr> ' . s:visual_leader . s:right_delims[i] . ' visualmode() == "<C-V>" ? <SID>MapMsg("' . s:VMapMsg . '") : "s' . s:left_delims[i] . '\<C-R>\"' . s:right_delims[i] . '"'
endfor
for quote in s:quotes
@@ -221,8 +216,7 @@ function! s:AutoClose() "{{{1
let s:i += 1
endwhile
- " Add matching quote and jump to the midle, or exit if inside a pair of
- " matching quotes:
+ " Add matching quote and jump to the midle, or exit if inside a pair of matching quotes:
" imap <buffer> " <C-R>=<SID>QuoteDelim("\"")<CR>
for delim in s:quotes
exec 'imap <buffer> ' . delim . ' <C-R>=<SID>QuoteDelim("\' . delim . '")<CR>'
@@ -234,8 +228,7 @@ function! s:AutoClose() "{{{1
exec 'imap <buffer> ' . delim . ' <C-R>=<SID>ClosePair("\' . delim . '")<CR>'
endfor
- " Wrap the selection with matching pairs, but do nothing if blockwise visual
- " mode is active:
+ " Wrap the selection with matching pairs, but do nothing if blockwise visual mode is active:
let s:i = 0
while s:i < len(s:matchpairs)
" Map left delimiter:
@@ -244,12 +237,11 @@ function! s:AutoClose() "{{{1
" Map right delimiter:
" vmap <buffer> <expr> q) visualmode() == "<C-V>" ? <SID>MapMsg("Message") : "s(\<C-R>\""\<Esc>"
- exec 'vmap <buffer> <expr> ' . s:visual_leader . s:right_delims[s:i] . ' visualmode() == "<C-V>" ? <SID>MapMsg("' . s:VMapMsg . '") : "s' . s:left_delims[s:i] . '\<C-R>\"\<Esc>"'
+ exec 'vmap <buffer> <expr> ' . s:visual_leader . s:right_delims[s:i] . ' visualmode() == "<C-V>" ? <SID>MapMsg("' . s:VMapMsg . '") : "s' . s:left_delims[s:i] . '\<C-R>\""'
let s:i += 1
endwhile
- " Wrap the selection with matching quotes, but do nothing if blockwise visual
- " mode is active:
+ " Wrap the selection with matching quotes, but do nothing if blockwise visual mode is active:
for quote in s:quotes
" vmap <buffer> <expr> q' visualmode() == "<C-V>" ? <SID>MapMsg("Message") : "s'\<C-R>\"'\<Esc>"
exec 'vmap <buffer> <expr> ' . s:visual_leader . quote . ' visualmode() == "<C-V>" ? <SID>MapMsg("' . s:VMapMsg . '") : "s' . escape(quote,'"') .'\<C-R>\"' . escape(quote,'"') . '\<Esc>"'
View
@@ -1 +0,0 @@
-To install this script just copy delimitMate.vim to your Vim's plugin folder (e.g.: $HOME/.vim/plugin) and delimitMate.txt to the respective 'doc' folder, then run 'helptags /path/to/.vim/doc'. After that you can read ':help delimitMate' for more info.

0 comments on commit c57035c

Please sign in to comment.