Skip to content

Commit

Permalink
- Single quote after an alphanumeric character is an apostrophe.
Browse files Browse the repository at this point in the history
- First attempt to behave nicely with an unbalanced quote.
  • Loading branch information
Raimondi committed Mar 23, 2010
1 parent d334819 commit 4e63e5f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .gitignore
@@ -0,0 +1,5 @@
*.sw?
*.vba
*.zip
*.gz
vimball.txt
15 changes: 15 additions & 0 deletions Makefile
@@ -0,0 +1,15 @@
PLUGIN=delimitMate

install:
cp -f doc/* ~/.vim/doc/${PLUGIN}.txt
cp -f plugin/* ~/.vim/plugin/${PLUGIN}.vim
vim -u NONE -c 'helptags ~/.vim/doc' -c 'q'

zip:
zip -r pickacolor.zip doc plugin
zip pickacolor.zip -d \*.sw\?

vimball: install
echo doc/${PLUGIN}.txt > vimball.txt
echo plugin/${PLUGIN}.vim >> vimball.txt
vim -c 'e vimball.txt' -c '%MkVimball! ${PLUGIN}' -c 'q'
12 changes: 10 additions & 2 deletions plugin/delimitMate.vim
Expand Up @@ -147,7 +147,8 @@ function! s:Init() "{{{1
endif " }}}

if !exists("b:delimitMate_apostrophes") && !exists("g:delimitMate_apostrophes") " {{{
let s:apostrophes = split("n't:'s:'re:'m:'d:'ll:'ve:s'",':')
"let s:apostrophes = split("n't:'s:'re:'m:'d:'ll:'ve:s'",':')
let s:apostrophes = []

elseif exists("b:delimitMate_apostrophes")
let s:apostrophes = split(b:delimitMate_apostrophes)
Expand All @@ -170,7 +171,7 @@ function! s:Init() "{{{1
call s:ExtraMappings()
let b:loaded_delimitMate = 1

endfunction "}}}1
endfunction "}}}1 Init()

function! s:ValidMatchpairs(str) "{{{1
if a:str !~ '^.:.\(,.:.\)*$'
Expand Down Expand Up @@ -229,6 +230,13 @@ function! s:QuoteDelim(char) "{{{1
if line[col - 2] == "\\"
" Seems like a escaped character, insert a single quotation mark.
return a:char
elseif line[col - 2] == a:char && line[col - 1 ] != a:char
" Seems like we have an unbalanced quote, insert a single
" quotation mark.
return a:char."\<Left>"
elseif a:char == "'" && line[col -2 ] =~ '[a-zA-Z0-9]'
" Seems like we follow a word, insert an apostrophe.
return a:char
elseif line[col - 1] == a:char
" Get out of the string.
return "\<Right>"
Expand Down

0 comments on commit 4e63e5f

Please sign in to comment.