changeset 4437:eb6ab7e78925

Update runtime files.
author Bram Moolenaar <bram@vim.org>
date Fri, 17 May 2013 18:14:19 +0200
parents a4fb812810e3
children 20e30e31bd86
files runtime/autoload/sqlcomplete.vim runtime/autoload/syntaxcomplete.vim runtime/compiler/msbuild.vim runtime/compiler/xbuild.vim runtime/doc/eval.txt runtime/doc/ft_sql.txt runtime/doc/if_pyth.txt runtime/doc/index.txt runtime/doc/pi_paren.txt runtime/doc/syntax.txt runtime/doc/tags runtime/doc/term.txt runtime/doc/todo.txt runtime/filetype.vim runtime/ftplugin/sql.vim runtime/indent/erlang.vim runtime/indent/tex.vim runtime/menu.vim runtime/plugin/matchparen.vim runtime/syntax/debchangelog.vim runtime/syntax/debsources.vim runtime/syntax/erlang.vim runtime/syntax/sgmllnx.vim runtime/syntax/sisu.vim runtime/syntax/sqlanywhere.vim runtime/tools/ccfilter_README.txt runtime/tutor/tutor.zh.utf-8
diffstat 27 files changed, 3046 insertions(+), 705 deletions(-) [+]
line wrap: on
line diff
--- a/runtime/autoload/sqlcomplete.vim
+++ b/runtime/autoload/sqlcomplete.vim
@@ -1,8 +1,8 @@
 " Vim OMNI completion script for SQL
 " Language:    SQL
 " Maintainer:  David Fishburn <dfishburn dot vim at gmail dot com>
-" Version:     14.0
-" Last Change: 2012 Dec 04
+" Version:     15.0
+" Last Change: 2013 May 13
 " Homepage:    http://www.vim.org/scripts/script.php?script_id=1572
 " Usage:       For detailed help
 "              ":help sql.txt"
@@ -11,6 +11,18 @@
 
 " History
 "
+" TODO
+"     - Jonas Enberg - if no table is found when using column completion
+"       look backwards to a FROM clause and find the first table
+"       and complete it.
+"
+" Version 15.0 (May 2013)
+"     - NF: Changed the SQL precached syntax items, omni_sql_precache_syntax_groups,
+"           to use regular expressions to pick up extended syntax group names.
+"           This requires an updated SyntaxComplete plugin version 13.0.
+"           If the required versions have not been installed, previous
+"           behaviour will not be impacted.
+"
 " Version 14.0 (Dec 2012)
 "     - BF: Added check for cpo
 "
@@ -91,7 +103,7 @@ endif
 if exists('g:loaded_sql_completion')
     finish
 endif
-let g:loaded_sql_completion = 130
+let g:loaded_sql_completion = 150
 let s:keepcpo= &cpo
 set cpo&vim
 
@@ -110,12 +122,14 @@ let s:syn_value             = []
 " Used in conjunction with the syntaxcomplete plugin
 let s:save_inc              = ""
 let s:save_exc              = ""
-if exists('g:omni_syntax_group_include_sql')
-    let s:save_inc = g:omni_syntax_group_include_sql
+if !exists('g:omni_syntax_group_include_sql')
+    let g:omni_syntax_group_include_sql = ''
 endif
-if exists('g:omni_syntax_group_exclude_sql')
-    let s:save_exc = g:omni_syntax_group_exclude_sql
+if !exists('g:omni_syntax_group_exclude_sql')
+    let g:omni_syntax_group_exclude_sql = ''
 endif
+let s:save_inc = g:omni_syntax_group_include_sql
+let s:save_exc = g:omni_syntax_group_exclude_sql
 
 " Used with the column list
 let s:save_prev_table       = ""
@@ -127,12 +141,12 @@ endif
 " Default syntax items to precache
 if !exists('g:omni_sql_precache_syntax_groups')
     let g:omni_sql_precache_syntax_groups = [
-                \ 'syntax',
-                \ 'sqlKeyword',
-                \ 'sqlFunction',
-                \ 'sqlOption',
-                \ 'sqlType',
-                \ 'sqlStatement'
+                \ 'syntax\w*',
+                \ 'sqlKeyword\w*',
+                \ 'sqlFunction\w*',
+                \ 'sqlOption\w*',
+                \ 'sqlType\w*',
+                \ 'sqlStatement\w*'
                 \ ]
 endif
 " Set ignorecase to the ftplugin standard
@@ -621,19 +635,23 @@ function! s:SQLCGetSyntaxList(syn_group)
         " Return previously cached value
         let compl_list = s:syn_value[list_idx]
     else
+        let s:save_inc = g:omni_syntax_group_include_sql
+        let s:save_exc = g:omni_syntax_group_exclude_sql
+        let g:omni_syntax_group_include_sql = ''
+        let g:omni_syntax_group_exclude_sql = ''
+
         " Request the syntax list items from the
         " syntax completion plugin
         if syn_group == 'syntax'
             " Handle this special case.  This allows the user
             " to indicate they want all the syntax items available,
             " so do not specify a specific include list.
-            let g:omni_syntax_group_include_sql = ''
+            let syn_value                       = syntaxcomplete#OmniSyntaxList()
         else
             " The user has specified a specific syntax group
             let g:omni_syntax_group_include_sql = syn_group
+            let syn_value                       = syntaxcomplete#OmniSyntaxList(syn_group)
         endif
-        let g:omni_syntax_group_exclude_sql = ''
-        let syn_value                       = syntaxcomplete#OmniSyntaxList()
         let g:omni_syntax_group_include_sql = s:save_inc
         let g:omni_syntax_group_exclude_sql = s:save_exc
         " Cache these values for later use
--- a/runtime/autoload/syntaxcomplete.vim
+++ b/runtime/autoload/syntaxcomplete.vim
@@ -1,18 +1,34 @@
 " Vim completion script
 " Language:    All languages, uses existing syntax highlighting rules
 " Maintainer:  David Fishburn <dfishburn dot vim at gmail dot com>
-" Version:     11.0
-" Last Change: 2012 Dec 04
+" Version:     13.0
+" Last Change: 2013 May 14
 " Usage:       For detailed help, ":help ft-syntax-omni"
 
 " History
 "
+" Version 13.0
+"   - Extended the option omni_syntax_group_include_{filetype}
+"     to accept a comma separated list of regex's rather than
+"     string.  For example, for the javascript filetype you could
+"     use:
+"        let g:omni_syntax_group_include_javascript = 'javascript\w\+,jquery\w\+'
+"   - Some syntax files (perl.vim) use the match // syntax as a mechanism
+"     to identify keywords.  This update attempts to parse the
+"     match syntax and pull out syntax items which are at least
+"     3 words or more.
+"
+" Version 12.0
+"   - It is possible to have '-' as part of iskeyword, when
+"     checking for character ranges, tighten up the regex.
+"     E688: More targets than List items.
+"
 " Version 11.0
-"     Corrected which characters required escaping during
+"   - Corrected which characters required escaping during
 "     substitution calls.
 "
 " Version 10.0
-"     Cycle through all the character ranges specified in the
+"   - Cycle through all the character ranges specified in the
 "     iskeyword option and build a list of valid word separators.
 "     Prior to this change, only actual characters were used,
 "     where for example ASCII "45" == "-".  If "45" were used
@@ -20,30 +36,30 @@
 "     This introduces a new option, since the character ranges
 "     specified could be multibyte:
 "         let g:omni_syntax_use_single_byte = 1
-"     This by default will only allow single byte ASCII
+"   - This by default will only allow single byte ASCII
 "     characters to be added and an additional check to ensure
 "     the charater is printable (see documentation for isprint).
 "
 " Version 9.0
-"     Add the check for cpo.
+"   - Add the check for cpo.
 "
 " Version 8.0
-"     Updated SyntaxCSyntaxGroupItems()
+"   - Updated SyntaxCSyntaxGroupItems()
 "         - Some additional syntax items were also allowed
 "           on nextgroup= lines which were ignored by default.
 "           Now these lines are processed independently.
 "
 " Version 7.0
-"     Updated syntaxcomplete#OmniSyntaxList()
+"   - Updated syntaxcomplete#OmniSyntaxList()
 "         - Looking up the syntax groups defined from a syntax file
 "           looked for only 1 format of {filetype}GroupName, but some
 "           syntax writers use this format as well:
 "               {b:current_syntax}GroupName
-"           OmniSyntaxList() will now check for both if the first
+"   -       OmniSyntaxList() will now check for both if the first
 "           method does not find a match.
 "
 " Version 6.0
-"     Added syntaxcomplete#OmniSyntaxList()
+"   - Added syntaxcomplete#OmniSyntaxList()
 "         - Allows other plugins to use this for their own
 "           purposes.
 "         - It will return a List of all syntax items for the
@@ -52,7 +68,7 @@
 "           sqlcomplete plugin to populate a Choose box.
 "
 " Version 5.0
-"     Updated SyntaxCSyntaxGroupItems()
+"   - Updated SyntaxCSyntaxGroupItems()
 "         - When processing a list of syntax groups, the final group
 "           was missed in function SyntaxCSyntaxGroupItems.
 "
@@ -70,7 +86,7 @@ endif
 if exists('g:loaded_syntax_completion')
     finish
 endif
-let g:loaded_syntax_completion = 110
+let g:loaded_syntax_completion = 130
 
 " Turn on support for line continuations when creating the script
 let s:cpo_save = &cpo
@@ -113,7 +129,8 @@ endif
 
 " This script will build a completion list based on the syntax
 " elements defined by the files in $VIMRUNTIME/syntax.
-let s:syn_remove_words = 'match,matchgroup=,contains,'.
+" let s:syn_remove_words = 'match,matchgroup=,contains,'.
+let s:syn_remove_words = 'matchgroup=,contains,'.
             \ 'links to,start=,end='
             " \ 'links to,start=,end=,nextgroup='
 
@@ -275,9 +292,19 @@ function! OmniSyntaxList(...)
     "     sqlType
     "     sqlOperators
     "     sqlKeyword ...
-    redir @l
-    silent! exec 'syntax list '.join(list_parms)
-    redir END
+    if !empty(list_parms) && empty(substitute(join(list_parms), '[a-zA-Z ]', '', 'g'))
+        " If list_parms only includes word characters, use it to limit
+        " the syntax elements.
+        " If using regex syntax list will fail to find those items, so
+        " simply grab the who syntax list.
+        redir @l
+        silent! exec 'syntax list '.join(list_parms)
+        redir END
+    else
+        redir @l
+        silent! exec 'syntax list'
+        redir END
+    endif
 
     let syntax_full = "\n".@l
     let @l = saveL
@@ -311,82 +338,167 @@ function! OmniSyntaxList(...)
         endif
     endif
 
-    " Sometimes filetypes can be composite names, like c.doxygen
-    " Loop through each individual part looking for the syntax
-    " items specific to each individual filetype.
-    let syn_list = ''
-    let ftindex  = 0
-    let ftindex  = match(&filetype, '\w\+', ftindex)
-
-    while ftindex > -1
-        let ft_part_name = matchstr( &filetype, '\w\+', ftindex )
+    if empty(list_parms)
+        let list_parms = [&filetype.'\w\+']
+    endif
 
-        " Syntax rules can contain items for more than just the current
-        " filetype.  They can contain additional items added by the user
-        " via autocmds or their vimrc.
-        " Some syntax files can be combined (html, php, jsp).
-        " We want only items that begin with the filetype we are interested in.
-        let next_group_regex = '\n' .
-                    \ '\zs'.ft_part_name.'\w\+\ze'.
-                    \ '\s\+xxx\s\+'
-        let index    = 0
-        let index    = match(syntax_full, next_group_regex, index)
+    let syn_list = ''
+    let index    = 0
+    for group_regex in list_parms
+        " Sometimes filetypes can be composite names, like c.doxygen
+        " Loop through each individual part looking for the syntax
+        " items specific to each individual filetype.
+        " let ftindex  = 0
+        " let ftindex  = match(syntax_full, group_regex, ftindex)
 
-        if index == -1 && exists('b:current_syntax') && ft_part_name != b:current_syntax
-            " There appears to be two standards when writing syntax files.
-            " Either items begin as:
-            "     syn keyword {filetype}Keyword         values ...
-            "     let b:current_syntax = "sql"
-            "     let b:current_syntax = "sqlanywhere"
-            " Or
-            "     syn keyword {syntax_filename}Keyword  values ...
-            "     let b:current_syntax = "mysql"
-            " So, we will make the format of finding the syntax group names
-            " a bit more flexible and look for both if the first fails to
-            " find a match.
+        " while ftindex > -1
+            " let ft_part_name = matchstr( syntax_full, '\w\+', ftindex )
+
+            " Syntax rules can contain items for more than just the current
+            " filetype.  They can contain additional items added by the user
+            " via autocmds or their vimrc.
+            " Some syntax files can be combined (html, php, jsp).
+            " We want only items that begin with the filetype we are interested in.
             let next_group_regex = '\n' .
-                        \ '\zs'.b:current_syntax.'\w\+\ze'.
+                        \ '\zs'.group_regex.'\ze'.
                         \ '\s\+xxx\s\+'
-            let index    = 0
             let index    = match(syntax_full, next_group_regex, index)
-        endif
-
-        while index > -1
-            let group_name = matchstr( syntax_full, '\w\+', index )
-
-            let get_syn_list = 1
-            for exclude_group_name in list_exclude_groups
-                if '\<'.exclude_group_name.'\>' =~ '\<'.group_name.'\>'
-                    let get_syn_list = 0
-                endif
-            endfor
 
-            " This code is no longer needed in version 6.0 since we have
-            " augmented the syntax list command to only retrieve the syntax
-            " groups we are interested in.
-            "
-            " if get_syn_list == 1
-            "     if syntax_group_include_{filetype} != ''
-            "         if '\<'.syntax_group_include_{filetype}.'\>' !~ '\<'.group_name.'\>'
-            "             let get_syn_list = 0
-            "         endif
-            "     endif
-            " endif
-
-            if get_syn_list == 1
-                " Pass in the full syntax listing, plus the group name we
-                " are interested in.
-                let extra_syn_list = s:SyntaxCSyntaxGroupItems(group_name, syntax_full)
-                let syn_list = syn_list . extra_syn_list . "\n"
+            " For the matched group name, strip off any of the regex special
+            " characters and see if we get a match with the current syntax
+            if index == -1 && exists('b:current_syntax') && substitute(group_regex, '[^a-zA-Z ]\+.*', '', 'g') !~ '^'.b:current_syntax
+                " There appears to be two standards when writing syntax files.
+                " Either items begin as:
+                "     syn keyword {filetype}Keyword         values ...
+                "     let b:current_syntax = "sql"
+                "     let b:current_syntax = "sqlanywhere"
+                " Or
+                "     syn keyword {syntax_filename}Keyword  values ...
+                "     let b:current_syntax = "mysql"
+                " So, we will make the format of finding the syntax group names
+                " a bit more flexible and look for both if the first fails to
+                " find a match.
+                let next_group_regex = '\n' .
+                            \ '\zs'.b:current_syntax.'\w\+\ze'.
+                            \ '\s\+xxx\s\+'
+                let index    = 0
+                let index    = match(syntax_full, next_group_regex, index)
             endif
 
-            let index = index + strlen(group_name)
-            let index = match(syntax_full, next_group_regex, index)
-        endwhile
+            while index > -1
+                let group_name = matchstr( syntax_full, '\w\+', index )
+
+                let get_syn_list = 1
+                for exclude_group_name in list_exclude_groups
+                    if '\<'.exclude_group_name.'\>' =~ '\<'.group_name.'\>'
+                        let get_syn_list = 0
+                    endif
+                endfor
+
+                " This code is no longer needed in version 6.0 since we have
+                " augmented the syntax list command to only retrieve the syntax
+                " groups we are interested in.
+                "
+                " if get_syn_list == 1
+                "     if syntax_group_include_{filetype} != ''
+                "         if '\<'.syntax_group_include_{filetype}.'\>' !~ '\<'.group_name.'\>'
+                "             let get_syn_list = 0
+                "         endif
+                "     endif
+                " endif
+
+                if get_syn_list == 1
+                    " Pass in the full syntax listing, plus the group name we
+                    " are interested in.
+                    let extra_syn_list = s:SyntaxCSyntaxGroupItems(group_name, syntax_full)
+                    let syn_list = syn_list . extra_syn_list . "\n"
+                endif
+
+                let index = index + strlen(group_name)
+                let index = match(syntax_full, next_group_regex, index)
+            endwhile
+
+            " let ftindex  = ftindex + len(ft_part_name)
+            " let ftindex  = match( syntax_full, group_regex, ftindex )
+        " endwhile
+    endfor
+
+"   " Sometimes filetypes can be composite names, like c.doxygen
+"   " Loop through each individual part looking for the syntax
+"   " items specific to each individual filetype.
+"   let syn_list = ''
+"   let ftindex  = 0
+"   let ftindex  = match(&filetype, '\w\+', ftindex)
+
+"   while ftindex > -1
+"       let ft_part_name = matchstr( &filetype, '\w\+', ftindex )
 
-        let ftindex  = ftindex + len(ft_part_name)
-        let ftindex  = match( &filetype, '\w\+', ftindex )
-    endwhile
+"       " Syntax rules can contain items for more than just the current
+"       " filetype.  They can contain additional items added by the user
+"       " via autocmds or their vimrc.
+"       " Some syntax files can be combined (html, php, jsp).
+"       " We want only items that begin with the filetype we are interested in.
+"       let next_group_regex = '\n' .
+"                   \ '\zs'.ft_part_name.'\w\+\ze'.
+"                   \ '\s\+xxx\s\+'
+"       let index    = 0
+"       let index    = match(syntax_full, next_group_regex, index)
+
+"       if index == -1 && exists('b:current_syntax') && ft_part_name != b:current_syntax
+"           " There appears to be two standards when writing syntax files.
+"           " Either items begin as:
+"           "     syn keyword {filetype}Keyword         values ...
+"           "     let b:current_syntax = "sql"
+"           "     let b:current_syntax = "sqlanywhere"
+"           " Or
+"           "     syn keyword {syntax_filename}Keyword  values ...
+"           "     let b:current_syntax = "mysql"
+"           " So, we will make the format of finding the syntax group names
+"           " a bit more flexible and look for both if the first fails to
+"           " find a match.
+"           let next_group_regex = '\n' .
+"                       \ '\zs'.b:current_syntax.'\w\+\ze'.
+"                       \ '\s\+xxx\s\+'
+"           let index    = 0
+"           let index    = match(syntax_full, next_group_regex, index)
+"       endif
+
+"       while index > -1
+"           let group_name = matchstr( syntax_full, '\w\+', index )
+
+"           let get_syn_list = 1
+"           for exclude_group_name in list_exclude_groups
+"               if '\<'.exclude_group_name.'\>' =~ '\<'.group_name.'\>'
+"                   let get_syn_list = 0
+"               endif
+"           endfor
+
+"           " This code is no longer needed in version 6.0 since we have
+"           " augmented the syntax list command to only retrieve the syntax
+"           " groups we are interested in.
+"           "
+"           " if get_syn_list == 1
+"           "     if syntax_group_include_{filetype} != ''
+"           "         if '\<'.syntax_group_include_{filetype}.'\>' !~ '\<'.group_name.'\>'
+"           "             let get_syn_list = 0
+"           "         endif
+"           "     endif
+"           " endif
+
+"           if get_syn_list == 1
+"               " Pass in the full syntax listing, plus the group name we
+"               " are interested in.
+"               let extra_syn_list = s:SyntaxCSyntaxGroupItems(group_name, syntax_full)
+"               let syn_list = syn_list . extra_syn_list . "\n"
+"           endif
+
+"           let index = index + strlen(group_name)
+"           let index = match(syntax_full, next_group_regex, index)
+"       endwhile
+
+"       let ftindex  = ftindex + len(ft_part_name)
+"       let ftindex  = match( &filetype, '\w\+', ftindex )
+"   endwhile
 
     " Convert the string to a List and sort it.
     let compl_list = sort(split(syn_list))
@@ -454,10 +566,65 @@ function! s:SyntaxCSyntaxGroupItems( gro
                     \    , "\n", 'g'
                     \  )
 
+        " Attempt to deal with lines using the match syntax
+        " javaScriptDocTags xxx match /@\(param\|argument\|requires\|file\)\>/
+        " Though it can use any types of regex, so this plugin will attempt
+        " to restrict it
+        " 1.  Only use \( or \%( constructs remove all else
+        " 2   Remove and []s
+        " 3.  Account for match //constructs
+        "                       \%(\%(ms\|me\|hs\|he\|rs\|re\|lc\)\S\+\)\?
+        " 4.  Hope for the best
+        "
+        "
+        let syn_list_old = syn_list
+        while syn_list =~ '\<match\>\s\+\/'
+            if syn_list =~ 'perlElseIfError'
+                let syn_list = syn_list
+            endif
+            " Check if the match has words at least 3 characters long
+            if syn_list =~ '\<match \/\zs.\{-}\<\w\{3,}\>.\{-}\ze\\\@<!\/\%(\%(ms\|me\|hs\|he\|rs\|re\|lc\)\S\+\)\?\s\+'
+                " Remove everything after / and before the first \(
+                let syn_list = substitute( syn_list, '\<match \/\zs.\{-}\ze\\%\?(.\{-}\\\@<!\/\%(\%(ms\|me\|hs\|he\|rs\|re\|lc\)\S\+\)\?\s\+', '', 'g' )
+                " Remove everything after \) and up to the ending /
+                let syn_list = substitute( syn_list, '\<match \/.\{-}\\)\zs.\{-}\ze\/\%(\%(ms\|me\|hs\|he\|rs\|re\|lc\)\S\+\)\?\s\+', '', 'g' )
+
+                " Remove any character classes
+                " let syn_list = substitute( syn_list, '\<match /\zs.\{-}\[[^]]*\].\{-}\ze\/ ', '', 'g' )
+                let syn_list = substitute( syn_list, '\%(\<match \/[^/]\{-}\)\@<=\[[^]]*\]\ze.\{-}\\\@<!\/\%(\%(ms\|me\|hs\|he\|rs\|re\|lc\)\S\+\)\?', '', 'g' )
+                " Remove any words < 3 characters
+                let syn_list = substitute( syn_list, '\%(\<match \/[^/]\{-}\)\@<=\<\w\{1,2}\>\ze.\{-}\\\@<!\/\%(\%(ms\|me\|hs\|he\|rs\|re\|lc\)\S\+\)\?\s\+', '', 'g' )
+                " Remove all non-word characters
+                " let syn_list = substitute( syn_list, '\<match /\zs.\{-}\<\W\+\>.\{-}\ze\/ ', "", 'g' )
+                " let syn_list = substitute( syn_list, '\%(\<match \/[^/]\{-}\)\@<=\W\+\ze.\{-}\/ ', ' ', 'g' )
+                " Do this by using the outer substitue() call to gather all
+                " text between the match /.../ tags.
+                " The inner substitute() call operates on the text selected
+                " and replaces all non-word characters.
+                let syn_list = substitute( syn_list, '\<match \/\zs\(.\{-}\)\ze\\\@<!\/\%(\%(ms\|me\|hs\|he\|rs\|re\|lc\)\S\+\)\?\s\+'
+                            \ , '\=substitute(submatch(1), "\\W\\+", " ", "g")'
+                            \ , 'g' )
+                " Remove the match / / syntax
+                let syn_list = substitute( syn_list, '\<match \/\(.\{-}\)\/\%(\%(ms\|me\|hs\|he\|rs\|re\|lc\)\S\+\)\?\s\+', '\1', 'g' )
+            else
+                " No words long enough, remove the match
+                " Remove the match syntax
+                " let syn_list = substitute( syn_list, '\<match \/[^\/]*\/\%(\%(ms\|me\|hs\|he\|rs\|re\|lc\)\S\+\)\?\s\+', '', 'g' )
+                let syn_list = substitute( syn_list, '\<match \/\%(.\{-}\)\?\/\%(\%(ms\|me\|hs\|he\|rs\|re\|lc\)\S\+\)\?\s\+', '', 'g' )
+            endif
+            if syn_list =~ '\<match\>\s\+\/'
+                " Problem removing the match / / tags
+                let syn_list = ''
+            endif
+        endwhile
+
+
         " Now strip off the newline + blank space + contained.
         " Also include lines with nextgroup=@someName skip_key_words syntax_element
+                    " \    syn_list, '\%(^\|\n\)\@<=\s*\<\(contained\|nextgroup=\)'
+                    " \    syn_list, '\%(^\|\n\)\@<=\s*\<\(contained\|nextgroup=[@a-zA-Z,]*\)'
         let syn_list = substitute(
-                    \    syn_list, '\%(^\|\n\)\@<=\s*\<\(contained\|nextgroup=\)'
+                    \    syn_list, '\<\(contained\|nextgroup=[@a-zA-Z,]*\)'
                     \    , "", 'g'
                     \ )
 
@@ -497,7 +664,7 @@ function! s:SyntaxCSyntaxGroupItems( gro
                 " If so, add it to the list.
                 let accepted_chars = ''
                 for item in split(&iskeyword, ',')
-                    if item =~ '-'
+                    if item =~ '\d-\d'
                         " This is a character range (ie 47-58),
                         " cycle through each character within the range
                         let [b:start, b:end] = split(item, '-')
new file mode 100644
--- /dev/null
+++ b/runtime/compiler/msbuild.vim
@@ -0,0 +1,21 @@
+" Vim compiler file
+" Compiler:	Microsoft Visual Studio C#
+" Maintainer:	Chiel ten Brinke (ctje92@gmail.com)
+" Last Change:	2013 May 13
+
+if exists("current_compiler")
+  finish
+endif
+let current_compiler = "msbuild"
+let s:keepcpo= &cpo
+set cpo&vim
+
+if exists(":CompilerSet") != 2		" older Vim always used :setlocal
+  command -nargs=* CompilerSet setlocal <args>
+endif
+
+CompilerSet errorformat=\ %#%f(%l\\\,%c):\ %m
+CompilerSet makeprg=msbuild\ /nologo\ /v:q\ /property:GenerateFullPaths=true
+
+let &cpo = s:keepcpo
+unlet s:keepcpo
new file mode 100644
--- /dev/null
+++ b/runtime/compiler/xbuild.vim
@@ -0,0 +1,22 @@
+" Vim compiler file
+" Compiler:	Mono C#
+" Maintainer:	Chiel ten Brinke (ctje92@gmail.com)
+" Last Change:	2013 May 13
+
+if exists("current_compiler")
+  finish
+endif
+
+let current_compiler = "xbuild"
+let s:keepcpo= &cpo
+set cpo&vim
+
+if exists(":CompilerSet") != 2		" older Vim always used :setlocal
+  command -nargs=* CompilerSet setlocal <args>
+endif
+
+CompilerSet errorformat=\ %#%f(%l\\\,%c):\ %m
+CompilerSet makeprg=xbuild\ /nologo\ /v:q\ /property:GenerateFullPaths=true
+
+let &cpo = s:keepcpo
+unlet s:keepcpo
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -1,4 +1,4 @@
-*eval.txt*	For Vim version 7.3.  Last change: 2013 May 06
+*eval.txt*	For Vim version 7.3.  Last change: 2013 May 17
 
 
 		  VIM REFERENCE MANUAL	  by Bram Moolenaar
@@ -1171,7 +1171,7 @@ b:changedtick	The total number of change
 A variable name that is preceded with "w:" is local to the current window.  It
 is deleted when the window is closed.
 
-						*tabpage-variable* *t:var*
+						*tabpage-variable* *t:var* *t:*
 A variable name that is preceded with "t:" is local to the current tab page,
 It is deleted when the tab page is closed. {not available when compiled
 without the |+windows| feature}
--- a/runtime/doc/ft_sql.txt
+++ b/runtime/doc/ft_sql.txt
@@ -1,4 +1,4 @@
-*ft_sql.txt*	For Vim version 7.3.  Last change: 2013 Apr 05
+*ft_sql.txt*	For Vim version 7.3.  Last change: 2013 May 15
 
 by David Fishburn
 
@@ -349,6 +349,7 @@ may not work properly on all platforms: 
 The static maps (which are based on the syntax highlight groups) follow this
 format: >
     imap <buffer> <C-C>k <C-\><C-O>:call sqlcomplete#Map('sqlKeyword')<CR><C-X><C-O>
+    imap <buffer> <C-C>k <C-\><C-O>:call sqlcomplete#Map('sqlKeyword\w*')<CR><C-X><C-O>
 
 This command breaks down as: >
     imap		   - Create an insert map
@@ -369,6 +370,9 @@ This command breaks down as: >
 			     command while editing a SQL file.
     'sqlKeyword'	   - Display the items for the sqlKeyword highlight
 			     group
+    'sqlKeyword\w*'	   - A second option available with Vim 7.4 which
+                             uses a regular expression to determine which
+			     syntax groups to use
     )<CR>		   - Execute the :let command
     <C-X><C-O>		   - Trigger the standard omni completion key stroke.
 			     Passing in 'sqlKeyword' instructs the SQL
--- a/runtime/doc/if_pyth.txt
+++ b/runtime/doc/if_pyth.txt
@@ -1,4 +1,4 @@
-*if_pyth.txt*   For Vim version 7.3.  Last change: 2013 May 06
+*if_pyth.txt*   For Vim version 7.3.  Last change: 2013 May 17
 
 
 		  VIM REFERENCE MANUAL    by Paul Moore
--- a/runtime/doc/index.txt
+++ b/runtime/doc/index.txt
@@ -1,4 +1,4 @@
-*index.txt*     For Vim version 7.3.  Last change: 2013 May 06
+*index.txt*     For Vim version 7.3.  Last change: 2013 May 17
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -1403,8 +1403,10 @@ tag	      command	      action ~
 |:pwd|		:pw[d]		print current directory
 |:py3|		:py3		execute Python 3 command
 |:python3|	:python3	same as :py3
+|:py3do|	:py3d[o]	execute Python 3 command for each line
 |:py3file|	:py3f[ile]	execute Python 3 script file
 |:python|	:py[thon]	execute Python command
+|:pydo|		:pyd[o]		execute Python command for each line
 |:pyfile|	:pyf[ile]	execute Python script file
 |:quit|		:q[uit]		quit current window (when one window quit Vim)
 |:quitall|	:quita[ll]	quit Vim
--- a/runtime/doc/pi_paren.txt
+++ b/runtime/doc/pi_paren.txt
@@ -1,4 +1,4 @@
-*pi_paren.txt*  For Vim version 7.3.  Last change: 2008 Jun 16
+*pi_paren.txt*  For Vim version 7.3.  Last change: 2013 May 08
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -46,7 +46,10 @@ are:
   closed folds.
 - 'synmaxcol' times 2 bytes before or after the cursor to avoid a delay
   in a long line with syntax highlighting.
-
+- A timeout of 300 msec (60 msec in Insert mode). This can be changed with the
+  g:matchparen_timeout and g:matchparen_insert_timeout variables and their
+  buffer-local equivalents b:matchparen_timeout and
+  b:matchparen_insert_timeout.
 
 If you would like the |%| command to work better, the matchit plugin can be
 used, see |matchit-install|.  This plugin also helps to skip matches in
--- a/runtime/doc/syntax.txt
+++ b/runtime/doc/syntax.txt
@@ -1239,17 +1239,17 @@ to your startup file.
 
 ERLANG						*erlang.vim* *ft-erlang-syntax*
 
-The erlang highlighting supports Erlang (ERicsson LANGuage).
-Erlang is case sensitive and default extension is ".erl".
-
-If you want to disable keywords highlighting, put in your .vimrc: >
-	:let erlang_keywords = 1
-If you want to disable built-in-functions highlighting, put in your
-.vimrc file: >
-	:let erlang_functions = 1
-If you want to disable special characters highlighting, put in
-your .vimrc: >
-	:let erlang_characters = 1
+Erlang is a functional programming language developed by Ericsson.  Files with
+the following extentions are recognized as Erlang files: erl, hrl, yaws.
+
+The BIFs (built-in functions) are highlighted by default. To disable this,
+put the following line in your vimrc: >
+
+      :let g:erlang_highlight_bifs = 0
+
+To enable highlighting some special atoms, put this in your vimrc: >
+
+      :let g:erlang_highlight_special_atoms = 1
 
 
 FLEXWIKI				*flexwiki.vim* *ft-flexwiki-syntax*
--- a/runtime/doc/tags
+++ b/runtime/doc/tags
@@ -2590,7 +2590,9 @@ 90.5	usr_90.txt	/*90.5*
 :pwd	editing.txt	/*:pwd*
 :py	if_pyth.txt	/*:py*
 :py3	if_pyth.txt	/*:py3*
+:py3do	if_pyth.txt	/*:py3do*
 :py3file	if_pyth.txt	/*:py3file*
+:pydo	if_pyth.txt	/*:pydo*
 :pyf	if_pyth.txt	/*:pyf*
 :pyfile	if_pyth.txt	/*:pyfile*
 :python	if_pyth.txt	/*:python*
@@ -4258,6 +4260,7 @@ E86	windows.txt	/*E86*
 E860	eval.txt	/*E860*
 E861	eval.txt	/*E861*
 E862	eval.txt	/*E862*
+E863	if_pyth.txt	/*E863*
 E87	windows.txt	/*E87*
 E88	windows.txt	/*E88*
 E89	message.txt	/*E89*
@@ -7336,6 +7339,8 @@ python-options	if_pyth.txt	/*python-opti
 python-output	if_pyth.txt	/*python-output*
 python-pyeval	if_pyth.txt	/*python-pyeval*
 python-range	if_pyth.txt	/*python-range*
+python-tabpage	if_pyth.txt	/*python-tabpage*
+python-tabpages	if_pyth.txt	/*python-tabpages*
 python-vars	if_pyth.txt	/*python-vars*
 python-vim	if_pyth.txt	/*python-vim*
 python-vvars	if_pyth.txt	/*python-vvars*
@@ -7851,6 +7856,7 @@ system-functions	usr_41.txt	/*system-fun
 system-vimrc	starting.txt	/*system-vimrc*
 s~	change.txt	/*s~*
 t	motion.txt	/*t*
+t:	eval.txt	/*t:*
 t:var	eval.txt	/*t:var*
 t_#2	term.txt	/*t_#2*
 t_#4	term.txt	/*t_#4*
--- a/runtime/doc/term.txt
+++ b/runtime/doc/term.txt
@@ -328,7 +328,7 @@ Note: Use the <> form if possible
 	t_k8	<F8>		function key 8		*<F8>*	*t_k8* *'t_k8'*
 	t_k9	<F9>		function key 9		*<F9>*	*t_k9* *'t_k9'*
 	t_k;	<F10>		function key 10		*<F10>*	*t_k;* *'t_k;'*
-	t_F1	<F11>		function key 11		*<F11>* *t_F1* *'t_F1'*
+	t_F1	<F11>		function key 11		*<F11>*	*t_F1* *'t_F1'*
 	t_F2	<F12>		function key 12		*<F12>*	*t_F2* *'t_F2'*
 	t_F3	<F13>		function key 13		*<F13>*	*t_F3* *'t_F3'*
 	t_F4	<F14>		function key 14		*<F14>*	*t_F4* *'t_F4'*
@@ -358,9 +358,9 @@ Note: Use the <> form if possible
 	t_kI	<Insert>	insert key			*t_kI* *'t_kI'*
 	t_kD	<Del>		delete key			*t_kD* *'t_kD'*
 	t_kb	<BS>		backspace key			*t_kb* *'t_kb'*
-	t_kB	<S-Tab>		back-tab (shift-tab)  *<S-Tab>* *t_kB* *'t_kB'*
+	t_kB	<S-Tab>		back-tab (shift-tab)  *<S-Tab>*	*t_kB* *'t_kB'*
 	t_kh	<Home>		home key			*t_kh* *'t_kh'*
-	t_#2	<S-Home>	shifted home key     *<S-Home>* *t_#2* *'t_#2'*
+	t_#2	<S-Home>	shifted home key     *<S-Home>*	*t_#2* *'t_#2'*
 		<xHome>		alternate home key		*<xHome>*
 	t_@7	<End>		end key				*t_@7* *'t_@7'*
 	t_*7	<S-End>		shifted end key	*<S-End>* *t_star7* *'t_star7'*
@@ -373,8 +373,8 @@ Note: Use the <> form if possible
 	t_K5	<kPageDown>	keypad page-down key		*t_K5* *'t_K5'*
 	t_K6	<kPlus>		keypad plus key	      *<kPlus>*	*t_K6* *'t_K6'*
 	t_K7	<kMinus>	keypad minus key     *<kMinus>*	*t_K7* *'t_K7'*
-	t_K8	<kDivide>	keypad divide	    *<kDivide>* *t_K8* *'t_K8'*
-	t_K9	<kMultiply>	keypad multiply   *<kMultiply>* *t_K9* *'t_K9'*
+	t_K8	<kDivide>	keypad divide	    *<kDivide>*	*t_K8* *'t_K8'*
+	t_K9	<kMultiply>	keypad multiply   *<kMultiply>*	*t_K9* *'t_K9'*
 	t_KA	<kEnter>	keypad enter key     *<kEnter>*	*t_KA* *'t_KA'*
 	t_KB	<kPoint>	keypad decimal point *<kPoint>*	*t_KB* *'t_KB'*
 	t_KC	<k0>		keypad 0		 *<k0>*	*t_KC* *'t_KC'*
--- a/runtime/doc/todo.txt
+++ b/runtime/doc/todo.txt
@@ -1,4 +1,4 @@
-*todo.txt*      For Vim version 7.3.  Last change: 2013 May 06
+*todo.txt*      For Vim version 7.3.  Last change: 2013 May 17
 
 
 		  VIM REFERENCE MANUAL	  by Bram Moolenaar
@@ -34,6 +34,134 @@ not be repeated below, unless there is e
 							*known-bugs*
 -------------------- Known bugs and current work -----------------------
 
+--- Python interface
+
+Python SystemExit exception is not handled properly.  Patch to catch the
+exception and give an error. (Yasuhiro Matsumoto)
+Does not work, tests fail.
+
+Patch to print the result of a :python command. (Maxim Philippov
+<philippovmi@gmail.com>, 2012 Aug 16)  Update Aug 17.
+Patch no longer applies.
+
+":python os.chdir('/tmp')" makes short buffer names invalid. (Xavier de Gaye)
+Check directory and call shorten_fnames()?  Better: make os.chdir()
+invoke the interal :cd implementation, that takes care of all side
+effects.
+
+Mac: OS/X 10.4 with Python 2.5 installed: configure finds an extra argument
+that breaks the build. (Brian Victor, 2008 Sep 1)
+
+Patch to access screen under Python. (Marko Mahni, 2010 Jul 18)
+
+Python: ":py raw_input('prompt')" doesn't work. (Manu Hack)
+
+Win32: The Python interface only works with one version of Python, selected at
+compile time.  Can this be made to work with version 2.1 and 2.2 dynamically?
+
+Python: Be able to define a Python function that can be called directly from
+Vim script.  Requires converting the arguments and return value.
+
+--- runtime files
+
+Syntax file for protocol buffers. (Feng Xiao, 2013 May 9)
+Has an ugly copyright notice.  No conflict with Vim license?
+
+Patch for JavaScript syntax. (Kevin Locke, 2013 May 9)
+Claudio didn't respond yet.
+
+--- Fast regexp engine
+
+Including NFA regexp code.  Latest version probably is:
+https://code.google.com/p/vim-soc2008-regexp/source/browse/trunk/vim72-re/src/regexp_nfa.c
+Patch updated by Ken Takata. (May 13)
+
+To be able to run tests:
+- set defaultre=old / nfa / auto
+- In pattern use "\%#= to set the engine: 0 = automatic, 1 = old 2 = nfa
+
+Get example files for many languages. Compare syntax highlighting with old and
+new regexp, find regexp constructs where NFA does not work correctly.
+Idea for comparing output: use format.vim (ZyX, 2013 May 12)
+MakeSynChk from Charles Campbell. (May 14)
+
+Performance tests:
+- ~/vim/test/veryslow.js (file from Daniel Fetchinson)
+- ~/vim/test/slowsearch
+- ~/vim/test/rgb.vim
+- ~/vim/text/FeiqCfg.xml (file from Netjune)
+- ~/vim/text/edl.svg  (also XML)
+- search for  a.*e*exn  in the vim executable.  Go to last line to use
+  'hlsearch'.
+
+--- bug fixes
+
+Patch to avoid wrong error message for 1.0[0]. (Yasuhiro Matsumoto, 2013 May
+1)
+
+Patch for if_lua. (Luis Carvalho, 2012 Aug 26, update Aug 29, another Aug 30,
+then Sep 1, reminder Oct 14)
+
+Patch to check if 'foldexpr' sets did_emsg. (Christian Brabandt, 2013 Mar 20)
+
+Patch for 'backupcopy' default behavior for symlinks on Windows. (David Pope,
+2012 Mar 21, update Mar 31)
+With fix for memory leak: Ken Takata, 2012 Aug 24
+Another update Sep 24.
+Also patch from Joerg Bornemann, 2013 Apr 30.
+
+Undo problem: line not removed as expected when using setline() from Insert
+mode. (Israel Chauca, 2010 May 13, more in second msg)
+Break undo when CTRL-R = changes the text?  Or save more lines?
+Patch by Christian Brabandt, 2012 Nov 16.
+
+Do allow real tags above the !_TAG entries. Undo older patch. Issue 90.
+
+Matches might be highlighted correctly. Inefficient patch by Christian
+Brabandt, 2013 Feb 26.
+
+Patch to use bold/italic fonts when 'guifontewide' is set. (Ken Takata, 2013
+Mar 31)
+
+Problem with winfixheight and resizing. (Yukihiro Nakadaira, 2011 Sep 17)
+Patch Sep 18.
+
+Patch for IME problems. Remove hacking code for old IM. (Yukihiro Nakadaira,
+2012 Jul 20)
+
+Patch to fix finding toolbar bitmaps.  Issue 129.
+
+Combining characters are not used when executing a register with :@w.
+(William Fugh, 2013 Apr 5, more info from Ben Fritz)
+Patch by Christian Brabandt, 2013 Apr 6.  Second one.
+
+MS-Windows ACL support doesn't work well.  Patch from Ken Takata, 2012 Aug 29.
+Update Aug 31.
+Another patch for MingW, 2012 Dec 29.
+
+Bug in completion menu. (Olivier Teuliere, 2013 Feb 15)
+Patch by Christian Brabandt, Feb 16.
+
+'cursorline' is drawn incorrectly in diff mode. Patch by Christian Brabandt,
+2012 Apr 2.
+
+--- slightly incompatible changes
+
+Patch to load ~/.vim/vimrc when ~/.vimrc isn't found. (Lech Lorens, 2013 Apr
+13)
+
+It's probably a good idea to make a negative value for 'sts' use the value of
+'sw'.  Patch by So8res, Oct 3 2012
+
+When a buffer-local mapping is used, but a global mapping starts with the same
+characters, Vim currently waits for the next typed character to find out if
+the global mapping matches.  It is probably better to let the local mapping
+win and not wait. (discussion with Andy Wokula, 2013 Jan 30)
+Patch by Michael Henry, 2013 Jan 30, update Feb 15.
+
+
+---- Fixes to be included before 7.4 above, less important stuff below ----
+
 Several syntax file match "^\s*" which may get underlined if that's in the
 highlight group.  Add a "\zs" after it?
 
@@ -48,8 +176,6 @@ GTK: problem with 'L' in 'guioptions' ch
 
 Javascript file where indent gets stuck on: GalaxyMaster, 2012 May 3.
 
-Nederlandse vertaling tutor. (Rob Bishoff, 2013 Apr 24)
-
 The CompleteDone autocommand needs some info passed to it:
 - The word that was selected (empty if abandoned complete)
 - Type of completion: tag, omnifunc, user func.
@@ -65,9 +191,6 @@ Win32: When a directory name contains an
 complete the contents of the directory.  No escaping for the "!"? (Jan
 Stocker, 2012 Jan 5)
 
-Patch to load ~/.vim/vimrc when ~/.vimrc isn't found. (Lech Lorens, 2013 Apr
-13)
-
 Problem caused by patch 7.3.638: window->open does not update window
 correctly. Issue 91.
 
@@ -76,90 +199,41 @@ 2013 Mar 19, later message)
 
 Patch to view coverage of the tests. (Nazri Ramliy, 2013 Feb 15)
 
-Patch to make vim.bindeval() in Python work. (Yukihiro Nakadaira, 2013 Mar 25)
-
-Patch to avoid wrong error message for 1.0[0]. (Yasuhiro Matsumoto, 2013 May
-1)
-
 Patch to invert characters differently in GTK. (Yukihiro Nakadaira, 2013 May
 5)
 
-Patch for 'backupcopy' default behavior for symlinks on Windows. (David Pope,
-2012 Mar 21, update Mar 31)
-With fix for memory leak: Ken Takata, 2012 Aug 24
-Another update Sep 24.
-Also patch from Joerg Bornemann, 2013 Apr 30.
-
-Do allow real tags above the !_TAG entries. Undo older patch. Issue 90.
-
 Patch to add the bufferlist() function. (Yegappan Lakshmanan, 2013 May 5)
 
+Patch to allow setting w:quickfix_title via setqflist() and setloclist()
+functions. (Christian Brabandt, 2013 May 8, update May 11)
+
 Patch to support 'u' in interactive substitute. (Christian Brabandt, 2012 Sep
 28)  With tests: Oct 9.
 
+Patch to add getlocstack() / setlocstack(). (Christian Brabandt, 2013 May 14)
+Second one.
+
 Patch to make fold updates much faster. (Christian Brabandt, 2012 Dec)
 
 Patch for IME handling, adds 'imactivatefunc' and 'imstatusfunc' option.
 (Yukihiro Nakadaira, 2012 Aug 16)
 Patch to improve IME handling. (Yasuhiro Matsumoto, 2012 Jul 18)
 
-Undo problem: line not removed as expected when using setline() from Insert
-mode. (Israel Chauca, 2010 May 13, more in second msg)
-Break undo when CTRL-R = changes the text?  Or save more lines?
-Patch by Christian Brabandt, 2012 Nov 16.
-
 Issue 54: document behavior of -complete, also expands arg.
 
-Python patch 7: move more to if_py_boty. (ZyX 2013 Apr 26)
-Python patch 8: add vim.window.number. (ZyX 2013 Apr 26)
-Python patch 9: remove useless calls.. (ZyX 2013 Apr 26)
-Python patch 10: window position. (ZyX 2013 Apr 26)
-Python patch 11: reorder code in if_py_both (ZyX 2013 Apr 28)
-Python patch 12: fix SEGVs (ZyX 2013 Apr 28)
-Python patch 13: negative indices were failing (ZyX 2013 Apr 28)
-Python patch 14: tests for previous fixes (ZyX 2013 Apr 28)
-Python patch 15: make buflist a bufmap (ZyX 2013 Apr 28)  incompatible?
-Python patch 16: fix name of FunctionType (ZyX 2013 Apr 28)
-Python patch 17: add iterators (ZyX 2013 Apr 28)
-Python patch 18: Python 2.2 support (ZyX 2013 Apr 28)
-Python patch 19: drop support for old Pythons (ZyX 2013 Apr 28)
-Python patch 20: tests for vim.buffers (ZyX 2013 Apr 28, second one)
-Python patch 20a: tests for vim.bufferlist (ZyX 2013 May 1)
-Python patch 21: add vim.tabpages and vim.current.tabpage (ZyX 2013 May 1)
-Python patch 22: make KeyErrors use PyErr_SetObject (ZyX 2013 May 1)
-Python patch 23: transform and clean python exceptions (ZyX 2013 May 1)
-Python patch 24: add ability to assign to more vim.current attributes (ZyX
-		2013 May 1)
-Python patch 25: make vim.error Exception subclass (ZyX 2013 May 1)
-Python patch 26: check whether PyObject_IsTrue failed (ZyX 2013 May 1)
-Python patch 27: add tests for various python interfaces (ZyX 2013 May 1)
-
-Matches might be highlighted correctly. Inefficient patch by Christian
-Brabandt, 2013 Feb 26.
-
 -   Add regex for 'paragraphs' and 'sections': 'parare' and 'sectre'.  Combine
     the two into a regex for searching. (Ned Konz)
 Patch by Christian Brabandt, 2013 Apr 20, unfinished.
 
-Patch to use bold/italic fonts when 'guifontewide' is set. (Ken Takata, 2013
-Mar 31)
-
-Patch to fix finding toolbar bitmaps.  Issue 129.
-
-Patch to handle Python SystemExit. (Yasuhiro Matsumoto, 2013 Apr 15)
+Bug: findfile("any", "http://;") returns http://any. (Andrew Pimlott, 2013 May
+7)  Not sure if that can be fixed, but when using "file://" it should be
+possible to check if the file exists.
 
 v:register is not directly reset to " after a delete command that specifies a
 register.  It is reset after the next command. (Steve Vermeulen, 2013 Mar 16)
 
 'ff' is wrong for one-line file without EOL. (Issue 77)
 
-Patch for if_lua. (Luis Carvalho, 2012 Aug 26, update Aug 29, another Aug 30,
-then Sep 1, reminder Oct 14)
-
-Patch to check if 'foldexpr' sets did_emsg. (Christian Brabandt, 2013 Mar 20)
-
-No completion for :xmap and :smap. (Yukihiro Nakadaira, 2013 May 5)
-
 Patch to set antialiasing style on Windows. (Ondrej Balaz, 2013 Mar 14)
 Needs a different check for CLEARTYPE_QUALITY.
 
@@ -172,21 +246,8 @@ a reboot.
 MS-Windows: Crash opening very long file name starting with "\\".
 (Christian Brock, 2012 Jun 29)
 
-It's probably a good idea to make a negative value for 'sts' use the value of
-'sw'.  Patch by So8res, Oct 3 2012
-
-Test 79 fails on Windows only. (Michael Soyka, 2013 Apr 11).
-What makes the test script mapping continue after an error?
-
 patch to add "combine" flag to  syntax commands. (so8res, 2012 Dec 6)
 
-Combining characters are not used when executing a register with :@w.
-(William Fugh, 2013 Apr 5, more info from Ben Fritz)
-Patch by Christian Brabandt, 2013 Apr 6.  Second one.
-
-Bug in completion menu. (Olivier Teuliere, 2013 Feb 15)
-Patch by Christian Brabandt, Feb 16.
-
 Syntax update problem in one buffer opened in two windows, bottom window is
 not correctly updated. (Paul Harris, 2012 Feb 27)
 
@@ -201,7 +262,7 @@ Patch to make confirm() display colors. 
 Patch to add functions for signs. (Christian Brabandt, 2013 Jan 27)
 
 Patch to use directX to draw text on Windows.  Adds the 'renderoptions'
-option.  (Taro Muraoka, 2013 Jan 25, update 2013 Apr 3)
+option.  (Taro Muraoka, 2013 Jan 25, update 2013 Apr 3, May 14)
 
 Problem with refresh:always in completion. (Tyler Wade, 2013 Mar 17)
 
@@ -227,10 +288,6 @@ Szamotulski, 2012 Nov 8)
 Crash in autocmd that unloads buffers in a BufUnload event. (Andrew Pimlott,
 2012 Aug 11)  Disallow :new when BufUnload is being handled?
 
-MS-Windows ACL support doesn't work well.  Patch from Ken Takata, 2012 Aug 29.
-Update Aug 31.
-Another patch for MingW, 2012 Dec 29.
-
 MS-Windows resizing problems:
 - Windows window on screen positioning: Patch by Yukihiro Nakadaira, 2012 Jun
   20.  Uses getWindowRect() instead of GetWindowPlacement()
@@ -240,7 +297,7 @@ MS-Windows resizing problems:
 
 'iminsert' global value set when using ":setlocal iminsert"? (Wu, 2012 Jun 23)
 
-Patch to append regesp to tag commands to make it possible to select one out
+Patch to append regexp to tag commands to make it possible to select one out
 of many matches. (Cody Cutler, 2013 Mar 28)
 
 Help for 'b:undo_indent'. (Thilo Six, 2012 May 28)
@@ -281,18 +338,9 @@ Patch to list user digraphs. (Christian 
 
 Patch for input method status. (Hirohito Higashi, 2012 Apr 18)
 
-Patch to print the result of a :python command. (Maxim Philippov
-<philippovmi@gmail.com>, 2012 Aug 16)  Update Aug 17.
-
 Patch to use .png icons for the toolbar on MS-Windows. (Martin Gieseking, 2013
 Apr 18)
 
-Problem with winfixheight and resizing. (Yukihiro Nakadaira, 2011 Sep 17)
-Patch Sep 18.
-
-Patch for IME problems. Remove hacking code for old IM. (Yukihiro Nakadaira,
-2012 Jul 20)
-
 Patch for has('unnamedplus') docs. (Tony Mechelynck, 2011 Sep 27)
 And one for gui_x11.txt.
 
@@ -325,16 +373,11 @@ Nov 20)
 Patch to improve GUI find/replace dialog. (Christian Brabandt, 2012 May 26)
 Update Jun 2.
 
-Patch to add ":py3do". (Lilydjwg, 2012 Apr 7)
-
 `] moves to character after insert, instead of the last inserted character.
 (Yukihiro Nakadaira, 2011 Dec 9)
 
 Plugin for Modeleasy. (Massimiliano Tripoli, 2011 Nov 29)
 
-Updated syntax file for ssh_config, maintainer doesn't respond.
-(Leonard Ehrenfried, 2011 Sep 26)
-
 BufWinLeave triggers too late when quitting last window in a tab page. (Lech
 Lorens, 2012 Feb 21)
 
@@ -364,15 +407,9 @@ Syntax region with 'concealends' and a '
 only one of the two ends gets the cchar displayed. (Brett Stahlman, 2010 Aug
 21, Ben Fritz, 2010 Sep 14)
 
-'cursorline' is drawn incorrectly in diff mode. Patch by Christian Brabandt,
-2012 Apr 2.
-
 'cursorline' works on a text line only.  Add 'cursorscreenline' for
 highlighting the screen line. (Christian Brabandt, 2012 Mar 31)
 
-Win32: Does building a 64 bit version with VC9 give warnings for int
-conversions? (Mike Williams)
-
 Win32: Patch to use task dialogs when available. (Sergiu Dotenco, 2011 Sep 17)
 New feature, requires testing.  Made some remarks.
 
@@ -452,12 +489,6 @@ string() can't parse back "inf" and "nan
 
 Make 'formatprg' global-local. (Sung Pae)
 
-When a buffer-local mapping is used, but a global mapping starts with the same
-characters, Vim currently waits for the next typed character to find out if
-the global mapping matches.  It is probably better to let the local mapping
-win and not wait. (discussion with Andy Wokula, 2013 Jan 30)
-Patch by Michael Henry, 2013 Jan 30, update Feb 15.
-
 When doing "redir => s:foo" in a script and then "redir END" somewhere else
 (e.g. in a function) it can't find s:foo.
 
@@ -584,9 +615,6 @@ the command line. (Ingo Karkat, 2011 Jan
 Since patch 7.2.46 Yankring plugin has become very slow, eventually make Vim
 crash? (Raiwil, 2010 Nov 17)
 
-Python: Adding line to buffer other than the current one doesn't work
-correctly. (Rozbujnik, 2010 Dec 19)
-
 Patch to add 'systemencoding', convert between 'encoding' and this for file
 names, shell commands and the like.  (Kikuchan, 2010 Oct 14)
 Assume the system converts between the actual encoding of the filesystem to
@@ -946,9 +974,6 @@ shellescape() depends on 'shellshash' fo
 Use a different option or let it depend on whether 'shell' looks like a
 unix-like shell?
 
-Allow patches to add something to version.c, like with an official patch, so
-that :version output shows which patches have been applied.
-
 Bug: in Ex mode (after "Q") backslash before line break, when yanked into a
 register and executed, results in <Nul>: instead of line break.
 (Konrad Schwarz, 2010 Apr 16)
@@ -1163,18 +1188,6 @@ Would be more consistent when an existin
 
 Add ":nofold".  Range will apply without expanding to closed fold.
 
-Including NFA regexp code:
-Use "\%#= to set the engine: 0 = automatic, 1 = backtracking, 2 = new.
-Useful in tests.
-Performance tests:
-- ~/vim/test/veryslow.js (file from Daniel Fetchinson)
-- ~/vim/test/slowsearch
-- ~/vim/test/rgb.vim
-- ~/vim/text/FeiqCfg.xml (file from Netjune)
-- ~/vim/text/edl.svg  (also XML)
-- search for  a.*e*exn  in the vim executable.  Go to last line to use
-  'hlsearch'.
-
 Using Aap to build Vim: add remarks about how to set personal preferences.
 Example on http://www.calmar.ws/tmp/aap.html
 
@@ -1407,9 +1420,6 @@ if_ruby.c.
 
 ":helpgrep" should use the directory from 'helpfile'.
 
-Patch to dynamically load Python on Solaris. (Danek Duvall, 2009 Feb 16)
-Needs more work.
-
 The need_fileinfo flag is messy.  Instead make the message right away and put
 it in keep_msg?
 
@@ -1451,9 +1461,6 @@ When doing ":quit" the Netbeans "killed"
 2008 Nov 10)  call netbeans_file_closed() at the end of buf_freeall(), or in
 all places where buf_freeall() is called?
 
-":python os.chdir('/tmp')" makes short buffer names invalid. (Xavier de Gaye)
-Check directory and call shorten_fnames()?
-
 aucmd_prepbuf() should also use a window in another tab page.
 
 When unloading a buffer in a BufHidden autocommand the hidden flag is reset?
@@ -1489,9 +1496,6 @@ somehow?  Or use a new function.
 
 Mac: Using gvim: netrw window disappears. (Nick Lo, 2006 Jun 21)
 
-Mac: OS/X 10.4 with Python 2.5 installed: configure finds an extra argument
-that breaks the build. (Brian Victor, 2008 Sep 1)
-
 Add an option to specify the character to use when a double-width character is
 moved to the next line.  Default '>', set to a space to blank it out.  Check
 that char is single width when it's set (compare with 'listchars').
@@ -1778,7 +1782,6 @@ More patches:
     more friendly for the Vim distribution.
     New version received 2008 Jan 6.
     No maintenance in two years...
--   Patch to access screen under Python. (Marko Mahni, 2010 Jul 18)
 -   Patch to open dropped files in new tabs. (Michael Trim, 2010 Aug 3)
 
 Awaiting updated patches:
@@ -2357,7 +2360,6 @@ 8   "stl" and "stlnc" in 'fillchars' don
 8   When doing Insert mode completion a mapping cannot recursively call
     edit(), because the completion information is global.  Put everything in
     an allocated structure?
-6   Python: ":py raw_input('prompt')" doesn't work. (Manu Hack)
 8   Command line completion: buffers "foo.txt" and "../b/foo.txt", completing
     ":buf foo<Tab>" doesn't find the second one. (George V. Reilly)
 7   mb_off2cells() doesn't work correctly on the tail byte of a double-byte
@@ -3654,9 +3656,6 @@ 7   Better support for jumping to where 
 Win32 GUI:
 8   Make debug mode work while starting up (vim -D).  Open console window for
     the message and input?
-7   The Python interface only works with one version of Python, selected at
-    compile time.  Can this be made to work with version 2.1 and 2.2
-    dynamically?
 7   GvimExt: when there are several existing Vims, move the list to a submenu.
     (Mike McCollister)
 8   When using "Edit with Vim" for one file it changes directory, when several
@@ -4871,8 +4870,6 @@ 7   Make the debug mode history availabl
 
 
 Various improvements:
-9   Python: be able to define a Python function that can be called directly
-    from Vim script.  Requires converting the arguments and return value.
 7   Add plugins for formatting?  Should be able to make a choice depending on
     the language of a file (English/Korean/Japanese/etc.).
     Setting the 'langformat' option to "chinese" would load the
@@ -4897,7 +4894,6 @@ 7   Add a command that goes back to the 
 7   Allow a window not to have a statusline.  Makes it possible to use a
     window as a buffer-tab selection.
 8   Allow non-active windows to have a different statusline. (Yakov Lerner)
-6   Python interface: add vim.message() function. (Michal Vitecek, 2002 Nov 5)
 7   Support using ":vert" with User commands.  Add expandable items <vert>.
     Do the same for ":browse" and ":confirm"?
     For ":silent" and ":debug" apply to the whole user command.
--- a/runtime/filetype.vim
+++ b/runtime/filetype.vim
@@ -1,7 +1,7 @@
 " Vim support file to detect file types
 "
 " Maintainer:	Bram Moolenaar <Bram@vim.org>
-" Last Change:	2013 Apr 08
+" Last Change:	2013 May 15
 
 " Listen very carefully, I will say this only once
 if exists("did_load_filetypes")
--- a/runtime/ftplugin/sql.vim
+++ b/runtime/ftplugin/sql.vim
@@ -1,8 +1,8 @@
 " SQL filetype plugin file
 " Language:    SQL (Common for Oracle, Microsoft SQL Server, Sybase)
-" Version:     10.0
+" Version:     11.0
 " Maintainer:  David Fishburn <dfishburn dot vim at gmail dot com>
-" Last Change: 2012 Dec 04
+" Last Change: 2013 May 13
 " Download:    http://vim.sourceforge.net/script.php?script_id=454
 
 " For more details please use:
@@ -36,6 +36,10 @@
 "
 " History
 "
+" Version 11.0 (May 2013)
+"
+" NF: Updated to use SyntaxComplete's new regex support for syntax groups.
+"
 " Version 10.0 (Dec 2012)
 "
 " NF: Changed all maps to use noremap instead of must map
@@ -189,7 +193,7 @@ if !exists("*SQL_SetType")
 
         " Remove any cached SQL since a new sytax will have different
         " items and groups
-        if !exists('g:loaded_sql_completion') || 100 == g:loaded_sql_completion
+        if !exists('g:loaded_sql_completion') || g:loaded_sql_completion >= 100
             call sqlcomplete#ResetCacheSyntax()
         endif
 
@@ -458,6 +462,8 @@ if exists('&omnifunc')
     " OMNI function prior to setting up the SQL OMNI function
     let b:sql_compl_savefunc = &omnifunc
 
+    " Source it to determine it's version
+    runtime autoload/sqlcomplete.vim
     " This is used by the sqlcomplete.vim plugin
     " Source it for it's global functions
     runtime autoload/syntaxcomplete.vim
@@ -466,14 +472,20 @@ if exists('&omnifunc')
     " Prevent the intellisense plugin from loading
     let b:sql_vis = 1
     if !exists('g:omni_sql_no_default_maps')
+        let regex_extra = ''
+        if exists('g:loaded_syntax_completion') && exists('g:loaded_sql_completion')
+            if g:loaded_syntax_completion > 120 && g:loaded_sql_completion > 140
+                let regex_extra = '\\w*'
+            endif
+        endif
         " Static maps which use populate the completion list
         " using Vim's syntax highlighting rules
         exec 'inoremap <buffer> '.g:ftplugin_sql_omni_key.'a <C-\><C-O>:call sqlcomplete#Map("syntax")<CR><C-X><C-O>'
-        exec 'inoremap <buffer> '.g:ftplugin_sql_omni_key.'k <C-\><C-O>:call sqlcomplete#Map("sqlKeyword")<CR><C-X><C-O>'
-        exec 'inoremap <buffer> '.g:ftplugin_sql_omni_key.'f <C-\><C-O>:call sqlcomplete#Map("sqlFunction")<CR><C-X><C-O>'
-        exec 'inoremap <buffer> '.g:ftplugin_sql_omni_key.'o <C-\><C-O>:call sqlcomplete#Map("sqlOption")<CR><C-X><C-O>'
-        exec 'inoremap <buffer> '.g:ftplugin_sql_omni_key.'T <C-\><C-O>:call sqlcomplete#Map("sqlType")<CR><C-X><C-O>'
-        exec 'inoremap <buffer> '.g:ftplugin_sql_omni_key.'s <C-\><C-O>:call sqlcomplete#Map("sqlStatement")<CR><C-X><C-O>'
+        exec 'inoremap <buffer> '.g:ftplugin_sql_omni_key.'k <C-\><C-O>:call sqlcomplete#Map("sqlKeyword'.regex_extra.'")<CR><C-X><C-O>'
+        exec 'inoremap <buffer> '.g:ftplugin_sql_omni_key.'f <C-\><C-O>:call sqlcomplete#Map("sqlFunction'.regex_extra.'")<CR><C-X><C-O>'
+        exec 'inoremap <buffer> '.g:ftplugin_sql_omni_key.'o <C-\><C-O>:call sqlcomplete#Map("sqlOption'.regex_extra.'")<CR><C-X><C-O>'
+        exec 'inoremap <buffer> '.g:ftplugin_sql_omni_key.'T <C-\><C-O>:call sqlcomplete#Map("sqlType'.regex_extra.'")<CR><C-X><C-O>'
+        exec 'inoremap <buffer> '.g:ftplugin_sql_omni_key.'s <C-\><C-O>:call sqlcomplete#Map("sqlStatement'.regex_extra.'")<CR><C-X><C-O>'
         " Dynamic maps which use populate the completion list
         " using the dbext.vim plugin
         exec 'inoremap <buffer> '.g:ftplugin_sql_omni_key.'t <C-\><C-O>:call sqlcomplete#Map("table")<CR><C-X><C-O>'
@@ -510,4 +522,3 @@ let &cpo = s:save_cpo
 unlet s:save_cpo
 
 " vim:sw=4:
-
--- a/runtime/indent/erlang.vim
+++ b/runtime/indent/erlang.vim
@@ -1,213 +1,1375 @@
 " Vim indent file
-" Language:     Erlang
+" Language:     Erlang (http://www.erlang.org)
 " Author:       Csaba Hoch <csaba.hoch@gmail.com>
 " Contributors: Edwin Fine <efine145_nospam01 at usa dot net>
 "               Pawel 'kTT' Salata <rockplayer.pl@gmail.com>
 "               Ricardo Catalinas Jiménez <jimenezrick@gmail.com>
+" Last Update:  2013-Mar-05
 " License:      Vim license
-" Version:      2011/09/06
+" URL:          https://github.com/hcs42/vim-erlang
+
+" Note About Usage:
+"   This indentation script works best with the Erlang syntax file created by
+"   Kreąimir Marľić (Kresimir Marzic) and maintained by Csaba Hoch.
+
+" Notes About Implementation:
+"
+" - LTI = Line to indent.
+" - The index of the first line is 1, but the index of the first column is 0.
+
+
+" Initialization {{{1
+" ==============
 
 " Only load this indent file when no other was loaded
-if exists("b:did_indent")
-    finish
+" Vim 7 or later is needed
+if exists("b:did_indent") || version < 700
+  finish
 else
-    let b:did_indent = 1
+  let b:did_indent = 1
 endif
 
 setlocal indentexpr=ErlangIndent()
-setlocal indentkeys+==after,=end,=catch,=),=],=}
+setlocal indentkeys+=0=end,0=of,0=catch,0=after,0=when,0=),0=],0=},0=>>
 
 " Only define the functions once
 if exists("*ErlangIndent")
-    finish
+  finish
 endif
 
-" The function goes through the whole line, analyses it and returns the
-" indentation level.
-"
-" line: the line to be examined
-" return: the indentation level of the examined line
-function s:ErlangIndentAfterLine(line)
-    let linelen = strlen(a:line) " the length of the line
-    let i       = 0 " the index of the current character in the line
-    let ind = 0 " how much should be the difference between the indentation of
-                " the current line and the indentation of the next line?
-                " e.g. +1: the indentation of the next line should be equal to
-                " the indentation of the current line plus one shiftwidth
-    let last_fun      = 0 " the last token was a 'fun'
-    let last_receive  = 0 " the last token was a 'receive'; needed for 'after'
-    let last_hash_sym = 0 " the last token was a '#'
+let s:cpo_save = &cpo
+set cpo&vim
+
+" Logging library {{{1
+" ===============
+
+" Purpose:
+"   Logs the given string using the ErlangIndentLog function if it exists.
+" Parameters:
+"   s: string
+function! s:Log(s)
+  if exists("*ErlangIndentLog")
+    call ErlangIndentLog(a:s)
+  endif
+endfunction
+
+" Line tokenizer library {{{1
+" ======================
+
+" Indtokens are "indentation tokens".
+
+" Purpose:
+"   Calculate the new virtual column after the given segment of a line.
+" Parameters:
+"   line: string
+"   first_index: integer -- the index of the first character of the segment
+"   last_index: integer -- the index of the last character of the segment
+"   vcol: integer -- the virtual column of the first character of the token
+"   tabstop: integer -- the value of the 'tabstop' option to be used
+" Returns:
+"   vcol: integer
+" Example:
+"   " index:    0 12 34567
+"   " vcol:     0 45 89
+"   s:CalcVCol("\t'\tx', b", 1, 4, 4)  -> 10
+function! s:CalcVCol(line, first_index, last_index, vcol, tabstop)
+
+  " We copy the relevent segment of the line, otherwise if the line were
+  " e.g. `"\t", term` then the else branch below would consume the `", term`
+  " part at once.
+  let line = a:line[a:first_index : a:last_index]
+
+  let i = 0
+  let last_index = a:last_index - a:first_index
+  let vcol = a:vcol
+
+  while 0 <= i && i <= last_index
+
+    if line[i] == "\t"
+      " Example (when tabstop == 4):
+      "
+      " vcol + tab -> next_vcol
+      " 0 + tab -> 4
+      " 1 + tab -> 4
+      " 2 + tab -> 4
+      " 3 + tab -> 4
+      " 4 + tab -> 8
+      "
+      " next_i - i == the number of tabs
+      let next_i = matchend(line, '\t*', i + 1)
+      let vcol = (vcol / a:tabstop + (next_i - i)) * a:tabstop
+      call s:Log('new vcol after tab: '. vcol)
+    else
+      let next_i = matchend(line, '[^\t]*', i + 1)
+      let vcol += next_i - i
+      call s:Log('new vcol after other: '. vcol)
+    endif
+    let i = next_i
+  endwhile
+
+  return vcol
+endfunction
+
+" Purpose:
+"   Go through the whole line and return the tokens in the line.
+" Parameters:
+"   line: string -- the line to be examined
+"   string_continuation: bool
+"   atom_continuation: bool
+" Returns:
+"   indtokens = [indtoken]
+"   indtoken = [token, vcol, col]
+"   token = string (examples: 'begin', '<variable>', '}')
+"   vcol = integer (the virtual column of the first character of the token)
+"   col = integer
+function! s:GetTokensFromLine(line, string_continuation, atom_continuation,
+                             \tabstop)
+
+  let linelen = strlen(a:line) " The length of the line
+  let i = 0 " The index of the current character in the line
+  let vcol = 0 " The virtual column of the current character
+  let indtokens = []
 
-    " Ignore comments
-    if a:line =~# '^\s*%'
-        return 0
+  if a:string_continuation
+    let i = matchend(a:line, '^\%([^"\\]\|\\.\)*"', 0)
+    if i == -1
+      call s:Log('    Whole line is string continuation -> ignore')
+      return []
+    else
+      let vcol = s:CalcVCol(a:line, 0, i - 1, 0, a:tabstop)
+      call add(indtokens, ['<string_end>', vcol, i])
+    endif
+  elseif a:atom_continuation
+    let i = matchend(a:line, "^\\%([^'\\\\]\\|\\\\.\\)*'", 0)
+    if i == -1
+      call s:Log('    Whole line is quoted atom continuation -> ignore')
+      return []
+    else
+      let vcol = s:CalcVCol(a:line, 0, i - 1, 0, a:tabstop)
+      call add(indtokens, ['<quoted_atom_end>', vcol, i])
+    endif
+  endif
+
+  while 0 <= i && i < linelen
+
+    let next_vcol = ''
+
+    " Spaces
+    if a:line[i] == ' '
+      let next_i = matchend(a:line, ' *', i + 1)
+
+    " Tabs
+    elseif a:line[i] == "\t"
+      let next_i = matchend(a:line, '\t*', i + 1)
+
+      " See example in s:CalcVCol
+      let next_vcol = (vcol / a:tabstop + (next_i - i)) * a:tabstop
+
+    " Comment
+    elseif a:line[i] == '%'
+      let next_i = linelen
+
+    " String token: "..."
+    elseif a:line[i] == '"'
+      let next_i = matchend(a:line, '\%([^"\\]\|\\.\)*"', i + 1)
+      if next_i == -1
+        call add(indtokens, ['<string_start>', vcol, i])
+      else
+        let next_vcol = s:CalcVCol(a:line, i, next_i - 1, vcol, a:tabstop)
+        call add(indtokens, ['<string>', vcol, i])
+      endif
+
+    " Quoted atom token: '...'
+    elseif a:line[i] == "'"
+      let next_i = matchend(a:line, "\\%([^'\\\\]\\|\\\\.\\)*'", i + 1)
+      if next_i == -1
+        call add(indtokens, ['<quoted_atom_start>', vcol, i])
+      else
+        let next_vcol = s:CalcVCol(a:line, i, next_i - 1, vcol, a:tabstop)
+        call add(indtokens, ['<quoted_atom>', vcol, i])
+      endif
+
+    " Keyword or atom or variable token or number
+    elseif a:line[i] =~# '[a-zA-Z_@0-9]'
+      let next_i = matchend(a:line,
+                           \'[[:alnum:]_@:]*\%(\s*#\s*[[:alnum:]_@:]*\)\=',
+                           \i + 1)
+      call add(indtokens, [a:line[(i):(next_i - 1)], vcol, i])
+
+    " Character token: $<char> (as in: $a)
+    elseif a:line[i] == '$'
+      call add(indtokens, ['$.', vcol, i])
+      let next_i = i + 2
+
+    " Dot token: .
+    elseif a:line[i] == '.'
+
+      let next_i = i + 1
+
+      if i + 1 == linelen || a:line[i + 1] =~# '[[:blank:]%]'
+        " End of clause token: . (as in: f() -> ok.)
+        call add(indtokens, ['<end_of_clause>', vcol, i])
+
+      else
+        " Possibilities:
+        " - Dot token in float: . (as in: 3.14)
+        " - Dot token in record: . (as in: #myrec.myfield)
+        call add(indtokens, ['.', vcol, i])
+      endif
+
+    " Equal sign
+    elseif a:line[i] == '='
+      " This is handled separately so that "=<<" will be parsed as
+      " ['=', '<<'] instead of ['=<', '<']. Although Erlang parses it
+      " currently in the latter way, that may be fixed some day.
+      call add(indtokens, [a:line[i], vcol, i])
+      let next_i = i + 1
+
+    " Three-character tokens
+    elseif i + 1 < linelen &&
+         \ index(['=:=', '=/='], a:line[i : i + 1]) != -1
+      call add(indtokens, [a:line[i : i + 1], vcol, i])
+      let next_i = i + 2
+
+    " Two-character tokens
+    elseif i + 1 < linelen &&
+         \ index(['->', '<<', '>>', '||', '==', '/=', '=<', '>=', '++', '--',
+         \        '::'],
+         \       a:line[i : i + 1]) != -1
+      call add(indtokens, [a:line[i : i + 1], vcol, i])
+      let next_i = i + 2
+
+    " Other character: , ; < > ( ) [ ] { } # + - * / : ? = ! |
+    else
+      call add(indtokens, [a:line[i], vcol, i])
+      let next_i = i + 1
+
     endif
 
-    " Partial function head where the guard is missing
-    if a:line =~# "\\(^\\l[[:alnum:]_]*\\)\\|\\(^'[^']\\+'\\)(" && a:line !~# '->'
-        return 2
-    endif
-
-    " The missing guard from the split function head
-    if a:line =~# '^\s*when\s\+.*->'
-        return -1
+    if next_vcol == ''
+      let vcol += next_i - i
+    else
+      let vcol = next_vcol
     endif
 
-    while 0<=i && i<linelen
-        " m: the next value of the i
-        if a:line[i] == '"'
-            let m = matchend(a:line,'"\%([^"\\]\|\\.\)*"',i)
-            let last_receive = 0
-        elseif a:line[i] == "'"
-            let m = matchend(a:line,"'[^']*'",i)
-            let last_receive = 0
-        elseif a:line[i] =~# "[a-z]"
-            let m = matchend(a:line,".[[:alnum:]_]*",i)
-            if last_fun
-                let ind = ind - 1
-                let last_fun = 0
-                let last_receive = 0
-            elseif a:line[(i):(m-1)] =~# '^\%(case\|if\|try\)$'
-                let ind = ind + 1
-            elseif a:line[(i):(m-1)] =~# '^receive$'
-                let ind = ind + 1
-                let last_receive = 1
-            elseif a:line[(i):(m-1)] =~# '^begin$'
-                let ind = ind + 2
-                let last_receive = 0
-            elseif a:line[(i):(m-1)] =~# '^end$'
-                let ind = ind - 2
-                let last_receive = 0
-            elseif a:line[(i):(m-1)] =~# '^after$'
-                if last_receive == 0
-                    let ind = ind - 1
-                else
-                    let ind = ind + 0
-                endif
-                let last_receive = 0
-            elseif a:line[(i):(m-1)] =~# '^fun$'
-                let ind = ind + 1
-                let last_fun = 1
-                let last_receive = 0
-            endif
-        elseif a:line[i] =~# "[A-Z_]"
-            let m = matchend(a:line,".[[:alnum:]_]*",i)
-            let last_receive = 0
-        elseif a:line[i] == '$'
-            let m = i+2
-            let last_receive = 0
-        elseif a:line[i] == "." && (i+1>=linelen || a:line[i+1]!~ "[0-9]")
-            let m = i+1
-            if last_hash_sym
-                let last_hash_sym = 0
-            else
-                let ind = ind - 1
-            endif
-            let last_receive = 0
-        elseif a:line[i] == '-' && (i+1<linelen && a:line[i+1]=='>')
-            let m = i+2
-            let ind = ind + 1
-            let last_receive = 0
-        elseif a:line[i] == ';' && a:line[(i):(linelen)] !~# '.*->.*'
-            let m = i+1
-            let ind = ind - 1
-            let last_receive = 0
-        elseif a:line[i] == '#'
-            let m = i+1
-            let last_hash_sym = 1
-        elseif a:line[i] =~# '[({[]'
-            let m = i+1
-            let ind = ind + 1
-            let last_fun = 0
-            let last_receive = 0
-            let last_hash_sym = 0
-        elseif a:line[i] =~# '[)}\]]'
-            let m = i+1
-            let ind = ind - 1
-            let last_receive = 0
+    let i = next_i
+
+  endwhile
+
+  return indtokens
+
+endfunction
+
+" TODO: doc, handle "not found" case
+function! s:GetIndtokenAtCol(indtokens, col)
+  let i = 0
+  while i < len(a:indtokens)
+    if a:indtokens[i][2] == a:col
+      return [1, i]
+    elseif a:indtokens[i][2] > a:col
+      return [0, s:IndentError('No token at col ' . a:col . ', ' .
+                              \'indtokens = ' . string(a:indtokens),
+                              \'', '')]
+    endif
+    let i += 1
+  endwhile
+  return [0, s:IndentError('No token at col ' . a:col . ', ' .
+                           \'indtokens = ' . string(a:indtokens),
+                           \'', '')]
+endfunction
+
+" Stack library {{{1
+" =============
+
+" Purpose:
+"   Push a token onto the parser's stack.
+" Parameters:
+"   stack: [token]
+"   token: string
+function! s:Push(stack, token)
+  call s:Log('    Stack Push: "' . a:token . '" into ' . string(a:stack))
+  call insert(a:stack, a:token)
+endfunction
+
+" Purpose:
+"   Pop a token from the parser's stack.
+" Parameters:
+"   stack: [token]
+"   token: string
+" Returns:
+"   token: string -- the removed element
+function! s:Pop(stack)
+  let head = remove(a:stack, 0)
+  call s:Log('    Stack Pop: "' . head . '" from ' . string(a:stack))
+  return head
+endfunction
+
+" Library for accessing and storing tokenized lines {{{1
+" =================================================
+
+" The Erlang token cache: an `lnum -> indtokens` dictionary that stores the
+" tokenized lines.
+let s:all_tokens = {}
+let s:file_name = ''
+let s:last_changedtick = -1
+
+" Purpose:
+"   Clear the Erlang token cache if we have a different file or the file has
+"   been changed since the last indentation.
+function! s:ClearTokenCacheIfNeeded()
+  let file_name = expand('%:p')
+  if file_name != s:file_name ||
+   \ b:changedtick != s:last_changedtick
+    let s:file_name = file_name
+    let s:last_changedtick = b:changedtick
+    let s:all_tokens = {}
+  endif
+endfunction
+
+" Purpose:
+"   Return the tokens of line `lnum`, if that line is not empty. If it is
+"   empty, find the first non-empty line in the given `direction` and return
+"   the tokens of that line.
+" Parameters:
+"   lnum: integer
+"   direction: 'up' | 'down'
+" Returns:
+"   result: [] -- the result is an empty list if we hit the beginning or end
+"                  of the file
+"           | [lnum, indtokens]
+"   lnum: integer -- the index of the non-empty line that was found and
+"                    tokenized
+"   indtokens: [indtoken] -- the tokens of line `lnum`
+function! s:TokenizeLine(lnum, direction)
+
+  call s:Log('Tokenizing starts from line ' . a:lnum)
+  if a:direction == 'up'
+    let lnum = prevnonblank(a:lnum)
+  else " a:direction == 'down'
+    let lnum = nextnonblank(a:lnum)
+  endif
+
+  " We hit the beginning or end of the file
+  if lnum == 0
+    let indtokens = []
+    call s:Log('  We hit the beginning or end of the file.')
+
+    " The line has already been parsed
+  elseif has_key(s:all_tokens, lnum)
+    let indtokens = s:all_tokens[lnum]
+    call s:Log('Cached line ' . lnum . ': ' . getline(lnum))
+    call s:Log("  Tokens in the line:\n    - " . join(indtokens, "\n    - "))
+
+    " The line should be parsed now
+  else
+
+    " Parse the line
+    let line = getline(lnum)
+    let string_continuation = s:IsLineStringContinuation(lnum)
+    let atom_continuation = s:IsLineAtomContinuation(lnum)
+    let indtokens = s:GetTokensFromLine(line, string_continuation,
+                                       \atom_continuation, &tabstop)
+    let s:all_tokens[lnum] = indtokens
+    call s:Log('Tokenizing line ' . lnum . ': ' . line)
+    call s:Log("  Tokens in the line:\n    - " . join(indtokens, "\n    - "))
+
+  endif
+
+  return [lnum, indtokens]
+endfunction
+
+" Purpose:
+"   As a helper function for PrevIndToken and NextIndToken, the FindIndToken
+"   function finds the first line with at least one token in the given
+"   direction.
+" Parameters:
+"   lnum: integer
+"   direction: 'up' | 'down'
+" Returns:
+"   result: [] -- the result is an empty list if we hit the beginning or end
+"                  of the file
+"           | indtoken
+function! s:FindIndToken(lnum, dir)
+  let lnum = a:lnum
+  while 1
+    let lnum += (a:dir == 'up' ? -1 : 1)
+    let [lnum, indtokens] = s:TokenizeLine(lnum, a:dir)
+    if lnum == 0
+      " We hit the beginning or end of the file
+      return []
+    elseif !empty(indtokens)
+      return indtokens[a:dir == 'up' ? -1 : 0]
+    endif
+  endwhile
+endfunction
+
+" Purpose:
+"   Find the token that directly precedes the given token.
+" Parameters:
+"   lnum: integer -- the line of the given token
+"   i: the index of the given token within line `lnum`
+" Returns:
+"   result = [] -- the result is an empty list if the given token is the first
+"                  token of the file
+"          | indtoken
+function! s:PrevIndToken(lnum, i)
+  call s:Log('    PrevIndToken called: lnum=' . a:lnum . ', i =' . a:i)
+
+  " If the current line has a previous token, return that
+  if a:i > 0
+    return s:all_tokens[a:lnum][a:i - 1]
+  else
+    return s:FindIndToken(a:lnum, 'up')
+  endif
+endfunction
+
+" Purpose:
+"   Find the token that directly succeeds the given token.
+" Parameters:
+"   lnum: integer -- the line of the given token
+"   i: the index of the given token within line `lnum`
+" Returns:
+"   result = [] -- the result is an empty list if the given token is the last
+"                  token of the file
+"          | indtoken
+function! s:NextIndToken(lnum, i)
+  call s:Log('    NextIndToken called: lnum=' . a:lnum . ', i =' . a:i)
+
+  " If the current line has a next token, return that
+  if len(s:all_tokens[a:lnum]) > a:i + 1
+    return s:all_tokens[a:lnum][a:i + 1]
+  else
+    return s:FindIndToken(a:lnum, 'down')
+  endif
+endfunction
+
+" ErlangCalcIndent helper functions {{{1
+" =================================
+
+" Purpose:
+"   This function is called when the parser encounters a syntax error.
+"
+"   If we encounter a syntax error, we return
+"   g:erlang_unexpected_token_indent, which is -1 by default. This means that
+"   the indentation of the LTI will not be changed.
+" Parameter:
+"   msg: string
+"   token: string
+"   stack: [token]
+" Returns:
+"   indent: integer
+function! s:IndentError(msg, token, stack)
+  call s:Log('Indent error: ' . a:msg . ' -> return')
+  call s:Log('  Token = ' . a:token . ', ' .
+            \'  stack = ' . string(a:stack))
+  return g:erlang_unexpected_token_indent
+endfunction
+
+" Purpose:
+"   This function is called when the parser encounters an unexpected token,
+"   and the parser will return the number given back by UnexpectedToken.
+"
+"   If we encounter an unexpected token, we return
+"   g:erlang_unexpected_token_indent, which is -1 by default. This means that
+"   the indentation of the LTI will not be changed.
+" Parameter:
+"   token: string
+"   stack: [token]
+" Returns:
+"   indent: integer
+function! s:UnexpectedToken(token, stack)
+  call s:Log('    Unexpected token ' . a:token . ', stack = ' .
+            \string(a:stack) . ' -> return')
+  return g:erlang_unexpected_token_indent
+endfunction
+
+if !exists('g:erlang_unexpected_token_indent')
+  let g:erlang_unexpected_token_indent = -1
+endif
+
+" Purpose:
+"   Return whether the given line starts with a string continuation.
+" Parameter:
+"   lnum: integer
+" Returns:
+"   result: bool
+" Example:
+"   f() ->           % IsLineStringContinuation = false
+"       "This is a   % IsLineStringContinuation = false
+"       multiline    % IsLineStringContinuation = true
+"       string".     % IsLineStringContinuation = true
+function! s:IsLineStringContinuation(lnum)
+  if has('syntax_items')
+    return synIDattr(synID(a:lnum, 1, 0), 'name') =~# '^erlangString'
+  else
+    return 0
+  endif
+endfunction
+
+" Purpose:
+"   Return whether the given line starts with an atom continuation.
+" Parameter:
+"   lnum: integer
+" Returns:
+"   result: bool
+" Example:
+"   'function with   % IsLineAtomContinuation = true, but should be false
+"   weird name'() -> % IsLineAtomContinuation = true
+"       ok.          % IsLineAtomContinuation = false
+function! s:IsLineAtomContinuation(lnum)
+  if has('syntax_items')
+    return synIDattr(synID(a:lnum, 1, 0), 'name') =~# '^erlangQuotedAtom'
+  else
+    return 0
+  endif
+endfunction
+
+" Purpose:
+"   Return whether the 'catch' token (which should be the `i`th token in line
+"   `lnum`) is standalone or part of a try-catch block, based on the preceding
+"   token.
+" Parameters:
+"   lnum: integer
+"   i: integer
+" Return:
+"   is_standalone: bool
+function! s:IsCatchStandalone(lnum, i)
+  call s:Log('    IsCatchStandalone called: lnum=' . a:lnum . ', i=' . a:i)
+  let prev_indtoken = s:PrevIndToken(a:lnum, a:i)
+
+  " If we hit the beginning of the file, it is not a catch in a try block
+  if prev_indtoken == []
+    return 1
+  endif
+
+  let prev_token = prev_indtoken[0]
+
+  if prev_token =~# '[A-Z_@0-9]'
+    let is_standalone = 0
+  elseif prev_token =~# '[a-z]'
+    if index(['after', 'and', 'andalso', 'band', 'begin', 'bnot', 'bor', 'bsl',
+            \ 'bsr', 'bxor', 'case', 'catch', 'div', 'not', 'or', 'orelse',
+            \ 'rem', 'try', 'xor'], prev_token) != -1
+      " If catch is after these keywords, it is standalone
+      let is_standalone = 1
+    else
+      " If catch is after another keyword (e.g. 'end') or an atom, it is
+      " part of try-catch.
+      "
+      " Keywords:
+      " - may precede 'catch': end
+      " - may not precede 'catch': fun if of receive when
+      " - unused: cond let query
+      let is_standalone = 0
+    endif
+  elseif index([')', ']', '}', '<string>', '<string_end>', '<quoted_atom>',
+              \ '<quoted_atom_end>', '$.'], prev_token) != -1
+    let is_standalone = 0
+  else
+    " This 'else' branch includes the following tokens:
+    "   -> == /= =< < >= > =:= =/= + - * / ++ -- :: < > ; ( [ { ? = ! . |
+    let is_standalone = 1
+  endif
+
+  call s:Log('   "catch" preceded by "' . prev_token  . '" -> catch ' .
+            \(is_standalone ? 'is standalone' : 'belongs to try-catch'))
+  return is_standalone
+
+endfunction
+
+" Purpose:
+"   This function is called when a begin-type element ('begin', 'case',
+"   '[', '<<', etc.) is found. It asks the caller to return if the stack
+" Parameters:
+"   stack: [token]
+"   token: string
+"   curr_vcol: integer
+"   stored_vcol: integer
+"   sw: integer -- number of spaces to be used after the begin element as
+"                  indentation
+" Returns:
+"   result: [should_return, indent]
+"   should_return: bool -- if true, the caller should return `indent` to Vim
+"   indent -- integer
+function! s:BeginElementFoundIfEmpty(stack, token, curr_vcol, stored_vcol, sw)
+  if empty(a:stack)
+    if a:stored_vcol == -1
+      call s:Log('    "' . a:token . '" directly preceeds LTI -> return')
+      return [1, a:curr_vcol + a:sw]
+    else
+      call s:Log('    "' . a:token .
+                \'" token (whose expression includes LTI) found -> return')
+      return [1, a:stored_vcol]
+    endif
+  else
+    return [0, 0]
+  endif
+endfunction
+
+" Purpose:
+"   This function is called when a begin-type element ('begin', 'case', '[',
+"   '<<', etc.) is found, and in some cases when 'after' and 'when' is found.
+"   It asks the caller to return if the stack is already empty.
+" Parameters:
+"   stack: [token]
+"   token: string
+"   curr_vcol: integer
+"   stored_vcol: integer
+"   end_token: end token that belongs to the begin element found (e.g. if the
+"              begin element is 'begin', the end token is 'end')
+"   sw: integer -- number of spaces to be used after the begin element as
+"                  indentation
+" Returns:
+"   result: [should_return, indent]
+"   should_return: bool -- if true, the caller should return `indent` to Vim
+"   indent -- integer
+function! s:BeginElementFound(stack, token, curr_vcol, stored_vcol, end_token, sw)
+
+  " Return 'return' if the stack is empty
+  let [ret, res] = s:BeginElementFoundIfEmpty(a:stack, a:token, a:curr_vcol,
+                                             \a:stored_vcol, a:sw)
+  if ret | return [ret, res] | endif
+
+  if a:stack[0] == a:end_token
+    call s:Log('    "' . a:token . '" pops "' . a:end_token . '"')
+    call s:Pop(a:stack)
+    if !empty(a:stack) && a:stack[0] == 'align_to_begin_element'
+      call s:Pop(a:stack)
+      if empty(a:stack)
+        return [1, a:curr_vcol]
+      else
+        return [1, s:UnexpectedToken(a:token, a:stack)]
+      endif
+    else
+      return [0, 0]
+    endif
+  else
+    return [1, s:UnexpectedToken(a:token, a:stack)]
+  endif
+endfunction
+
+" Purpose:
+"   This function is called when we hit the beginning of a file or an
+"   end-of-clause token -- i.e. when we found the beginning of the current
+"   clause.
+"
+"   If the stack contains an '->' or 'when', this means that we can return
+"   now, since we were looking for the beginning of the clause.
+" Parameters:
+"   stack: [token]
+"   token: string
+"   stored_vcol: integer
+" Returns:
+"   result: [should_return, indent]
+"   should_return: bool -- if true, the caller should return `indent` to Vim
+"   indent -- integer
+function! s:BeginningOfClauseFound(stack, token, stored_vcol)
+  if !empty(a:stack) && a:stack[0] == 'when'
+    call s:Log('    BeginningOfClauseFound: "when" found in stack')
+    call s:Pop(a:stack)
+    if empty(a:stack)
+      call s:Log('    Stack is ["when"], so LTI is in a guard -> return')
+      return [1, a:stored_vcol + &sw + 2]
+    else
+      return [1, s:UnexpectedToken(a:token, a:stack)]
+    endif
+  elseif !empty(a:stack) && a:stack[0] == '->'
+    call s:Log('    BeginningOfClauseFound: "->" found in stack')
+    call s:Pop(a:stack)
+    if empty(a:stack)
+      call s:Log('    Stack is ["->"], so LTI is in function body -> return')
+      return [1, a:stored_vcol + &sw]
+    elseif a:stack[0] == ';'
+      call s:Pop(a:stack)
+      if empty(a:stack)
+        call s:Log('    Stack is ["->", ";"], so LTI is in a function head ' .
+                  \'-> return')
+        return [0, a:stored_vcol]
+      else
+        return [1, s:UnexpectedToken(a:token, a:stack)]
+      endif
+    else
+      return [1, s:UnexpectedToken(a:token, a:stack)]
+    endif
+  else
+    return [0, 0]
+  endif
+endfunction
+
+let g:erlang_indent_searchpair_timeout = 2000
+
+" TODO
+function! s:SearchPair(lnum, curr_col, start, middle, end)
+  call cursor(a:lnum, a:curr_col + 1)
+  let [lnum_new, col1_new] = 
+      \searchpairpos(a:start, a:middle, a:end, 'bW',
+                    \'synIDattr(synID(line("."), col("."), 0), "name") ' .
+                    \'=~? "string\\|quotedatom\\|todo\\|comment\\|' . 
+                    \'erlangmodifier"',
+                    \0, g:erlang_indent_searchpair_timeout)
+  return [lnum_new, col1_new - 1]
+endfunction
+
+function! s:SearchEndPair(lnum, curr_col)
+  return s:SearchPair(
+         \ a:lnum, a:curr_col,
+         \ '\<\%(case\|try\|begin\|receive\|if\)\>\|' .
+         \ '\<fun\>\%(\s\|\n\|%.*$\)*(',
+         \ '',
+         \ '\<end\>')
+endfunction
+
+" ErlangCalcIndent {{{1
+" ================
+
+" Purpose:
+"   Calculate the indentation of the given line.
+" Parameters:
+"   lnum: integer -- index of the line for which the indentation should be
+"                    calculated
+"   stack: [token] -- initial stack
+" Return:
+"   indent: integer -- if -1, that means "don't change the indentation";
+"                      otherwise it means "indent the line with `indent`
+"                      number of spaces or equivalent tabs"
+function! s:ErlangCalcIndent(lnum, stack)
+  let res = s:ErlangCalcIndent2(a:lnum, a:stack)
+  call s:Log("ErlangCalcIndent returned: " . res)
+  return res
+endfunction
+
+function! s:ErlangCalcIndent2(lnum, stack)
+
+  let lnum = a:lnum
+  let stored_vcol = -1 " Virtual column of the first character of the token that
+                   " we currently think we might align to.
+  let mode = 'normal'
+  let stack = a:stack
+  let semicolon_abscol = ''
+
+  " Walk through the lines of the buffer backwards (starting from the
+  " previous line) until we can decide how to indent the current line.
+  while 1
+
+    let [lnum, indtokens] = s:TokenizeLine(lnum, 'up')
+
+    " Hit the start of the file
+    if lnum == 0
+      let [ret, res] = s:BeginningOfClauseFound(stack, 'beginning_of_file',
+                                               \stored_vcol)
+      if ret | return res | endif
+
+      return 0
+    endif
+
+    let i = len(indtokens) - 1
+    let last_token_of_line = 1
+
+    while i >= 0
+
+      let [token, curr_vcol, curr_col] = indtokens[i]
+      call s:Log('  Analyzing the following token: ' . string(indtokens[i]))
+
+      if len(stack) > 256 " TODO: magic number
+        return s:IndentError('Stack too long', token, stack)
+      endif
+
+      if token == '<end_of_clause>'
+        let [ret, res] = s:BeginningOfClauseFound(stack, token, stored_vcol)
+        if ret | return res | endif
+
+        if stored_vcol == -1
+          call s:Log('    End of clause directly preceeds LTI -> return')
+          return 0
         else
-            let m = i+1
+          call s:Log('    End of clause (but not end of line) -> return')
+          return stored_vcol
+        endif
+
+      elseif stack == ['prev_term_plus']
+        if token =~# '[a-zA-Z_@]' ||
+         \ token == '<string>' || token == '<string_start>' ||
+         \ token == '<quoted_atom>' || token == '<quoted_atom_start>'
+          call s:Log('    previous token found: curr_vcol + plus = ' .
+                    \curr_vcol . " + " . plus)
+          return curr_vcol + plus
         endif
 
-        let i = m
-    endwhile
+      elseif token == 'begin'
+        let [ret, res] = s:BeginElementFound(stack, token, curr_vcol,
+                                            \stored_vcol, 'end', &sw)
+        if ret | return res | endif
+
+      " case EXPR of BRANCHES end
+      " try EXPR catch BRANCHES end
+      " try EXPR after BODY end
+      " try EXPR catch BRANCHES after BODY end
+      " try EXPR of BRANCHES catch BRANCHES end
+      " try EXPR of BRANCHES after BODY end
+      " try EXPR of BRANCHES catch BRANCHES after BODY end
+      " receive BRANCHES end
+      " receive BRANCHES after BRANCHES end
+
+      " This branch is not Emacs-compatible
+      elseif (index(['of', 'receive', 'after', 'if'], token) != -1 ||
+           \  (token == 'catch' && !s:IsCatchStandalone(lnum, i))) &&
+           \ !last_token_of_line &&
+           \ (empty(stack) || stack == ['when'] || stack == ['->'] ||
+           \  stack == ['->', ';'])
+
+        " If we are after of/receive, but these are not the last
+        " tokens of the line, we want to indent like this:
+        "
+        "   % stack == []
+        "   receive stored_vcol,
+        "           LTI
+        "
+        "   % stack == ['->', ';']
+        "   receive stored_vcol ->
+        "               B;
+        "           LTI
+        "
+        "   % stack == ['->']
+        "   receive stored_vcol ->
+        "               LTI
+        "
+        "   % stack == ['when']
+        "   receive stored_vcol when
+        "               LTI
 
-    return ind
-endfunction
+        " stack = []  =>  LTI is a condition
+        " stack = ['->']  =>  LTI is a branch
+        " stack = ['->', ';']  =>  LTI is a condition
+        " stack = ['when']  =>  LTI is a guard
+        if empty(stack) || stack == ['->', ';']
+          call s:Log('    LTI is in a condition after ' .
+                    \'"of/receive/after/if/catch" -> return')
+          return stored_vcol
+        elseif stack == ['->']
+          call s:Log('    LTI is in a branch after ' .
+                    \'"of/receive/after/if/catch" -> return')
+          return stored_vcol + &sw
+        elseif stack == ['when']
+          call s:Log('    LTI is in a guard after ' .
+                    \'"of/receive/after/if/catch" -> return')
+          return stored_vcol + &sw
+        else
+          return s:UnexpectedToken(token, stack)
+        endif
+
+      elseif index(['case', 'if', 'try', 'receive'], token) != -1
+
+        " stack = []  =>  LTI is a condition
+        " stack = ['->']  =>  LTI is a branch
+        " stack = ['->', ';']  =>  LTI is a condition
+        " stack = ['when']  =>  LTI is in a guard
+        if empty(stack)
+          " pass
+        elseif (token == 'case' && stack[0] == 'of') ||
+             \ (token == 'if') ||
+             \ (token == 'try' && (stack[0] == 'of' ||
+             \                     stack[0] == 'catch' ||
+             \                     stack[0] == 'after')) ||
+             \ (token == 'receive')
+
+          " From the indentation point of view, the keyword
+          " (of/catch/after/end) before the LTI is what counts, so
+          " when we reached these tokens, and the stack already had
+          " a catch/after/end, we didn't modify it.
+          "
+          " This way when we reach case/try/receive (i.e. now),
+          " there is at most one of/catch/after/end token in the
+          " stack.
+          if token == 'case' || token == 'try' ||
+           \ (token == 'receive' && stack[0] == 'after')
+            call s:Pop(stack)
+          endif
 
-function s:FindPrevNonBlankNonComment(lnum)
-    let lnum = prevnonblank(a:lnum)
-    let line = getline(lnum)
-    " Continue to search above if the current line begins with a '%'
-    while line =~# '^\s*%.*$'
-        let lnum = prevnonblank(lnum - 1)
-        if 0 == lnum
-            return 0
+          if empty(stack)
+            call s:Log('    LTI is in a condition; matching ' .
+                      \'"case/if/try/receive" found')
+            let stored_vcol = curr_vcol + &sw
+          elseif stack[0] == 'align_to_begin_element'
+            call s:Pop(stack)
+            let stored_vcol = curr_vcol
+          elseif len(stack) > 1 && stack[0] == '->' && stack[1] == ';'
+            call s:Log('    LTI is in a condition; matching ' .
+                      \'"case/if/try/receive" found')
+            call s:Pop(stack)
+            call s:Pop(stack)
+            let stored_vcol = curr_vcol + &sw
+          elseif stack[0] == '->'
+            call s:Log('    LTI is in a branch; matching ' .
+                      \'"case/if/try/receive" found')
+            call s:Pop(stack)
+            let stored_vcol = curr_vcol + 2 * &sw
+          elseif stack[0] == 'when'
+            call s:Log('    LTI is in a guard; matching ' .
+                      \'"case/if/try/receive" found')
+            call s:Pop(stack)
+            let stored_vcol = curr_vcol + 2 * &sw + 2
+          endif
+
+        endif
+
+        let [ret, res] = s:BeginElementFound(stack, token, curr_vcol,
+                                            \stored_vcol, 'end', &sw)
+        if ret | return res | endif
+
+      elseif token == 'fun'
+        let next_indtoken = s:NextIndToken(lnum, i)
+        call s:Log('    Next indtoken = ' . string(next_indtoken))
+
+        if !empty(next_indtoken) && next_indtoken[0] == '('
+          " We have an anonymous function definition
+          " (e.g. "fun () -> ok end")
+
+          " stack = []  =>  LTI is a condition
+          " stack = ['->']  =>  LTI is a branch
+          " stack = ['->', ';']  =>  LTI is a condition
+          " stack = ['when']  =>  LTI is in a guard
+          if empty(stack)
+            call s:Log('    LTI is in a condition; matching "fun" found')
+            let stored_vcol = curr_vcol + &sw
+          elseif len(stack) > 1 && stack[0] == '->' && stack[1] == ';'
+            call s:Log('    LTI is in a condition; matching "fun" found')
+            call s:Pop(stack)
+            call s:Pop(stack)
+          elseif stack[0] == '->'
+            call s:Log('    LTI is in a branch; matching "fun" found')
+            call s:Pop(stack)
+            let stored_vcol = curr_vcol + 2 * &sw
+          elseif stack[0] == 'when'
+            call s:Log('    LTI is in a guard; matching "fun" found')
+            call s:Pop(stack)
+            let stored_vcol = curr_vcol + 2 * &sw + 2
+          endif
+
+          let [ret, res] = s:BeginElementFound(stack, token, curr_vcol,
+                                              \stored_vcol, 'end', &sw)
+          if ret | return res | endif
+        else
+          " Pass: we have a function reference (e.g. "fun f/0")
+        endif
+
+      elseif token == '['
+        " Emacs compatibility
+        let [ret, res] = s:BeginElementFound(stack, token, curr_vcol,
+                                            \stored_vcol, ']', 1)
+        if ret | return res | endif
+
+      elseif token == '<<'
+        " Emacs compatibility
+        let [ret, res] = s:BeginElementFound(stack, token, curr_vcol,
+                                            \stored_vcol, '>>', 2)
+        if ret | return res | endif
+
+      elseif token == '(' || token == '{'
+
+        let end_token = (token == '(' ? ')' :
+                        \token == '{' ? '}' : 'error')
+
+        if empty(stack)
+          " We found the opening paren whose block contains the LTI.
+          let mode = 'inside'
+        elseif stack[0] == end_token
+          call s:Log('    "' . token . '" pops "' . end_token . '"')
+          call s:Pop(stack)
+
+          if !empty(stack) && stack[0] == 'align_to_begin_element'
+            " We found the opening paren whose closing paren
+            " starts LTI
+            let mode = 'align_to_begin_element'
+          else
+            " We found the opening pair for a closing paren that
+            " was already in the stack.
+            let mode = 'outside'
+          endif
+        else
+          return s:UnexpectedToken(token, stack)
         endif
-        let line = getline(lnum)
-    endwhile
-    return lnum
-endfunction
+
+        if mode == 'inside' || mode == 'align_to_begin_element'
+
+          if last_token_of_line && i != 0
+            " Examples: {{{
+            "
+            " mode == 'inside':
+            "
+            "     my_func(
+            "       LTI
+            "
+            "     [Variable, {
+            "        LTI
+            "
+            " mode == 'align_to_begin_element':
+            "
+            "     my_func(
+            "       Params
+            "      ) % LTI
+            "
+            "     [Variable, {
+            "        Terms
+            "       } % LTI
+            " }}}
+            let stack = ['prev_term_plus']
+            let plus = (mode == 'inside' ? 2 : 1)
+            call s:Log('    "' . token .
+                      \'" token found at end of line -> find previous token')
+          elseif mode == 'align_to_begin_element'
+            " Examples: {{{
+            "
+            " mode == 'align_to_begin_element' && !last_token_of_line
+            "
+            "     my_func(stored_vcol
+            "            ) % LTI
+            "
+            "     [Variable, {stored_vcol
+            "                } % LTI
+            "
+            " mode == 'align_to_begin_element' && i == 0
+            "
+            "     (
+            "       stored_vcol
+            "     ) % LTI
+            "
+            "     {
+            "       stored_vcol
+            "     } % LTI
+            " }}}
+            call s:Log('    "' . token . '" token (whose closing token ' .
+                      \'starts LTI) found -> return')
+            return curr_vcol
+          elseif stored_vcol == -1
+            " Examples: {{{
+            "
+            " mode == 'inside' && stored_vcol == -1 && !last_token_of_line
+            "
+            "     my_func(
+            "             LTI
+            "     [Variable, {
+            "                 LTI
+            "
+            " mode == 'inside' && stored_vcol == -1 && i == 0
+            "
+            "     (
+            "      LTI
+            "
+            "     {
+            "      LTI
+            " }}}
+            call s:Log('    "' . token .
+                      \'" token (which directly precedes LTI) found -> return')
+            return curr_vcol + 1
+          else
+            " Examples: {{{
+            "
+            " mode == 'inside' && stored_vcol != -1 && !last_token_of_line
+            "
+            "     my_func(stored_vcol,
+            "             LTI
+            "
+            "     [Variable, {stored_vcol,
+            "                 LTI
+            "
+            " mode == 'inside' && stored_vcol != -1 && i == 0
+            "
+            "     (stored_vcol,
+            "      LTI
+            "
+            "     {stored_vcol,
+            "      LTI
+            " }}}
+            call s:Log('    "' . token .
+                      \'" token (whose block contains LTI) found -> return')
+            return stored_vcol
+          endif
+        endif
+
+      elseif token == 'end'
+        let [lnum_new, col_new] = s:SearchEndPair(lnum, curr_col)
+
+        if lnum_new == 0
+          return s:IndentError('Matching token for "end" not found',
+                              \token, stack)
+        else
+          if lnum_new != lnum
+            call s:Log('    Tokenize for "end" <<<<')
+            let [lnum, indtokens] = s:TokenizeLine(lnum_new, 'up')
+            call s:Log('    >>>> Tokenize for "end"')
+          endif
+
+          let [success, i] = s:GetIndtokenAtCol(indtokens, col_new)
+          if !success | return i | endif
+          let [token, curr_vcol, curr_col] = indtokens[i]
+          call s:Log('    Match for "end" in line ' . lnum_new . ': ' .
+                    \string(indtokens[i]))
+        endif
+
+      elseif index([')', ']', '}'], token) != -1
+
+        call s:Push(stack, token)
+
+        " We have to escape '[', because this string will be interpreted as a
+        " regexp
+        let open_paren = (token == ')' ? '(' :
+                         \token == ']' ? '\[' :
+                         \               '{')
+
+        let [lnum_new, col_new] = s:SearchPair(lnum, curr_col,
+                                              \open_paren, '', token)
+
+        if lnum_new == 0
+          return s:IndentError('Matching token not found',
+                              \token, stack)
+        else
+          if lnum_new != lnum
+            call s:Log('    Tokenize the opening paren <<<<')
+            let [lnum, indtokens] = s:TokenizeLine(lnum_new, 'up')
+            call s:Log('    >>>>')
+          endif
+
+          let [success, i] = s:GetIndtokenAtCol(indtokens, col_new)
+          if !success | return i | endif
+          let [token, curr_vcol, curr_col] = indtokens[i]
+          call s:Log('    Match in line ' . lnum_new . ': ' .
+                    \string(indtokens[i]))
+
+          " Go back to the beginning of the loop and handle the opening paren
+          continue
+        endif
 
-" The function returns the indentation level of the line adjusted to a mutiple
-" of 'shiftwidth' option.
-"
-" lnum: line number
-" return: the indentation level of the line
-function s:GetLineIndent(lnum)
-    return (indent(a:lnum) / &sw) * &sw
-endfunction
+      elseif token == '>>'
+        call s:Push(stack, token)
+
+      elseif token == ';'
+
+        if empty(stack)
+          call s:Push(stack, ';')
+        elseif index([';', '->', 'when', 'end', 'after', 'catch'],
+                    \stack[0]) != -1
+          " Pass:
+          "
+          " - If the stack top is another ';', then one ';' is
+          "   enough.
+          " - If the stack top is an '->' or a 'when', then we
+          "   should keep that, because they signify the type of the
+          "   LTI (branch, condition or guard).
+          " - From the indentation point of view, the keyword
+          "   (of/catch/after/end) before the LTI is what counts, so
+          "   if the stack already has a catch/after/end, we don't
+          "   modify it. This way when we reach case/try/receive,
+          "   there will be at most one of/catch/after/end token in
+          "   the stack.
+        else
+          return s:UnexpectedToken(token, stack)
+        endif
+
+      elseif token == '->'
+
+        if empty(stack) && !last_token_of_line
+          call s:Log('    LTI is in expression after arrow -> return')
+          return stored_vcol
+        elseif empty(stack) || stack[0] == ';' || stack[0] == 'end'
+          " stack = [';']  -> LTI is either a branch or in a guard
+          " stack = ['->']  ->  LTI is a condition
+          " stack = ['->', ';']  -> LTI is a branch
+          call s:Push(stack, '->')
+        elseif index(['->', 'when', 'end', 'after', 'catch'], stack[0]) != -1
+          " Pass:
+          "
+          " - If the stack top is another '->', then one '->' is
+          "   enough.
+          " - If the stack top is a 'when', then we should keep
+          "   that, because this signifies that LTI is a in a guard.
+          " - From the indentation point of view, the keyword
+          "   (of/catch/after/end) before the LTI is what counts, so
+          "   if the stack already has a catch/after/end, we don't
+          "   modify it. This way when we reach case/try/receive,
+          "   there will be at most one of/catch/after/end token in
+          "   the stack.
+        else
+          return s:UnexpectedToken(token, stack)
+        endif
+
+      elseif token == 'when'
+
+        " Pop all ';' from the top of the stack
+        while !empty(stack) && stack[0] == ';'
+          call s:Pop(stack)
+        endwhile
 
-function ErlangIndent()
-    " Find a non-blank line above the current line
-    let lnum = prevnonblank(v:lnum - 1)
+        if empty(stack)
+          if semicolon_abscol != ''
+            let stored_vcol = semicolon_abscol
+          endif
+          if !last_token_of_line
+            " Example:
+            "   when A,
+            "        LTI
+            let [ret, res] = s:BeginElementFoundIfEmpty(stack, token, curr_vcol,
+                                                       \stored_vcol, &sw)
+            if ret | return res | endif
+          else
+            " Example:
+            "   when
+            "       LTI
+            call s:Push(stack, token)
+          endif
+        elseif index(['->', 'when', 'end', 'after', 'catch'], stack[0]) != -1
+          " Pass:
+          " - If the stack top is another 'when', then one 'when' is
+          "   enough.
+          " - If the stack top is an '->' or a 'when', then we
+          "   should keep that, because they signify the type of the
+          "   LTI (branch, condition or guard).
+          " - From the indentation point of view, the keyword
+          "   (of/catch/after/end) before the LTI is what counts, so
+          "   if the stack already has a catch/after/end, we don't
+          "   modify it. This way when we reach case/try/receive,
+          "   there will be at most one of/catch/after/end token in
+          "   the stack.
+        else
+          return s:UnexpectedToken(token, stack)
+        endif
+
+      elseif token == 'of' || token == 'after' ||
+           \ (token == 'catch' && !s:IsCatchStandalone(lnum, i))
+
+        if token == 'after'
+          " If LTI is between an 'after' and the corresponding
+          " 'end', then let's return
+          let [ret, res] = s:BeginElementFoundIfEmpty(stack, token, curr_vcol,
+                                                     \stored_vcol, &sw)
+          if ret | return res | endif
+        endif
 
-    " Hit the start of the file, use zero indent
-    if lnum == 0
-        return 0
+        if empty(stack) || stack[0] == '->' || stack[0] == 'when'
+          call s:Push(stack, token)
+        elseif stack[0] == 'catch' || stack[0] == 'after' || stack[0] == 'end'
+          " Pass: From the indentation point of view, the keyword
+          " (of/catch/after/end) before the LTI is what counts, so
+          " if the stack already has a catch/after/end, we don't
+          " modify it. This way when we reach case/try/receive,
+          " there will be at most one of/catch/after/end token in
+          " the stack.
+        else
+          return s:UnexpectedToken(token, stack)
+        endif
+
+      elseif token == '||' && empty(stack) && !last_token_of_line
+
+        call s:Log('    LTI is in expression after "||" -> return')
+        return stored_vcol
+
+      else
+        call s:Log('    Misc token, stack unchanged = ' . string(stack))
+
+      endif
+
+      if empty(stack) || stack[0] == '->' || stack[0] == 'when'
+        let stored_vcol = curr_vcol
+        let semicolon_abscol = ''
+        call s:Log('    Misc token when the stack is empty or has "->" ' .
+                  \'-> setting stored_vcol to ' . stored_vcol)
+      elseif stack[0] == ';'
+        let semicolon_abscol = curr_vcol
+        call s:Log('    Setting semicolon-stored_vcol to ' . stored_vcol)
+      endif
+
+      let i -= 1
+      call s:Log('    Token processed. stored_vcol=' . stored_vcol)
+
+      let last_token_of_line = 0
+
+    endwhile " iteration on tokens in a line
+
+    call s:Log('  Line analyzed. stored_vcol=' . stored_vcol)
+
+    if empty(stack) && stored_vcol != -1 &&
+     \ (!empty(indtokens) && indtokens[0][0] != '<string_end>' &&
+     \                       indtokens[0][0] != '<quoted_atom_end>')
+      call s:Log('    Empty stack at the beginning of the line -> return')
+      return stored_vcol
     endif
 
-    let prevline = getline(lnum)
-    let currline = getline(v:lnum)
+    let lnum -= 1
+
+  endwhile " iteration on lines
+
+endfunction
+
+" ErlangIndent function {{{1
+" =====================
+
+function! ErlangIndent()
+
+  call s:ClearTokenCacheIfNeeded()
+
+  let currline = getline(v:lnum)
+  call s:Log('Indenting line ' . v:lnum . ': ' . currline)
+
+  if s:IsLineStringContinuation(v:lnum) || s:IsLineAtomContinuation(v:lnum)
+    call s:Log('String or atom continuation found -> ' .
+              \'leaving indentation unchanged')
+    return -1
+  endif
+
+  let ml = matchlist(currline,
+                    \'^\(\s*\)\(\%(end\|of\|catch\|after\)\>\|[)\]}]\|>>\)')
 
-    let ind_after = s:ErlangIndentAfterLine(prevline)
-    if ind_after != 0
-        let ind = s:GetLineIndent(lnum) + ind_after * &sw
+  " If the line has a special beginning, but not a standalone catch
+  if !empty(ml) && !(ml[2] == 'catch' && s:IsCatchStandalone(v:lnum, 0))
+
+    let curr_col = len(ml[1])
+
+    if ml[2] == 'end'
+      let [lnum, col] = s:SearchEndPair(v:lnum, curr_col)
+
+      if lnum == 0
+        return s:IndentError('Matching token for "end" not found',
+                            \'end', [])
+      else
+        call s:Log('    Tokenize for "end" <<<<')
+        let [lnum, indtokens] = s:TokenizeLine(lnum, 'up')
+        call s:Log('    >>>> Tokenize for "end"')
+
+        let [success, i] = s:GetIndtokenAtCol(indtokens, col)
+        if !success | return i | endif
+        let [token, curr_vcol, curr_col] = indtokens[i]
+        call s:Log('    Match for "end" in line ' . lnum . ': ' .
+                   \string(indtokens[i]))
+        return curr_vcol
+      endif
+
     else
-        let ind = indent(lnum) + ind_after * &sw
-    endif
 
-    " Special cases:
-    if prevline =~# '^\s*\%(after\|end\)\>'
-        let ind = ind + 2*&sw
-    endif
-    if currline =~# '^\s*end\>'
-        let ind = ind - 2*&sw
+      call s:Log("  Line type = 'end'")
+      let new_col = s:ErlangCalcIndent(v:lnum - 1,
+                                      \[ml[2], 'align_to_begin_element'])
     endif
-    if currline =~# '^\s*after\>'
-        let plnum = s:FindPrevNonBlankNonComment(v:lnum-1)
-        if getline(plnum) =~# '^[^%]*\<receive\>\s*\%(%.*\)\=$'
-            " If the 'receive' is not in the same line as the 'after'
-            let ind = ind - 1*&sw
-        else
-            let ind = ind - 2*&sw
-        endif
-    endif
-    if prevline =~# '^\s*[)}\]]'
-        let ind = ind + 1*&sw
+  else
+    call s:Log("  Line type = 'normal'")
+
+    let new_col = s:ErlangCalcIndent(v:lnum - 1, [])
+    if currline =~# '^\s*when\>'
+      let new_col += 2
     endif
-    if currline =~# '^\s*[)}\]]'
-        let ind = ind - 1*&sw
-    endif
-    if prevline =~# '^\s*\%(catch\)\s*\%(%\|$\)'
-        let ind = ind + 1*&sw
-    endif
-    if currline =~# '^\s*\%(catch\)\s*\%(%\|$\)'
-        let ind = ind - 1*&sw
-    endif
+  endif
+
+  if new_col < -1
+    call s:Log('WARNING: returning new_col == ' . new_col)
+    return g:erlang_unexpected_token_indent
+  endif
+
+  return new_col
 
-    if ind<0
-        let ind = 0
-    endif
-    return ind
 endfunction
+
+" Cleanup {{{1
+" =======
+
+let &cpo = s:cpo_save
+unlet s:cpo_save
+
+" vim: sw=2 et fdm=marker
--- a/runtime/indent/tex.vim
+++ b/runtime/indent/tex.vim
@@ -1,6 +1,6 @@
 " Vim indent file
 " Language:     LaTeX
-" Maintainer:   Zhou YiChao <broken.zhou AT gmail.com>
+" Maintainer:   YiChao Zhou <broken.zhou AT gmail.com>
 " Created:      Sat, 16 Feb 2002 16:50:19 +0100
 " Last Change:	2012 Mar 18 19:19:50
 " Version: 0.7
@@ -46,6 +46,9 @@
 "               (*) Modify indentkeys.
 "               2012/03/18 by Zhou Yichao <broken.zhou AT gmail.com>
 "               (*) Add &cpo
+"               2013/05/02 by Zhou Yichao <broken.zhou AT gmail.com>
+"               (*) Fix problem about GetTeXIndent checker. Thank Albert Netymk
+"                   for reporting this.
 " }}}
 
 " Document: {{{
@@ -106,10 +109,6 @@
 " }}} 
 
 " Only define the function once
-if exists("*GetTeXIndent")
-    finish
-endif
-
 if exists("b:did_indent")
     finish
 endif
@@ -158,7 +157,7 @@ exec 'setlocal indentkeys+=[,(,{,),},],\
 let g:tex_items = '^\s*' . substitute(g:tex_items, '^\(\^\\s\*\)*', '', '')
 " }}}
 
-function GetTeXIndent() " {{{
+function! GetTeXIndent() " {{{
     " Find a non-blank line above the current line.
     let lnum = prevnonblank(v:lnum - 1)
 
--- a/runtime/menu.vim
+++ b/runtime/menu.vim
@@ -2,7 +2,7 @@
 " You can also use this as a start for your own set of menus.
 "
 " Maintainer:	Bram Moolenaar <Bram@vim.org>
-" Last Change:	2012 Dec 06
+" Last Change:	2013 May 17
 
 " Note that ":an" (short for ":anoremenu") is often used to make a menu work
 " in all modes and avoid side effects from mappings defined by the user.
@@ -308,8 +308,10 @@ fun! s:TextWidth()
   endif
   let n = inputdialog(g:menutrans_textwidth_dialog, &tw)
   if n != ""
-    " remove leading zeros to avoid it being used as an octal number
-    let &tw = substitute(n, "^0*", "", "")
+    " Remove leading zeros to avoid it being used as an octal number.
+    " But keep a zero by itself.
+    let tw = substitute(n, "^0*", "", "")
+    let &tw = tw == '' ? 0 : tw 
   endif
 endfun
 
--- a/runtime/plugin/matchparen.vim
+++ b/runtime/plugin/matchparen.vim
@@ -1,6 +1,6 @@
 " Vim plugin for showing matching parens
 " Maintainer:  Bram Moolenaar <Bram@vim.org>
-" Last Change: 2013 Mar 19
+" Last Change: 2013 May 08
 
 " Exit quickly when:
 " - this plugin was already loaded (or disabled)
@@ -11,6 +11,13 @@ if exists("g:loaded_matchparen") || &cp 
 endif
 let g:loaded_matchparen = 1
 
+if !exists("g:matchparen_timeout")
+  let g:matchparen_timeout = 300
+endif
+if !exists("g:matchparen_insert_timeout")
+  let g:matchparen_insert_timeout = 60
+endif
+
 augroup matchparen
   " Replace all matchparen autocommands
   autocmd! CursorMoved,CursorMovedI,WinEnter * call s:Highlight_Matching_Pair()
@@ -99,10 +106,15 @@ function! s:Highlight_Matching_Pair()
     let stopline = stoplinetop
   endif
 
+  " Limit the search time to 300 msec to avoid a hang on very long lines.
+  " This fails when a timeout is not supported.
+  if mode() == 'i' || mode() == 'R'
+    let timeout = exists("b:matchparen_insert_timeout") ? b:matchparen_insert_timeout : g:matchparen_insert_timeout
+  else
+    let timeout = exists("b:matchparen_timeout") ? b:matchparen_timeout : g:matchparen_timeout
+  endif
   try
-    " Limit the search time to 300 msec to avoid a hang on very long lines.
-    " This fails when a timeout is not supported.
-    let [m_lnum, m_col] = searchpairpos(c, '', c2, s_flags, s_skip, stopline, 300)
+    let [m_lnum, m_col] = searchpairpos(c, '', c2, s_flags, s_skip, stopline, timeout)
   catch /E118/
     " Can't use the timeout, restrict the stopline a bit more to avoid taking
     " a long time on closed folds and long lines.
--- a/runtime/syntax/debchangelog.vim
+++ b/runtime/syntax/debchangelog.vim
@@ -3,7 +3,7 @@
 " Maintainer:  Debian Vim Maintainers <pkg-vim-maintainers@lists.alioth.debian.org>
 " Former Maintainers: Gerfried Fuchs <alfie@ist.org>
 "                     Wichert Akkerman <wakkerma@debian.org>
-" Last Change: 2013 Jan 03
+" Last Change: 2013 May 05
 " URL: http://anonscm.debian.org/hg/pkg-vim/vim/raw-file/unstable/runtime/syntax/debchangelog.vim
 
 " Standard syntax initialization
@@ -19,7 +19,7 @@ syn case ignore
 " Define some common expressions we can use later on
 syn match debchangelogName	contained "^[[:alnum:]][[:alnum:].+-]\+ "
 syn match debchangelogUrgency	contained "; urgency=\(low\|medium\|high\|critical\|emergency\)\( \S.*\)\="
-syn match debchangelogTarget	contained "\v %(frozen|unstable|%(testing|%(old)=stable)%(-proposed-updates|-security)=|experimental|%(squeeze)-%(backports%(-sloppy)=|volatile)|%(hardy|lucid|oneiric|precise|quantal|raring)%(-%(security|proposed|updates|backports|commercial|partner))=)+"
+syn match debchangelogTarget	contained "\v %(frozen|unstable|%(testing|%(old)=stable)%(-proposed-updates|-security)=|experimental|squeeze-%(backports%(-sloppy)=|volatile)|wheezy-backports|%(lucid|precise|quantal|raring|saucy)%(-%(security|proposed|updates|backports|commercial|partner))=)+"
 syn match debchangelogVersion	contained "(.\{-})"
 syn match debchangelogCloses	contained "closes:\_s*\(bug\)\=#\=\_s\=\d\+\(,\_s*\(bug\)\=#\=\_s\=\d\+\)*"
 syn match debchangelogLP	contained "\clp:\s\+#\d\+\(,\s*#\d\+\)*"
--- a/runtime/syntax/debsources.vim
+++ b/runtime/syntax/debsources.vim
@@ -2,7 +2,7 @@
 " Language:     Debian sources.list
 " Maintainer:   Debian Vim Maintainers <pkg-vim-maintainers@lists.alioth.debian.org>
 " Former Maintainer: Matthijs Mohlmann <matthijs@cacholong.nl>
-" Last Change: 2013 Jan 03
+" Last Change: 2013 May 05
 " URL: http://anonscm.debian.org/hg/pkg-vim/vim/raw-file/unstable/runtime/syntax/debsources.vim
 
 " Standard syntax initialization
@@ -23,7 +23,7 @@ syn match debsourcesComment        /#.*/
 
 " Match uri's
 syn match debsourcesUri            +\(http://\|ftp://\|[rs]sh://\|debtorrent://\|\(cdrom\|copy\|file\):\)[^' 	<>"]\++
-syn match debsourcesDistrKeyword   +\([[:alnum:]_./]*\)\(squeeze\|wheezy\|\(old\)\=stable\|testing\|unstable\|sid\|rc-buggy\|experimental\|hardy\|lucid\|oneiric\|precise\|quantal\|raring\)\([-[:alnum:]_./]*\)+
+syn match debsourcesDistrKeyword   +\([[:alnum:]_./]*\)\(squeeze\|wheezy\|\(old\)\=stable\|testing\|unstable\|sid\|rc-buggy\|experimental\|lucid\|precise\|quantal\|raring\|saucy\)\([-[:alnum:]_./]*\)+
 
 " Associate our matches and regions with pretty colours
 hi def link debsourcesLine            Error
--- a/runtime/syntax/erlang.vim
+++ b/runtime/syntax/erlang.vim
@@ -1,126 +1,175 @@
 " Vim syntax file
-" Language:     Erlang
-" Author:       Oscar Hellstrm <oscar@oscarh.net> (http://oscar.hellstrom.st)
-" Contributors: Ricardo Catalinas Jimnez <jimenezrick@gmail.com>
+" Language:     Erlang (http://www.erlang.org)
+" Maintainer:   Csaba Hoch <csaba.hoch@gmail.com>
+" Former Maintainer:  Kreąimir Marľić (Kresimir Marzic) <kmarzic@fly.srk.fer.hr>
+" Last Update:  2013-Mar-07
 " License:      Vim license
-" Version:      2011/09/11
+" URL:          https://github.com/hcs42/vim-erlang
 
-if exists("b:current_syntax")
-	finish
-else
-	let b:current_syntax = "erlang"
+" Customization:
+"
+" There are two optional sets of highlighting:
+"
+" 1. The BIFs (built-in functions) are highlighted by default. To disable
+"    this, put the following line in your vimrc:
+"
+"      let g:erlang_highlight_bifs = 0
+"
+" 2. To enable highlighting some special atoms, put this in your vimrc:
+"
+"      let g:erlang_highlight_special_atoms = 1
+
+" For version 5.x: Clear all syntax items
+" For version 6.x: Quit when a syntax file was already loaded
+if version < 600
+    syntax clear
+elseif exists("b:current_syntax")
+    finish
 endif
 
-if !exists("g:erlang_highlight_bif")
-	let g:erlang_highlight_bif = 1
-endif
-
-" Erlang is case sensitive
+" Case sensitive
 syn case match
 
-" Match groups
-syn match erlangStringModifier               /\\./ contained
-syn match erlangStringModifier               /\~\%(-\?[0-9*]\+\)\?\%(\.[0-9*]\+\..\?\)\?\%(c\|f\|e\|g\|s\|w\|p\|W\|P\|B\|X\|#\|b\|+\|n\|i\)/ contained
-syn match erlangModifier                     /\$\\\?./
+if version >= 600
+  setlocal iskeyword+=$,@-@
+endif
 
-syn match erlangInteger                      /\<\%([0-9]\+#[0-9a-fA-F]\+\|[0-9]\+\)\>/
-syn match erlangFloat                        /\<[0-9]\+\.[0-9]\+\%(e-\?[0-9]\+\)\?\>/
+" Comments
+syn match erlangComment             '%.*$' contains=erlangCommentAnnotation,erlangTodo
+syn match erlangCommentAnnotation   ' \@<=@\%(clear\|docfile\|end\|headerfile\|todo\|TODO\|type\|author\|copyright\|doc\|reference\|see\|since\|title\|version\|deprecated\|hidden\|private\|equiv\|spec\|throws\)' contained
+syn match erlangCommentAnnotation   /`[^']*'/ contained
+syn keyword erlangTodo              TODO FIXME XXX contained
+
+" Numbers (minimum base is 2, maximum is 36.)
+syn match   erlangNumberInteger     '\<\d\+\>'
+syn match   erlangNumberInteger     '\<\%([2-9]\|[12]\d\|3[0-6]\)\+#[[:alnum:]]\+\>'
+syn match   erlangNumberFloat       '\<\d\+\.\d\+\%([eE][+-]\=\d\+\)\=\>'
 
-syn keyword erlangTodo                       TODO FIXME XXX contained
-syn match   erlangComment                    /%.*$/ contains=@Spell,erlangTodo,erlangAnnotation
-syn match   erlangAnnotation                 /\%(%\s\)\@<=@\%(author\|clear\|copyright\|deprecated\|doc\|docfile\|end\|equiv\|headerfile\|hidden\|private\|reference\|see\|since\|spec\|throws\|title\|todo\|TODO\|type\|version\)/ contained
-syn match   erlangAnnotation                 /`[^']\+'/ contained
-
-syn keyword erlangKeyword                    band bor bnot bsl bsr bxor div rem xor
-syn keyword erlangKeyword                    try catch begin receive after cond fun let query
+" Strings, atoms, characters
+syn region  erlangString            start=/"/ end=/"/ contains=erlangStringModifier
+syn region  erlangQuotedAtom        start=/'/ end=/'/ contains=erlangQuotedAtomModifier
+syn match   erlangStringModifier     '\~\a\|\\\%(\o\{1,3}\|x\x\x\|x{\x\+}\|\^.\|.\)' contained
+syn match   erlangQuotedAtomModifier '\~\a\|\\\%(\o\{1,3}\|x\x\x\|x{\x\+}\|\^.\|.\)' contained
+syn match   erlangModifier           '\$\%([^\\]\|\\\%(\o\{1,3}\|x\x\x\|x{\x\+}\|\^.\|.\)\)'
 
-syn keyword erlangConditional                case if of end
-syn keyword erlangConditional                not and or andalso orelse
-syn keyword erlangConditional                when
+" Operators
+syn match   erlangOperator          '==\|=:=\|/=\|=/=\|<\|=<\|>\|>=\|++\|--\|=\|!\|<-\|+\|-\|\*\|\/'
+syn keyword erlangOperator          div rem or xor bor bxor bsl bsr and band not bnot andalso orelse
 
-syn keyword erlangBoolean                    true false
-
-syn keyword erlangGuard                      is_list is_alive is_atom is_binary is_bitstring is_boolean is_tuple is_number is_integer is_float is_function is_constant is_pid is_port is_reference is_record is_process_alive
+" Separators
+syn match erlangSeparator           '(\|)\|{\|}\|\[\|]\||\|||\|;\|,\|?\|#'
+syn match erlangRightArrow          '->'
 
-syn match erlangOperator                     /\/\|*\|+\|-\|++\|--/
-syn match erlangOperator                     /->\|<-\|||\||\|!\|=/
-syn match erlangOperator                     /=:=\|==\|\/=\|=\/=\|<\|>\|=<\|>=/
-syn keyword erlangOperator                   div rem
+" Functions call
+syn match   erlangFCall             '\<\%(\a[[:alnum:]@]*\s*\.\s*\)*\a[[:alnum:]@]*\s*:\s*\a[[:alnum:]@]*\>'
+
+" Constants and Directives
+syn match   erlangDirective         '-\%(behaviour\|behavior\|compile\|define\|else\|endif\|export\|file\|ifdef\|ifndef\|import\|include_lib\|include\|module\|record\|undef\|author\|copyright\|doc\|vsn\|on_load\|export_type\)\>'
 
-syn region erlangString                      start=/"/ end=/"/ skip=/\\/ contains=@Spell,erlangStringModifier
+" Keywords
+syn keyword erlangKeyword           after begin case catch cond end fun if let of query receive when try
+syn keyword erlangExtra             true false
+
 
-syn match erlangVariable                     /\<[A-Z_]\w*\>/
-syn match erlangAtom                         /\%(\%(^-\)\|#\)\@<!\<[a-z][A-Za-z0-9_]*\>\%(\s*[(:]\)\@!/
-syn match erlangAtom                         /\\\@<!'[^']*\\\@<!'/
+if !exists("g:erlang_highlight_bifs") || g:erlang_highlight_bifs == 1
 
-syn match erlangRecord                       /#\w\+/
+  " build-in-functions (BIFs)
+  syn keyword erlangBIF        abs alive apply atom_to_binary atom_to_list binary_part binary_to_atom binary_to_existing_atom binary_to_float binary_to_integer bitstring_to_list binary_to_list binary_to_term bit_size byte_size check_old_code check_process_code concat_binary date delete_module demonitor disconnect_node element erase error exit float float_to_binary float_to_list garbage_collect get get_keys group_leader halt hd integer_to_binary integer_to_list iolist_to_binary iolist_size is_alive is_atom is_binary is_bitstring is_boolean is_float is_function is_integer is_list is_number is_pid is_port is_process_alive is_record is_reference is_tuple length link list_to_atom list_to_binary list_to_bitstring list_to_existing_atom list_to_float list_to_integer list_to_pid list_to_tuple load_module make_ref max min module_loaded monitor monitor_node node nodes now open_port pid_to_list port_close port_command port_connect pre_loaded process_flag process_flag process_info process purge_module put register registered round self setelement size spawn spawn_link spawn_monitor spawn_opt split_binary statistics term_to_binary throw time tl trunc tuple_size tuple_to_list unlink unregister whereis
 
-syn match erlangTuple                        /{\|}/
-syn match erlangList                         /\[\|\]/
+endif
+
+
+if exists("g:erlang_highlight_special_atoms") && g:erlang_highlight_special_atoms == 1
 
-syn match erlangAttribute                    /^-\%(vsn\|author\|copyright\|compile\|deprecated\|module\|export\|import\|behaviour\|behavior\|export_type\|ignore_xref\|on_load\)\s*(\@=/
-syn match erlangInclude                      /^-include\%(_lib\)\?\s*(\@=/
-syn match erlangRecordDef                    /^-record\s*(\@=/
-syn match erlangDefine                       /^-\%(define\|undef\)\s*(\@=/
-syn match erlangPreCondit                    /^-\%(ifdef\|ifndef\|else\|endif\)\%(\s*(\@=\)\?/
+  " Processes
+  syn keyword erlangProcess    creation current_function dictionary
+  syn keyword erlangProcess    group_leader heap_size high initial_call
+  syn keyword erlangProcess    linked low memory_in_use message_queue
+  syn keyword erlangProcess    net_kernel node normal priority
+  syn keyword erlangProcess    reductions registered_name runnable
+  syn keyword erlangProcess    running stack_trace status timer
+  syn keyword erlangProcess    trap_exit waiting
 
-syn match erlangType                         /^-\%(spec\|type\)[( ]\@=/
-
-syn match erlangMacro                        /\%(-define(\)\@<=\w\+/
-syn match erlangMacro                        /?\??\w\+/
+  " Ports
+  syn keyword erlangPort       command count_in count_out creation in
+  syn keyword erlangPort       in_format linked node out owner packeting
 
-syn match erlangBitType                      /\%(\/\|-\)\@<=\%(bits\|bitstring\|binary\|integer\|float\|unit\)\>/
-syn match erlangBitSize                      /:\@<=[0-9]\+/
+  " Nodes
+  syn keyword erlangNode       atom_tables communicating creation
+  syn keyword erlangNode       current_gc current_reductions current_runtime
+  syn keyword erlangNode       current_wall_clock distribution_port
+  syn keyword erlangNode       entry_points error_handler friends
+  syn keyword erlangNode       garbage_collection magic_cookie magic_cookies
+  syn keyword erlangNode       module_table monitored_nodes name next_ref
+  syn keyword erlangNode       ports preloaded processes reductions
+  syn keyword erlangNode       ref_state registry runtime wall_clock
 
-syn match erlangBinary                      /<<\|>>/
+  " Reserved
+  syn keyword erlangReserved   apply_lambda module_info module_lambdas
+  syn keyword erlangReserved   record record_index record_info
+
+  " Extras
+  syn keyword erlangExtra      badarg nocookie
 
-" BIFs
-syn match erlangBIF                          /\%([^:0-9A-Za-z_]\|\<erlang:\)\@<=\%(abs\|apply\|atom_to_binary\|atom_to_list\|binary_part\|binary_to_atom\|binary_to_existing_atom\|binary_to_list\|binary_to_term\|bit_size\|bitstring_to_list\|byte_size\|check_process_code\|date\|delete_module\|demonitor\|disconnect_node\|element\|erase\|exit\|float\|float_to_list\|garbage_collect\|get\|get_keys\|group_leader\|hd\|integer_to_list\|iolist_size\|iolist_to_binary\|is_alive\|is_atom\|is_binary\|is_bitstring\|is_boolean\|is_float\|is_function\|is_integer\|is_list\|is_number\|is_pid\|is_port\|is_process_alive\|is_record\|is_reference\|is_tuple\|length\|link\|list_to_atom\|list_to_binary\|list_to_bitstring\|list_to_existing_atom\|list_to_float\|list_to_integer\|list_to_pid\|list_to_tuple\|load_module\|make_ref\|max\|min\|module_loaded\|monitor\|monitor_node\|node\|nodes\|now\|open_port\|pid_to_list\|port_close\|port_command\|port_connect\|port_control\|pre_loaded\|processes\|process_flag\|process_info\|purge_module\|put\|register\|registered\|round\|self\|setelement\|size\|spawn\|spawn_link\|spawn_monitor\|spawn_opt\|split_binary\|statistics\|term_to_binary\|time\|tl\|trunc\|tuple_size\|tuple_to_list\|unlink\|unregister\|whereis\)\%((\|\/[0-9]\)\@=/
-syn match erlangBIF                          /\<\%(erlang:\)\@<=\%(append_element\|bump_reductions\|cancel_timer\|decode_packet\|display\|function_exported\|fun_info\|fun_to_list\|get_cookie\|get_stacktrace\|hash\|is_builtin\|loaded\|load_nif\|localtime\|localtime_to_universaltime\|make_tuple\|memory\|monitor_node\|phash\|port_call\|port_info\|ports\|port_to_list\|process_display\|read_timer\|ref_to_list\|resume_process\|send\|send_after\|send_nosuspend\|set_cookie\|start_timer\|suspend_process\|system_flag\|system_info\|system_monitor\|system_profile\|trace\|trace_delivered\|trace_info\|trace_pattern\|universaltime\|universaltime_to_localtime\|yield\)(\@=/
-syn match erlangGBIF                         /erlang\%(:\w\)\@=/
+  " Signals
+  syn keyword erlangSignal     badsig kill killed exit normal
+endif
+
+" Sync at the beginning of functions: if this is not used, multiline string
+" are not always recognized
+syn sync match erlangSync grouphere NONE "^[a-z]\s*("
+
+" Define the default highlighting.
+" For version 5.7 and earlier: only when not done already
+" For version 5.8 and later: only when an item doesn't have highlighting yet
+if version >= 508 || !exists ("did_erlang_inits")
+  if version < 508
+    let did_erlang_inits = 1
+    command -nargs=+ HiLink hi link <args>
+  else
+    command -nargs=+ HiLink hi def link <args>
+  endif
 
-" Link Erlang stuff to Vim groups
-hi link erlangTodo           Todo
-hi link erlangString         String
-hi link erlangNoSpellString  String
-hi link erlangModifier       SpecialChar
-hi link erlangStringModifier SpecialChar
-hi link erlangComment        Comment
-hi link erlangAnnotation     Special
-hi link erlangVariable       Identifier
-hi link erlangInclude        Include
-hi link erlangRecordDef      Keyword
-hi link erlangAttribute      Keyword
-hi link erlangKeyword        Keyword
-hi link erlangMacro          Macro
-hi link erlangDefine         Define
-hi link erlangPreCondit      PreCondit
-hi link erlangPreProc        PreProc
-hi link erlangDelimiter      Delimiter
-hi link erlangBitDelimiter   Normal
-hi link erlangOperator       Operator
-hi link erlangConditional    Conditional
-hi link erlangGuard          Conditional
-hi link erlangBoolean        Boolean
-hi link erlangAtom           Constant
-hi link erlangRecord         Structure
-hi link erlangInteger        Number
-hi link erlangFloat          Number
-hi link erlangFloat          Number
-hi link erlangFloat          Number
-hi link erlangFloat          Number
-hi link erlangHex            Number
-hi link erlangFun            Keyword
-hi link erlangList           Delimiter
-hi link erlangTuple          Delimiter
-hi link erlangBinary         Keyword
-hi link erlangBitVariable    Identifier
-hi link erlangBitType        Type
-hi link erlangType           Type
-hi link erlangBitSize        Number
+  " erlang_characters
+  HiLink erlangComment Comment
+  HiLink erlangCommentAnnotation Special
+  HiLink erlangTodo Todo
+  HiLink erlangSeparator Normal
+  HiLink erlangOperator Operator
+  HiLink erlangRightArrow Operator
+
+  HiLink erlangStartString String
+  HiLink erlangString String
+  HiLink erlangStringModifier Special
+
+  HiLink erlangStartQuotedAtom Type
+  HiLink erlangQuotedAtom Type
+  HiLink erlangQuotedAtomModifier Special
+
+  HiLink erlangNumberInteger Number
+  HiLink erlangNumberFloat Float
+  HiLink erlangNumberHex Number
+
+  HiLink erlangModifier Special
 
-" Optional highlighting
-if g:erlang_highlight_bif
-	hi link erlangBIF    Keyword
-	hi link erlangGBIF   Keyword
+  " erlang_functions
+  HiLink erlangFCall Function
+  HiLink erlangBIF Function
+
+  " erlang_keywords
+  HiLink erlangDirective Type
+  HiLink erlangKeyword Keyword
+  HiLink erlangProcess Special
+  HiLink erlangPort Special
+  HiLink erlangNode Special
+  HiLink erlangReserved Statement
+  HiLink erlangExtra Statement
+  HiLink erlangSignal Statement
+
+  delcommand HiLink
 endif
+
+
+let b:current_syntax = "erlang"
+
+" vim: sw=2 et
--- a/runtime/syntax/sgmllnx.vim
+++ b/runtime/syntax/sgmllnx.vim
@@ -1,8 +1,7 @@
 " Vim syntax file
 " Language:	SGML-linuxdoc (supported by old sgmltools-1.x)
-"		(for more information, visit www.sgmltools.org)
 " Maintainer:	SungHyun Nam <goweol@gmail.com>
-" Last Change:	2008 Sep 17
+" Last Change:	2013 May 13
 
 " For version 5.x: Clear all syntax items
 " For version 6.x: Quit when a syntax file was already loaded
@@ -29,7 +28,7 @@ syn region sgmllnxSpecial	oneline start=
 syn keyword sgmllnxTagName contained article author date toc title sect verb
 syn keyword sgmllnxTagName contained abstract tscreen p itemize item enum
 syn keyword sgmllnxTagName contained descrip quote htmlurl code ref
-syn keyword sgmllnxTagName contained tt tag bf
+syn keyword sgmllnxTagName contained tt tag bf it url
 syn match   sgmllnxTagName contained "sect\d\+"
 
 " Comments
--- a/runtime/syntax/sisu.vim
+++ b/runtime/syntax/sisu.vim
@@ -1,8 +1,8 @@
 " SiSU Vim syntax file
 " SiSU Maintainer: Ralph Amissah <ralph@amissah.com>
-" SiSU Markup:     SiSU (sisu-3.1.0)
-" Last Change:     2011-10-03
-" URL:             <http://git.sisudoc.org/?p=code/sisu.git;a=blob;f=data/sisu/v3/conf/editor-syntax-etc/vim/syntax/sisu.vim;hb=HEAD>
+" SiSU Markup:     SiSU (sisu-4.0.9)
+" Last Change:     2013-02-22
+" URL (sisu-4.1.0): <http://git.sisudoc.org/?p=code/sisu.git;a=blob;f=data/sisu/conf/editor-syntax-etc/vim/syntax/sisu.vim;hb=HEAD>
 "(originally looked at Ruby Vim by Mirko Nasato)
 
 if version < 600
@@ -20,14 +20,9 @@ syn match sisu_error contains=sisu_link,
 "% "Markers Identifiers:
 if !exists("sisu_no_identifiers")
   syn match   sisu_mark_endnote                                           "\~^"
-  syn match   sisu_break               contains=@NoSpell                  " \\\\\( \|$\)"
-  syn match   sisu_break               contains=@NoSpell                  "<br>\|<br />"
-  syn match   sisu_control             contains=@NoSpell                  "^<:p[bn]>\s*$"
- "syn match   sisu_control             contains=@NoSpell                  "^<\(br\)\?:\(pg\|pgn\|pn\)>\s*$"
- "syn match   sisu_control             contains=@NoSpell                  "^\[\(br\)\?:\(pg\|pgn\|pn\)\]\s*$"
+  syn match   sisu_break               contains=@NoSpell                  " \\\\\( \|$\)\|<br>\|<br />"
+  syn match   sisu_control             contains=@NoSpell                  "^\(-\\\\-\|=\\\\=\|-\.\.-\|<:p[bn]>\)\s*$"
   syn match   sisu_control             contains=@NoSpell                  "^<:\(bo\|---\)>\s*$"
- "syn match   sisu_control             contains=@NoSpell                  "^<\(br\)\?:\(pr\|o\)>\s*$"
- "syn match   sisu_control             contains=@NoSpell                  "^\[\(br\)\?:\(pr\|o\)\]\s*$"
   syn match   sisu_marktail                                               "[~-]#"
   syn match   sisu_control                                                "\""
   syn match   sisu_underline                                              "\(^\| \)_[a-zA-Z0-9]\+_\([ .,]\|$\)"
@@ -43,11 +38,12 @@ if !exists("sisu_no_identifiers")
   syn match   sisu_sub_header_title                                       "^\s\+:\(subtitle\|short\|edition\|language\|lang_char\|note\):\s" "group=sisu_header_content
   syn match   sisu_sub_header_creator                                     "^\s\+:\(author\|editor\|contributor\|illustrator\|photographer\|translator\|digitized_by\|prepared_by\|audio\|video\):\s"                               " &hon &institution
   syn match   sisu_sub_header_rights                                      "^\s\+:\(copyright\|text\|translation\|illustrations\|photographs\|preparation\|digitization\|audio\|video\|license\|all\):\s"                   " access_rights license
-  syn match   sisu_sub_header_classify                                    "^\s\+:\(topic_register\|coverage\|format\|identifier\|keywords\|relation\|subject\|type\|dewey\|loc\|oclc\|pg\|isbn\):\s"
-  syn match   sisu_sub_header_date                                       "^\s\+:\(added_to_site\|available\|created\|issued\|modified\|published\|valid\|translated\|original_publication\):\s"
+  syn match   sisu_sub_header_classify                                    "^\s\+:\(topic_register\|keywords\|subject\|dewey\|loc\):\s"
+  syn match   sisu_sub_header_identifier                                  "^\s\+:\(oclc\|isbn\):\s"
+  syn match   sisu_sub_header_date                                        "^\s\+:\(added_to_site\|available\|created\|issued\|modified\|published\|valid\|translated\|original_publication\):\s"
   syn match   sisu_sub_header_original                                    "^\s\+:\(publisher\|date\|language\|lang_char\|institution\|nationality\|source\):\s"
-  syn match   sisu_sub_header_make                                        "^\s\+:\(headings\|num_top\|breaks\|language\|italics\|bold\|emphasis\|plaintext_wrap\|texpdf_font_mono\|texpdf_font\|skin\|stamp\|promo\|ad\|manpage\):\s"
-  syn match   sisu_sub_header_notes                                       "^\s\+:\(abstract\|comment\|description\|history\|prefix\|prefix_[ab]\|suffix\):\s"
+  syn match   sisu_sub_header_make                                        "^\s\+:\(headings\|num_top\|breaks\|language\|italics\|bold\|emphasis\|substitute\|omit\|plaintext_wrap\|texpdf_font_mono\|texpdf_font\|stamp\|promo\|ad\|manpage\|home_button_text\|home_button_image\|cover_image\|footer\):\s"
+  syn match   sisu_sub_header_notes                                       "^\s\+:\(description\|abstract\|comment\|coverage\|relation\|source\|history\|type\|format\|prefix\|prefix_[ab]\|suffix\):\s"
 
 "% "semantic markers: (ignore)
   syn match   sisu_sem_marker                                             ";{\|};[a-z._]*[a-z]"
@@ -85,6 +81,8 @@ syn region sisu_header_content contains=
 syn region sisu_header_content contains=sisu_error,sisu_comment,sisu_break,sisu_link,sisu_sub_header_rights matchgroup=sisu_header start="^[@]rights:[+-]\?\(\s\|\n\)"rs=e-1 end="\n$"
 " classify document
 syn region sisu_header_content contains=sisu_error,sisu_comment,sisu_break,sisu_link,sisu_sub_header_classify matchgroup=sisu_header start="^[@]classify:[+-]\?\(\s\|\n\)"rs=e-1 end="\n$"
+" identifier document
+syn region sisu_header_content contains=sisu_error,sisu_comment,sisu_break,sisu_link,sisu_sub_header_identifier matchgroup=sisu_header start="^[@]identifier:[+-]\?\(\s\|\n\)"rs=e-1 end="\n$"
 " original language (depreciated)
 syn region sisu_header_content contains=sisu_error,sisu_comment,sisu_break,sisu_link,sisu_sub_header_original matchgroup=sisu_header start="^[@]original:[+-]\?\(\s\|\n\)"rs=e-1 end="\n$"
 " notes
@@ -219,6 +217,7 @@ hi def link sisu_sub_header_date       S
 hi def link sisu_sub_header_publisher  Statement
 hi def link sisu_sub_header_rights     Statement
 hi def link sisu_sub_header_classify   Statement
+hi def link sisu_sub_header_identifier Statement
 hi def link sisu_sub_header_original   Statement
 hi def link sisu_sub_header_links      Statement
 hi def link sisu_sub_header_notes      Statement
--- a/runtime/syntax/sqlanywhere.vim
+++ b/runtime/syntax/sqlanywhere.vim
@@ -1,11 +1,11 @@
-
 " Vim syntax file
 " Language:    SQL, Adaptive Server Anywhere
 " Maintainer:  David Fishburn <dfishburn dot vim at gmail dot com>
-" Last Change: 2012 Jan 23
-" Version:     12.0.1
+" Last Change: 2013 May 13
+" Version:     16.0.0
 
-" Description: Updated to Adaptive Server Anywhere 12.0.1 (including spatial data)
+" Description: Updated to Adaptive Server Anywhere 16.0.0
+"              Updated to Adaptive Server Anywhere 12.0.1 (including spatial data)
 "              Updated to Adaptive Server Anywhere 11.0.1
 "              Updated to Adaptive Server Anywhere 10.0.1
 "              Updated to Adaptive Server Anywhere  9.0.2
@@ -27,33 +27,34 @@ syn case ignore
 syn keyword sqlSpecial  false null true
 
 " common functions
-syn keyword sqlFunction	 count sum avg min max debug_eng isnull
-syn keyword sqlFunction	 greater lesser argn string ymd todate
-syn keyword sqlFunction	 totimestamp date today now utc_now
-syn keyword sqlFunction	 number identity years months weeks days
-syn keyword sqlFunction	 hours minutes seconds second minute hour
-syn keyword sqlFunction	 day month year dow date_format substr
-syn keyword sqlFunction	 substring byte_substr length byte_length
-syn keyword sqlFunction	 datalength ifnull evaluate list
-syn keyword sqlFunction	 soundex similar difference like_start
-syn keyword sqlFunction	 like_end regexp_compile
-syn keyword sqlFunction	 regexp_compile_patindex remainder abs
-syn keyword sqlFunction	 graphical_plan plan explanation ulplan
-syn keyword sqlFunction	 graphical_ulplan long_ulplan
-syn keyword sqlFunction	 short_ulplan rewrite watcomsql
-syn keyword sqlFunction	 transactsql dialect estimate
-syn keyword sqlFunction	 estimate_source index_estimate
-syn keyword sqlFunction	 experience_estimate traceback wsql_state
-syn keyword sqlFunction	 lang_message dateadd datediff datepart
-syn keyword sqlFunction	 datename dayname monthname quarter
-syn keyword sqlFunction	 tsequal hextoint inttohex rand textptr
-syn keyword sqlFunction	 rowid grouping stddev variance rank
-syn keyword sqlFunction	 dense_rank density percent_rank user_name
-syn keyword sqlFunction	 user_id str stuff char_length nullif
-syn keyword sqlFunction	 sortkey compare ts_index_statistics
-syn keyword sqlFunction	 ts_table_statistics isdate isnumeric
-syn keyword sqlFunction	 get_identity lookup newid uuidtostr
-syn keyword sqlFunction	 strtouuid varexists
+syn keyword sqlFunction  abs argn avg bintohex bintostr
+syn keyword sqlFunction  byte_length byte_substr char_length
+syn keyword sqlFunction  compare count count_big datalength date
+syn keyword sqlFunction  date_format dateadd datediff datename
+syn keyword sqlFunction  datepart day dayname days debug_eng
+syn keyword sqlFunction  dense_rank density dialect difference
+syn keyword sqlFunction  dow estimate estimate_source evaluate
+syn keyword sqlFunction  experience_estimate explanation
+syn keyword sqlFunction  get_identity graphical_plan
+syn keyword sqlFunction  graphical_ulplan greater grouping
+syn keyword sqlFunction  hextobin hextoint hour hours identity
+syn keyword sqlFunction  ifnull index_estimate inttohex isdate
+syn keyword sqlFunction  isencrypted isnull isnumeric
+syn keyword sqlFunction  lang_message length lesser like_end
+syn keyword sqlFunction  like_start list long_ulplan lookup max
+syn keyword sqlFunction  min minute minutes month monthname
+syn keyword sqlFunction  months newid now nullif number
+syn keyword sqlFunction  percent_rank plan quarter rand rank
+syn keyword sqlFunction  regexp_compile regexp_compile_patindex
+syn keyword sqlFunction  remainder rewrite rowid second seconds
+syn keyword sqlFunction  short_ulplan similar sortkey soundex
+syn keyword sqlFunction  stddev stack_trace str string strtobin strtouuid stuff
+syn keyword sqlFunction  subpartition substr substring sum switchoffset sysdatetimeoffset
+syn keyword sqlFunction  textptr todate todatetimeoffset today totimestamp traceback transactsql
+syn keyword sqlFunction  ts_index_statistics ts_table_statistics
+syn keyword sqlFunction  tsequal ulplan user_id user_name utc_now
+syn keyword sqlFunction  uuidtostr varexists variance watcomsql
+syn keyword sqlFunction  weeks wsql_state year years ymd
 
 " 9.0.1 functions
 syn keyword sqlFunction	 acos asin atan atn2 cast ceiling convert cos cot
@@ -473,31 +474,36 @@ syn keyword sqlFunction  ST_ToPoint
 syn keyword sqlFunction  ST_ToPolygon
 syn keyword sqlFunction  ST_ToSurface
 
+" Array functions 16.x
+syn keyword sqlFunction	 array array_agg array_max_cardinality trim_array
+syn keyword sqlFunction	 error_line error_message error_procedure
+syn keyword sqlFunction	 error_sqlcode error_sqlstate error_stack_trace
+
 
 " keywords
-syn keyword sqlKeyword	 absolute accent action active add address admin aes_decrypt
-syn keyword sqlKeyword	 after aggregate algorithm allow_dup_row allow allowed alter 
-syn keyword sqlKeyword	 and angular ansi_substring any as append apply 
-syn keyword sqlKeyword	 arbiter asc ascii ase
-syn keyword sqlKeyword	 assign at atan2 atomic attended 
-syn keyword sqlKeyword	 audit auditing authorization axis
+syn keyword sqlKeyword	 absolute accent access account action active activate add address admin
+syn keyword sqlKeyword	 aes_decrypt after aggregate algorithm allow_dup_row allow allowed alter
+syn keyword sqlKeyword	 always and angular ansi_substring any as append apply
+syn keyword sqlKeyword	 arbiter array asc ascii ase
+syn keyword sqlKeyword	 assign at atan2 atomic attended
+syn keyword sqlKeyword	 audit auditing authentication authorization axis
 syn keyword sqlKeyword	 autoincrement autostop batch bcp before
 syn keyword sqlKeyword	 between bit_and bit_length bit_or bit_substr bit_xor
 syn keyword sqlKeyword	 blank blanks block
 syn keyword sqlKeyword	 both bottom unbounded breaker bufferpool
 syn keyword sqlKeyword	 build bulk by byte bytes cache calibrate calibration
-syn keyword sqlKeyword	 cancel capability cascade cast
-syn keyword sqlKeyword	 catalog ceil change changes char char_convert check checksum
-syn keyword sqlKeyword	 class classes client cmp
+syn keyword sqlKeyword	 cancel capability cardinality cascade cast
+syn keyword sqlKeyword	 catalog catch ceil change changes char char_convert
+syn keyword sqlKeyword	 check checkpointlog checksum class classes client cmp
 syn keyword sqlKeyword	 cluster clustered collation
 syn keyword sqlKeyword	 column columns
-syn keyword sqlKeyword	 command comments committed comparisons
+syn keyword sqlKeyword	 command comments committed commitid comparisons
 syn keyword sqlKeyword	 compatible component compressed compute computes
 syn keyword sqlKeyword	 concat configuration confirm conflict connection
 syn keyword sqlKeyword	 console consolidate consolidated
-syn keyword sqlKeyword	 constraint constraints content 
+syn keyword sqlKeyword	 constraint constraints content
 syn keyword sqlKeyword	 convert coordinate coordinator copy count count_set_bits
-syn keyword sqlKeyword	 crc createtime cross cube cume_dist
+syn keyword sqlKeyword	 crc createtime critical cross cube cume_dist
 syn keyword sqlKeyword	 current cursor data data database
 syn keyword sqlKeyword	 current_timestamp current_user cycle
 syn keyword sqlKeyword	 databases datatype dba dbfile
@@ -506,83 +512,86 @@ syn keyword sqlKeyword	 decrypted defaul
 syn keyword sqlKeyword	 definer definition
 syn keyword sqlKeyword	 delay deleting delimited dependencies desc
 syn keyword sqlKeyword	 description deterministic directory
-syn keyword sqlKeyword	 disable disabled disallow distinct do domain download duplicate
-syn keyword sqlKeyword	 dsetpass dttm dynamic each earth editproc ejb
-syn keyword sqlKeyword	 elimination ellipsoid
-syn keyword sqlKeyword	 else elseif empty enable encapsulated encrypted end
-syn keyword sqlKeyword	 encoding endif engine environment erase error escape escapes event
+syn keyword sqlKeyword	 disable disabled disallow distinct disksandbox disk_sandbox
+syn keyword sqlKeyword	 dn do domain download duplicate
+syn keyword sqlKeyword	 dsetpass dttm dynamic each earth editproc effective ejb
+syn keyword sqlKeyword	 elimination ellipsoid else elseif
+syn keyword sqlKeyword	 email empty enable encapsulated encrypted encryption end
+syn keyword sqlKeyword	 encoding endif engine environment erase error errors escape escapes event
 syn keyword sqlKeyword	 event_parameter every exception exclude excluded exclusive exec
 syn keyword sqlKeyword	 existing exists expanded expiry express exprtype extended_property
 syn keyword sqlKeyword	 external externlogin factor failover false
 syn keyword sqlKeyword	 fastfirstrow feature fieldproc file files filler
 syn keyword sqlKeyword	 fillfactor final finish first first_keyword first_value
 syn keyword sqlKeyword	 flattening
-syn keyword sqlKeyword	 following force foreign format forxml forxml_sep fp frame
-syn keyword sqlKeyword	 free freepage french fresh full function 
+syn keyword sqlKeyword	 following force foreign format forjson forxml forxml_sep fp frame
+syn keyword sqlKeyword	 free freepage french fresh full function
 syn keyword sqlKeyword	 gb generic get_bit go global grid
 syn keyword sqlKeyword	 group handler hash having header hexadecimal
 syn keyword sqlKeyword	 hidden high history hg hng hold holdlock host
 syn keyword sqlKeyword	 hours http_body http_session_timeout id identified identity ignore
 syn keyword sqlKeyword	 ignore_dup_key ignore_dup_row immediate
 syn keyword sqlKeyword	 in inactiv inactive inactivity included increment incremental
-syn keyword sqlKeyword	 index index_enabled index_lparen indexonly info
-syn keyword sqlKeyword	 inline inner inout insensitive inserting
-syn keyword sqlKeyword	 instead integrated
-syn keyword sqlKeyword	 internal intersection into introduced inverse invoker 
+syn keyword sqlKeyword	 index index_enabled index_lparen indexonly info information
+syn keyword sqlKeyword	 inheritance inline inner inout insensitive inserting
+syn keyword sqlKeyword	 instead
+syn keyword sqlKeyword	 internal intersection into introduced inverse invoker
 syn keyword sqlKeyword	 iq is isolation
 syn keyword sqlKeyword	 jar java java_location java_main_userid java_vm_options
-syn keyword sqlKeyword	 jconnect jdk join kb key keep kerberos language last
+syn keyword sqlKeyword	 jconnect jdk join json kb key keys keep language last
 syn keyword sqlKeyword	 last_keyword last_value lateral latitude
-syn keyword sqlKeyword	 ld left len linear lf ln level like
-syn keyword sqlKeyword	 limit local location log 
+syn keyword sqlKeyword	 ld ldap left len linear lf ln level like
+syn keyword sqlKeyword	 limit local location log
 syn keyword sqlKeyword	 logging logical login logscan long longitude low lru ls
-syn keyword sqlKeyword	 main major manual mark
-syn keyword sqlKeyword	 match matched materialized max maxvalue maximum mb measure membership
-syn keyword sqlKeyword	 merge metadata methods minimum minor minutes minvalue mirror 
-syn keyword sqlKeyword	 mode modify monitor move mru multiplex 
-syn keyword sqlKeyword	 name named namespaces national native natural new next nextval 
+syn keyword sqlKeyword	 main major manage manual mark master
+syn keyword sqlKeyword	 match matched materialized max maxvalue maximum mb measure median membership
+syn keyword sqlKeyword	 merge metadata methods migrate minimum minor minutes minvalue mirror
+syn keyword sqlKeyword	 mode modify monitor move mru multiplex
+syn keyword sqlKeyword	 name named namespaces national native natural new next nextval
 syn keyword sqlKeyword	 ngram no noholdlock nolock nonclustered none normal not
-syn keyword sqlKeyword	 notify null nullable_constant nulls 
-syn keyword sqlKeyword	 object oem_string of off offline offset olap
+syn keyword sqlKeyword	 notify null nullable_constant nulls
+syn keyword sqlKeyword	 object objects oem_string of off offline offset olap
 syn keyword sqlKeyword	 old on online only openstring operator
 syn keyword sqlKeyword	 optimization optimizer option
-syn keyword sqlKeyword	 or order organization others out outer over
+syn keyword sqlKeyword	 or order ordinality organization others out outer over owner
 syn keyword sqlKeyword	 package packetsize padding page pages
-syn keyword sqlKeyword	 paglock parallel parameter parent part 
-syn keyword sqlKeyword	 partition partitions partner password path pctfree 
-syn keyword sqlKeyword	 perms plan planar policy polygon populate port postfilter preceding 
+syn keyword sqlKeyword	 paglock parallel parameter parent part partial
+syn keyword sqlKeyword	 partition partitions partner password path pctfree
+syn keyword sqlKeyword	 permissions perms plan planar policy polygon populate port postfilter preceding
 syn keyword sqlKeyword	 precisionprefetch prefilter prefix preserve preview previous
-syn keyword sqlKeyword	 primary prior priority priqty private privileges procedure profile
+syn keyword sqlKeyword	 primary prior priority priqty private privilege privileges procedure profile profiling
 syn keyword sqlKeyword	 property_is_cumulative property_is_numeric public publication publish publisher
 syn keyword sqlKeyword	 quiesce quote quotes range readclientfile readcommitted reader readfile readonly
 syn keyword sqlKeyword	 readpast readuncommitted readwrite rebuild
 syn keyword sqlKeyword	 received recompile recover recursive references
 syn keyword sqlKeyword	 referencing regex regexp regexp_substr relative relocate
-syn keyword sqlKeyword	 rename repeatable repeatableread replicate 
+syn keyword sqlKeyword	 rename repeatable repeatableread replicate replication
 syn keyword sqlKeyword	 requests request_timeout required rereceive resend reserve reset
 syn keyword sqlKeyword	 resizing resolve resource respect restart
-syn keyword sqlKeyword	 restrict result retain
-syn keyword sqlKeyword	 returns reverse right role
-syn keyword sqlKeyword	 rollup root row row_number rowlock rows 
+syn keyword sqlKeyword	 restrict result retain retries
+syn keyword sqlKeyword	 returns reverse right role roles
+syn keyword sqlKeyword	 rollup root row row_number rowlock rows rowtype
 syn keyword sqlKeyword	 sa_index_hash sa_internal_fk_verify sa_internal_termbreak
 syn keyword sqlKeyword	 sa_order_preserving_hash sa_order_preserving_hash_big sa_order_preserving_hash_prefix
-syn keyword sqlKeyword	 scale schedule schema scope scripted scroll seconds secqty security
+syn keyword sqlKeyword	 sa_file_free_pages sa_internal_type_from_catalog sa_internal_valid_hash
+syn keyword sqlKeyword	 sa_internal_validate_value sa_json_element
+syn keyword sqlKeyword	 scale schedule schema scope script scripted scroll search seconds secqty security
 syn keyword sqlKeyword	 semi send sensitive sent sequence serializable
-syn keyword sqlKeyword	 server server session set_bit set_bits sets
+syn keyword sqlKeyword	 server severity session set_bit set_bits sets
 syn keyword sqlKeyword	 shapefile share side simple since site size skip
-syn keyword sqlKeyword	 snap snapshot soapheader soap_header 
+syn keyword sqlKeyword	 snap snapshot soapheader soap_header
 syn keyword sqlKeyword	 spatial split some sorted_data
 syn keyword sqlKeyword	 sql sqlcode sqlid sqlflagger sqlstate sqrt square
-syn keyword sqlKeyword	 stacker stale statement statistics status stddev_pop stddev_samp
+syn keyword sqlKeyword	 stacker stale state statement statistics status stddev_pop stddev_samp
 syn keyword sqlKeyword	 stemmer stogroup stoplist storage store
 syn keyword sqlKeyword	 strip stripesizekb striping subpages subscribe subscription
-syn keyword sqlKeyword	 subtransaction suser_id suser_name synchronization
+syn keyword sqlKeyword	 subtransaction suser_id suser_name suspend synchronization
 syn keyword sqlKeyword	 syntax_error table tables tablock
-syn keyword sqlKeyword	 tablockx tb temp template temporary term then ties 
-syn keyword sqlKeyword	 timezone timeout to to_char to_nchar tolerance top
-syn keyword sqlKeyword	 traced_plan tracing
-syn keyword sqlKeyword	 transfer transform transaction transactional treat tries 
-syn keyword sqlKeyword	 true tsequal type tune uncommitted unconditionally
+syn keyword sqlKeyword	 tablockx target tb temp template temporary term then ties
+syn keyword sqlKeyword	 timezone timeout tls to to_char to_nchar tolerance top
+syn keyword sqlKeyword	 trace traced_plan tracing
+syn keyword sqlKeyword	 transfer transform transaction transactional treat tries
+syn keyword sqlKeyword	 true try tsequal type tune uncommitted unconditionally
 syn keyword sqlKeyword	 unenforced unicode unique unistr unit unknown unlimited unload
 syn keyword sqlKeyword	 unpartition unquiesce updatetime updating updlock upgrade upload
 syn keyword sqlKeyword	 upper usage use user
@@ -593,14 +602,14 @@ syn keyword sqlKeyword	 verify versions 
 syn keyword sqlKeyword	 warning wd web when where with with_auto
 syn keyword sqlKeyword	 with_auto with_cube with_rollup without
 syn keyword sqlKeyword	 with_lparen within word work workload write writefile
-syn keyword sqlKeyword	 writeclientfile writer writers writeserver xlock 
-syn keyword sqlKeyword	 zeros zone
-" XML 
+syn keyword sqlKeyword	 writeclientfile writer writers writeserver xlock
+syn keyword sqlKeyword	 war xml zeros zone
+" XML
 syn keyword sqlKeyword	 raw auto elements explicit
 " HTTP support
 syn keyword sqlKeyword	 authorization secure url service next_soap_header
 " HTTP 9.0.2 new procedure keywords
-syn keyword sqlKeyword	 namespace certificate clientport proxy
+syn keyword sqlKeyword	 namespace certificate certificates clientport proxy trusted_certificates_file
 " OLAP support 9.0.0
 syn keyword sqlKeyword	 covar_pop covar_samp corr regr_slope regr_intercept
 syn keyword sqlKeyword	 regr_count regr_r2 regr_avgx regr_avgy
@@ -610,6 +619,10 @@ syn keyword sqlKeyword	 regr_sxx regr_sy
 syn keyword sqlKeyword	 character dec options proc reference
 syn keyword sqlKeyword	 subtrans tran syn keyword
 
+" Login Mode Options
+syn keyword sqlKeywordLogin	 standard integrated kerberos LDAPUA
+syn keyword sqlKeywordLogin	 cloudadmin mixed
+
 " Spatial Predicates
 syn keyword sqlKeyword   ST_Contains
 syn keyword sqlKeyword   ST_ContainsFilter
@@ -692,9 +705,9 @@ syn keyword sqlKeyword   ST_LinearUnHash
 syn keyword sqlOperator	 in any some all between exists
 syn keyword sqlOperator	 like escape not is and or
 syn keyword sqlOperator  minus
-syn keyword sqlOperator  prior distinct
+syn keyword sqlOperator  prior distinct unnest
 
-syn keyword sqlStatement allocate alter attach backup begin break call case
+syn keyword sqlStatement allocate alter attach backup begin break call case catch
 syn keyword sqlStatement checkpoint clear close comment commit configure connect
 syn keyword sqlStatement continue create deallocate declare delete describe
 syn keyword sqlStatement detach disconnect drop except execute exit explain fetch
@@ -705,7 +718,7 @@ syn keyword sqlStatement prepare print p
 syn keyword sqlStatement remote remove reorganize resignal restore resume
 syn keyword sqlStatement return revoke rollback save savepoint select
 syn keyword sqlStatement set setuser signal start stop synchronize
-syn keyword sqlStatement system trigger truncate union unload update
+syn keyword sqlStatement system trigger truncate try union unload update
 syn keyword sqlStatement validate waitfor whenever while window writetext
 
 
@@ -715,7 +728,7 @@ syn keyword sqlType	 float int integer n
 syn keyword sqlType	 smallint tinyint real
 syn keyword sqlType	 money smallmoney
 syn keyword sqlType	 date datetime datetimeoffset smalldatetime time timestamp
-syn keyword sqlType	 binary image varbinary uniqueidentifier
+syn keyword sqlType	 binary image varray varbinary uniqueidentifier
 syn keyword sqlType	 unsigned
 " Spatial types
 syn keyword sqlType	 st_geometry st_point st_curve st_surface st_geomcollection
@@ -736,8 +749,10 @@ syn keyword sqlOption    Ansi_update_con
 syn keyword sqlOption    Ansinull
 syn keyword sqlOption    Auditing
 syn keyword sqlOption    Auditing_options
+syn keyword sqlOption    Auto_commit_on_create_local_temp_index
 syn keyword sqlOption    Background_priority
 syn keyword sqlOption    Blocking
+syn keyword sqlOption    Blocking_others_timeout
 syn keyword sqlOption    Blocking_timeout
 syn keyword sqlOption    Chained
 syn keyword sqlOption    Checkpoint_time
@@ -754,6 +769,7 @@ syn keyword sqlOption    Cooperative_com
 syn keyword sqlOption    Database_authentication
 syn keyword sqlOption    Date_format
 syn keyword sqlOption    Date_order
+syn keyword sqlOption    db_publisher
 syn keyword sqlOption    Debug_messages
 syn keyword sqlOption    Dedicated_task
 syn keyword sqlOption    Default_dbspace
@@ -764,14 +780,18 @@ syn keyword sqlOption    Divide_by_zero_
 syn keyword sqlOption    Escape_character
 syn keyword sqlOption    Exclude_operators
 syn keyword sqlOption    Extended_join_syntax
+syn keyword sqlOption    Extern_login_credentials
 syn keyword sqlOption    Fire_triggers
 syn keyword sqlOption    First_day_of_week
 syn keyword sqlOption    For_xml_null_treatment
 syn keyword sqlOption    Force_view_creation
 syn keyword sqlOption    Global_database_id
 syn keyword sqlOption    Http_session_timeout
+syn keyword sqlOption    Http_connection_pool_basesize
+syn keyword sqlOption    Http_connection_pool_timeout
 syn keyword sqlOption    Integrated_server_name
 syn keyword sqlOption    Isolation_level
+syn keyword sqlOption    Java_class_path
 syn keyword sqlOption    Java_location
 syn keyword sqlOption    Java_main_userid
 syn keyword sqlOption    Java_vm_options
@@ -790,6 +810,7 @@ syn keyword sqlOption    Max_recursive_i
 syn keyword sqlOption    Max_statement_count
 syn keyword sqlOption    Max_temp_space
 syn keyword sqlOption    Min_password_length
+syn keyword sqlOption    Min_role_admins
 syn keyword sqlOption    Nearest_century
 syn keyword sqlOption    Non_keywords
 syn keyword sqlOption    Odbc_describe_binary_as_varbinary
@@ -807,6 +828,7 @@ syn keyword sqlOption    Prefetch
 syn keyword sqlOption    Preserve_source_format
 syn keyword sqlOption    Prevent_article_pkey_update
 syn keyword sqlOption    Priority
+syn keyword sqlOption    Progress_messages
 syn keyword sqlOption    Query_mem_timeout
 syn keyword sqlOption    Quoted_identifier
 syn keyword sqlOption    Read_past_deleted
@@ -814,6 +836,7 @@ syn keyword sqlOption    Recovery_time
 syn keyword sqlOption    Remote_idle_timeout
 syn keyword sqlOption    Replicate_all
 syn keyword sqlOption    Request_timeout
+syn keyword sqlOption    Reserved_keywords
 syn keyword sqlOption    Return_date_time_as_string
 syn keyword sqlOption    Rollback_on_deadlock
 syn keyword sqlOption    Row_counts
@@ -823,6 +846,12 @@ syn keyword sqlOption    Sort_collation
 syn keyword sqlOption    Sql_flagger_error_level
 syn keyword sqlOption    Sql_flagger_warning_level
 syn keyword sqlOption    String_rtruncation
+syn keyword sqlOption    st_geometry_asbinary_format
+syn keyword sqlOption    st_geometry_astext_format
+syn keyword sqlOption    st_geometry_asxml_format
+syn keyword sqlOption    st_geometry_describe_type
+syn keyword sqlOption    st_geometry_interpolation
+syn keyword sqlOption    st_geometry_on_invalid
 syn keyword sqlOption    Subsume_row_locks
 syn keyword sqlOption    Suppress_tds_debugging
 syn keyword sqlOption    Synchronize_mirror_on_commit
@@ -831,6 +860,7 @@ syn keyword sqlOption    Temp_space_limi
 syn keyword sqlOption    Time_format
 syn keyword sqlOption    Time_zone_adjustment
 syn keyword sqlOption    Timestamp_format
+syn keyword sqlOption    Timestamp_with_time_zone_format
 syn keyword sqlOption    Truncate_timestamp_values
 syn keyword sqlOption    Tsql_outer_joins
 syn keyword sqlOption    Tsql_variables
@@ -842,6 +872,7 @@ syn keyword sqlOption    Uuid_has_hyphen
 syn keyword sqlOption    Verify_password_function
 syn keyword sqlOption    Wait_for_commit
 syn keyword sqlOption    Webservice_namespace_host
+syn keyword sqlOption    Webservice_sessionid_name
 
 " Strings and characters:
 syn region sqlString		start=+"+    end=+"+ contains=@Spell
@@ -859,32 +890,18 @@ syn sync ccomment sqlComment
 syn sync ccomment sqlDashComment
 syn sync ccomment sqlSlashComment
 
-" Define the default highlighting.
-" For version 5.7 and earlier: only when not done already
-" For version 5.8 and later: only when an item doesn't have highlighting yet
-if version >= 508 || !exists("did_sql_syn_inits")
-    if version < 508
-        let did_sql_syn_inits = 1
-        command -nargs=+ HiLink hi link <args>
-    else
-        command -nargs=+ HiLink hi link <args>
-    endif
-
-    HiLink sqlDashComment	Comment
-    HiLink sqlSlashComment	Comment
-    HiLink sqlMultiComment	Comment
-    HiLink sqlNumber	        Number
-    HiLink sqlOperator	        Operator
-    HiLink sqlSpecial	        Special
-    HiLink sqlKeyword	        Keyword
-    HiLink sqlStatement	        Statement
-    HiLink sqlString	        String
-    HiLink sqlType	        Type
-    HiLink sqlFunction	        Function
-    HiLink sqlOption	        PreProc
-
-    delcommand HiLink
-endif
+hi def link sqlDashComment	Comment
+hi def link sqlSlashComment	Comment
+hi def link sqlMultiComment	Comment
+hi def link sqlNumber	        Number
+hi def link sqlOperator	        Operator
+hi def link sqlSpecial	        Special
+hi def link sqlKeyword	        Keyword
+hi def link sqlStatement	Statement
+hi def link sqlString	        String
+hi def link sqlType	        Type
+hi def link sqlFunction	        Function
+hi def link sqlOption	        PreProc
 
 let b:current_syntax = "sqlanywhere"
 
--- a/runtime/tools/ccfilter_README.txt
+++ b/runtime/tools/ccfilter_README.txt
@@ -11,7 +11,7 @@ so you would normally compile it with on
     cc -D_IRIX    ccfilter.c -o ccfilter
     cc -D_SOLARIS ccfilter.c -o ccfilter
     cc -D_HPUX    ccfilter.c -o ccfilter
-You can then copy ccfilter to it's target destination (i.e: /usr/local/bin).
+You can then copy ccfilter to its target destination (i.e: /usr/local/bin).
 The man page ccfilter.1 has to be copied to somewhere in your MANPATH,
 under a man1 directory (i.e: /usr/local/man/man1).
 
new file mode 100644
--- /dev/null
+++ b/runtime/tutor/tutor.zh.utf-8
@@ -0,0 +1,852 @@
+===============================================================================
+=      歡     迎     閱     讀   《 V I M  教  程 》   ──     版本 1.5      =
+===============================================================================
+     vim 是一個具有很多命令的功能非常強大的編輯器。限于篇幅,在本教程當中
+     不就詳細介紹了。本教程的設計目標是講述一些必要的基本命令,而掌握好這
+     些命令,您就能夠很容易將vim當作一個通用的萬能編輯器來使用了。
+
+     完成本教程的內容大約需要25-30分鐘,取決于您訓練的時間。
+
+     每一節的命令操作將會更改本文。推薦您復制本文的一個副本,然後在副本上
+     進行訓練(如果您是通過"vimtutor"來啟動教程的,那麼本文就已經是副本了)。
+
+     切記一點︰本教程的設計思路是在使用中進行學習的。也就是說,您需要通過
+     執行命令來學習它們本身的正確用法。如果您只是閱讀而不操作,那麼您可能
+     會很快遺忘這些命令的!
+
+     好了,現在請確定您的Shift-Lock(大小寫鎖定鍵)還沒有按下,然後按鍵盤上
+     的字母鍵 j 足夠多的次數來移動光標,直到第一節的內容能夠完全充滿屏幕。
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+			第一講第一節︰移動光標
+
+
+   ※※ 要移動光標,請依照說明分別按下 h、j、k、l 鍵。 ※※
+
+	     ^
+	     k		    提示︰ h 的鍵位于左邊,每次按下就會向左移動。
+       < h	 l >		   l 的鍵位于右邊,每次按下就會向右移動。
+	     j			   j 鍵看起來很象一支尖端方向朝下的箭頭。
+	     v
+
+  1. 請隨意在屏幕內移動光標,直至您覺得舒服為止。
+
+  2. 按下下行鍵(j),直到出現光標重復下行。
+
+---> 現在您應該已經學會如何移動到下一講吧。
+
+  3. 現在請使用下行鍵,將光標移動到第二講。
+
+提示︰如果您不敢確定您所按下的字母,請按下<ESC>鍵回到正常(Normal)模式。
+      然後再次從鍵盤輸入您想要的命令。
+
+提示︰光標鍵應當也能正常工作的。但是使用hjkl鍵,在習慣之後您就能夠快速
+      地在屏幕內四處移動光標了。
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+			第一講第二節︰VIM的進入和退出
+
+
+  !! 特別提示︰敬請閱讀完整本一節的內容,然後才能執行以下所講解的命令。
+
+  1. 請按<ESC>鍵(這是為了確保您處在正常模式)。
+
+  2. 然後輸入︰			:q! <回車>
+
+---> 這種方式的退出編輯器絕不會保存您進入編輯器以來所做的改動。
+     如果您想保存更改再退出,請輸入︰
+				:wq  <回車>
+
+  3. 如果您看到了命令行提示符,請輸入能夠帶您回到本教程的命令,那就是︰
+
+		vimtutor <回車>
+
+     通常情況下您也可以用這種方式︰
+
+		vim tutor <回車>
+
+---> 這裡的 'vim' 表示進入vim編輯器,而 'tutor'則是您準備要編輯的文件。
+
+  4. 如果您自信已經牢牢記住了這些步驟的話,請從步驟1執行到步驟3退出,然
+     後再次進入編輯器。接著將光標移動到第一講第三節來繼續我們的教程講解。
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+			第一講第三節︰文本編輯之刪除
+
+
+   ** 在正常(Normal)模式下,可以按下 x 鍵來刪除光標所在位置的字符。**
+
+  1. 請將光標移動到本節中下面標記有 ---> 的那一行。
+
+  2. 為了修正輸入錯誤,請將光標移至準備刪除的字符的位置處。
+
+  3. 然後按下 x 鍵將錯誤字符刪除掉。
+
+  4. 重復步驟2到步驟4,直到句子修正為止。
+
+---> The ccow jumpedd ovverr thhe mooon.
+
+  5. 好了,該行已經修正了,下一節內容是第一講第四節。
+
+特別提示︰在您瀏覽本教程時,不要強行記憶。記住一點︰在使用中學習。
+
+
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+		     第一講第四節︰文本編輯之插入
+
+
+	 ** 在正常模式下,可以按下 i 鍵來插入文本。**
+
+  1. 請將光標移動到本節中下面標記有 ---> 的第一行。
+
+  2. 為了使得第一行內容雷同于第二行,請將光標移至文本第一個字符準備插入
+     的位置。
+
+  3. 然後按下 i 鍵,接著輸入必要的文本字符。
+
+  4. 所有文本都修正完畢,請按下 <ESC> 鍵返回正常模式。
+     重復步驟2至步驟4以便修正句子。
+
+---> There is text misng this .
+---> There is some text missing from this line.
+
+  5. 如果您對文本插入操作已經很滿意,請接著閱讀下面的小結。
+
+
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+			       第一講小結
+
+
+  1. 光標在屏幕文本中的移動既可以用箭頭鍵,也可以使用 hjkl 字母鍵。
+	 h (左移)	j (下行)       k (上行)	    l (右移)
+
+  2. 欲進入vim編輯器(從命令行提示符),請輸入︰vim 文件名 <回車>
+
+  3. 欲退出vim編輯器,請輸入以下命令放棄所有修改︰
+
+	<ESC>   :q!	 <回車>
+
+     或者輸入以下命令保存所有修改︰
+
+	<ESC>   :wq	 <回車>
+
+  4. 在正常模式下刪除光標所在位置的字符,請按︰ x
+
+  5. 在正常模式下要在光標所在位置開始插入文本,請按︰
+
+	 i     輸入必要文本	<ESC>
+
+特別提示︰按下 <ESC> 鍵會帶您回到正常模式或者取消一個不期望或者部分完成
+的命令。
+
+好了,第一講到此結束。下面接下來繼續第二講的內容。
+
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+			第二講第一節︰刪除類命令
+
+
+	    ** 輸入 dw 可以從光標處刪除至一個單字/單詞的末尾。**
+
+  1. 請按下 <ESC> 鍵確保您處于正常模式。
+
+  2. 請將光標移動到本節中下面標記有 ---> 的那一行。
+
+  3. 請將光標移至準備要刪除的單詞的開始。
+
+  4. 接著輸入 dw 刪除掉該單詞。
+
+  特別提示︰您所輸入的 dw 會在您輸入的同時出現在屏幕的最後一行。如果您輸
+  入有誤,請按下 <ESC> 鍵取消,然後重新再來。
+
+---> There are a some words fun that don't belong paper in this sentence.
+
+  5. 重復步驟3至步驟4,直至句子修正完畢。接著繼續第二講第二節內容。
+
+
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+		      第二講第二節︰其他刪除類命令
+
+
+		   ** 輸入 d$ 從當前光標刪除到行末。**
+
+  1. 請按下 <ESC> 鍵確保您處于正常模式。
+
+  2. 請將光標移動到本節中下面標記有 ---> 的那一行。
+
+  3. 請將光標移動到該行的尾部(也就是在第一個點號‘.’後面)。
+
+  4. 然後輸入 d$ 從光標處刪至當前行尾部。
+
+---> Somebody typed the end of this line twice. end of this line twice.
+
+
+  5. 請繼續學習第二講第三節就知道是怎麼回事了。
+
+
+
+
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+		     第二講第三節︰關于命令和對象
+
+
+  刪除命令 d 的格式如下︰
+
+	 [number]   d	object	    或者     d	 [number]   object
+
+  其意如下︰
+    number - 代表執行命令的次數(可選項,缺省設置為 1 )。
+    d - 代表刪除。
+    object - 代表命令所要操作的對象(下面有相關介紹)。
+
+  一個簡短的對象列表︰
+    w - 從當前光標當前位置直到單字/單詞末尾,包括空格。
+    e - 從當前光標當前位置直到單字/單詞末尾,但是 *不* 包括空格。
+    $ - 從當前光標當前位置直到當前行末。
+
+特別提示︰
+    對于勇于探索者,請在正常模式下面僅按代表相應對象的鍵而不使用命令,則
+    將看到光標的移動正如上面的對象列表所代表的一樣。
+
+
+
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+		第二講第四節︰對象命令的特殊情況
+
+
+	       ** 輸入 dd 可以刪除整一個當前行。 **
+
+  鑒于整行刪除的高頻度,VIM 的設計者決定要簡化整行刪除,僅需要在同一行上
+  擊打兩次 d 就可以刪除掉光標所在的整行了。
+
+  1. 請將光標移動到本節中下面的短句段落中的第二行。
+  2. 輸入 dd 刪除該行。
+  3. 然後移動到第四行。
+  4. 接著輸入 2dd (還記得前面講過的 number-command-object 嗎?) 刪除兩行。
+
+      1)  Roses are red,
+      2)  Mud is fun,
+      3)  Violets are blue,
+      4)  I have a car,
+      5)  Clocks tell time,
+      6)  Sugar is sweet
+      7)  And so are you.
+
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+			 第二講第五節︰撤消類命令
+
+
+	 ** 輸入 u 來撤消最後執行的命令,輸入 U 來修正整行。**
+
+  1. 請將光標移動到本節中下面標記有 ---> 的那一行,並將其置于第一個錯誤
+     處。
+  2. 輸入 x 刪除第一個不想保留的字母。
+  3. 然後輸入 u 撤消最後執行的(一次)命令。
+  4. 這次要使用 x 修正本行的所有錯誤。
+  5. 現在輸入一個大寫的 U ,恢復到該行的原始狀態。
+  6. 接著多次輸入 u 以撤消 U 以及更前的命令。
+  7. 然後多次輸入 CTRL-R (先按下 CTRL 鍵不放開,接著輸入 R 鍵) ,這樣就
+     可以執行恢復命令,也就是撤消掉撤消命令。
+
+---> Fiix the errors oon thhis line and reeplace them witth undo.
+
+  8. 這些都是非常有用的命令。下面是第二講的小結了。
+
+
+
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+			       第二講小結
+
+
+  1. 欲從當前光標刪除至單字/單詞末尾,請輸入︰dw
+
+  2. 欲從當前光標刪除至當前行末尾,請輸入︰d$
+
+  3. 欲刪除整行,請輸入︰dd
+
+  4. 在正常模式下一個命令的格式是︰
+
+       [number]   command   object     或者     command	[number]   object
+     其意是︰
+       number - 代表的是命令執行的次數
+       command - 代表要做的事情,比如 d 代表刪除
+       object - 代表要操作的對象,比如 w 代表單字/單詞,$ 代表到行末等等。
+		$ (to the end of line), etc.
+
+  5. 欲撤消以前的操作,請輸入︰u (小寫的u)
+     欲撤消在一行中所做的改動,請輸入︰U (大寫的U)
+     欲撤消以前的撤消命令,恢復以前的操作結果,請輸入︰CTRL-R
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+			 第三講第一節︰置入類命令
+
+
+	       ** 輸入 p 將最後一次刪除的內容置入光標之後 **
+
+  1. 請將光標移動到本節中下面示范段落的首行。
+
+  2. 輸入 dd 將該行刪除,這樣會將該行保存到vim的緩沖區中。
+
+  3. 接著將光標移動到準備置入的位置的上方。記住︰是上方哦。
+
+  4. 然後在正常模式下(<ESC>鍵進入),輸入 p 將該行粘貼置入。
+
+  5. 重復步驟2至步驟4,將所有的行依序放置到正確的位置上。
+
+     d) Can you learn too?
+     b) Violets are blue,
+     c) Intelligence is learned,
+     a) Roses are red,
+
+
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+		       第三講第二節︰替換類命令
+
+
+	  ** 輸入 r 和一個字符替換光標所在位置的字符。**
+
+  1. 請將光標移動到本節中下面標記有 ---> 的第一行。
+
+  2. 請移動光標到第一個錯誤的適當位置。
+
+  3. 接著輸入 r ,這樣就能將錯誤替換掉了。
+
+  4. 重復步驟2和步驟3,直到第一行已經修改完畢。
+
+--->  Whan this lime was tuoed in, someone presswd some wrojg keys!
+--->  When this line was typed in, someone pressed some wrong keys!
+
+  5. 然後我們繼續學校第三講第三節。
+
+特別提示︰切記您要在使用中學習,而不是在記憶中學習。
+
+
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+			第三講第三節︰更改類命令
+
+
+	   ** 要改變一個單字/單詞的部分或者全部,請輸入 cw **
+
+  1. 請將光標移動到本節中下面標記有 ---> 的第一行。
+
+  2. 接著把光標放在單詞 lubw 的字母 u 的位置那裡。
+
+  3. 然後輸入 cw 就可以修正該單詞了(在本例這裡是輸入 ine 。)
+
+  4. 最後按 <ESC> 鍵,然後光標定位到下一個錯誤第一個準備更改的字母處。
+
+  5. 重復步驟3和步驟4,直到第一個句子完全雷同第二個句子。
+
+---> This lubw has a few wptfd that mrrf changing usf the change command.
+---> This line has a few words that need changing using the change command.
+
+提示︰請注意 cw 命令不僅僅是替換了一個單詞,也讓您進入文本插入狀態了。
+
+
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+		       第三講第四節︰使用c指令的其他更改類命令
+
+
+	     ** 更改類指令可以使用同刪除類命令所使用的對象參數。**
+
+  1. 更改類指令的工作方式跟刪除類命令是一致的。操作格式是︰
+
+       [number]   c   object	   或者	    c	[number]   object
+
+  2. 對象參數也是一樣的,比如 w 代表單字/單詞,$代表行末等等。
+
+  3. 請將光標移動到本節中下面標記有 ---> 的第一行。
+
+  4. 接著將光標移動到第一個錯誤處。
+
+  5. 然後輸入 c$ 使得該行剩下的部分更正得同第二行一樣。最後按 <ESC> 鍵。
+
+---> The end of this line needs some help to make it like the second.
+---> The end of this line needs to be corrected using the  c$  command.
+
+
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+			       第三講小結
+
+
+  1. 要重新置入已經刪除的文本內容,請輸入小寫字母 p。該操作可以將已刪除
+     的文本內容置于光標之後。如果最後一次刪除的是一個整行,那麼該行將置
+     于當前光標所在行的下一行。
+
+  2. 要替換光標所在位置的字符,請輸入小寫的 r 和要替換掉原位置字符的新字
+     符即可。
+
+  3. 更改類命令允許您改變指定的對象,從當前光標所在位置直到對象的末尾。
+     比如輸入 cw 可以替換當前光標到單詞的末尾的內容;輸入 c$ 可以替換當
+     前光標到行末的內容。
+
+  4. 更改類命令的格式是︰
+
+	 [number]   c	object	      或者	c   [number]   object
+
+下面我們繼續學習下一講。
+
+
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+		     第四講第一節︰定位及文件狀態
+
+
+  ** 輸入 CTRL-g 顯示當前編輯文件中當前光標所在行位置以及文件狀態信息。
+     輸入 SHIFT-G 則直接跳轉到文件中的某一指定行。**
+
+  提示︰切記要先通讀本節內容,之後才可以執行以下步驟!!!
+
+  1. 按下 CTRL 鍵不放開然後按 g 鍵。然後就會看到頁面最底部出現一個狀態信
+     息行,顯示的內容是當前編輯的文件名和文件的總行數。請記住步驟3的行號。
+
+  2. 按下 SHIFT-G 鍵可以使得當前光標直接跳轉到文件最後一行。
+
+  3. 輸入您曾停留的行號,然後按下 SHIFT-G。這樣就可以返回到您第一次按下
+     CTRL-g 時所在的行好了。注意︰輸入行號時,行號是不會在屏幕上顯示出來
+     的。
+
+  4. 如果願意,您可以繼續執行步驟1至步驟三。
+
+
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+			第四講第二節︰搜索類命令
+
+
+     ** 輸入 / 以及尾隨的字符串可以用以在當前文件中查找該字符串。**
+
+  1. 在正常模式下輸入 / 字符。您此時會注意到該字符和光標都會出現在屏幕底
+     部,這跟 : 命令是一樣的。
+
+  2. 接著輸入 errroor <回車>。那個errroor就是您要查找的字符串。
+
+  3. 要查找同上一次的字符串,只需要按 n 鍵。要向相反方向查找同上一次的字
+     符串,請輸入 Shift-N 即可。
+
+  4. 如果您想逆向查找字符串,請使用 ? 代替 / 進行。
+
+---> When the search reaches the end of the file it will continue at the start.
+
+  "errroor" is not the way to spell error;  errroor is an error.
+
+  提示︰如果查找已經到達文件末尾,查找會自動從文件頭部繼續查找。
+
+
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+		   第四講第三節︰配對括號的查找
+
+
+	      ** 按 % 可以查找配對的括號 )、]、}。**
+
+  1. 把光標放在本節下面標記有 --> 那一行中的任何一個 (、[ 或 { 處。
+
+  2. 接著按 % 字符。
+
+  3. 此時光標的位置應當是在配對的括號處。
+
+  4. 再次按 % 就可以跳回配對的第一個括號處。
+
+---> This ( is a test line with ('s, ['s ] and {'s } in it. ))
+
+提示︰在程序調試時,這個功能用來查找不配對的括號是很有用的。
+
+
+
+
+
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+		      第四講第四節︰修正錯誤的方法之一
+
+
+		** 輸入 :s/old/new/g 可以替換 old 為 new。**
+
+  1. 請將光標移動到本節中下面標記有 ---> 的那一行。
+
+  2. 輸入 :s/thee/the <回車> 。請注意該命令只改變光標所在行的第一個匹配
+     串。
+
+  3. 輸入 :s/thee/the/g	則是替換全行的匹配串。
+
+---> the best time to see thee flowers is in thee spring.
+
+  4. 要替換兩行之間出現的每個匹配串,請輸入 :#,#s/old/new/g (#,#代表的是
+     兩行的行號)。輸入 :%s/old/new/g 則是替換整個文件中的每個匹配串。
+
+
+
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+			       第四講小結
+
+
+  1. Ctrl-g 用于顯示當前光標所在位置和文件狀態信息。Shift-G 用于將光標跳
+     轉至文件最後一行。先敲入一個行號然後按 Shift-G 則是將光標移動至該行
+     號代表的行。
+
+  2. 輸入 / 然後緊隨一個字符串是則是在當前所編輯的文檔中向後查找該字符串。
+     輸入問號 ? 然後緊隨一個字符串是則是在當前所編輯的文檔中向前查找該字
+     符串。完成一次查找之後按 n 鍵則是重復上一次的命令,可在同一方向上查
+     找下一個字符串所在;或者按 Shift-N 向相反方向查找下該字符串所在。
+
+  3. 如果光標當前位置是括號(、)、[、]、{、},按 % 可以將光標移動到配對的
+     括號上。
+
+  4. 在一行內替換頭一個字符串 old 為新的字符串 new,請輸入  :s/old/new
+     在一行內替換所有的字符串 old 為新的字符串 new,請輸入  :s/old/new/g
+     在兩行內替換所有的字符串 old 為新的字符串 new,請輸入  :#,#s/old/new/g
+     在文件內替換所有的字符串 old 為新的字符串 new,請輸入  :%s/old/new/g
+     進行全文替換時詢問用戶確認每個替換需添加 c 選項,請輸入 :%s/old/new/gc
+
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+		第五講第一節︰在 VIM 內執行外部命令的方法
+
+
+	   ** 輸入 :! 然後緊隨著輸入一個外部命令可以執行該外部命令。**
+
+  1. 按下我們所熟悉的 : 命令設置光標到屏幕底部。這樣就可以讓您輸入命令了。
+
+  2. 接著輸入感嘆號 ! 這個字符,這樣就允許您執行外部的 shell 命令了。
+
+  3. 我們以 ls 命令為例。輸入 !ls <回車> 。該命令就會列舉出您當前目錄的
+     內容,就如同您在命令行提示符下輸入 ls 命令的結果一樣。如果 !ls 沒起
+     作用,您可以試試 :!dir 看看。
+
+---> 提示︰ 所有的外部命令都可以以這種方式執行。
+
+---> 提示︰ 所有的 : 命令都必須以 <回車> 告終。
+
+
+
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+		      第五講第二節︰關于保存文件的更多信息
+
+
+	     ** 要將對文件的改動保存到文件中,請輸入 :w FILENAME **
+
+  1. 輸入 :!dir 或者 :!ls 獲知當前目錄的內容。您應當已知道最後還得敲
+     <回車> 吧。
+
+  2. 選擇一個尚未存在文件名,比如 TEST 。
+
+  3. 接著輸入 :w TEST  (此處 TEST 是您所選擇的文件名。)
+
+  4. 該命令會以 TEST 為文件名保存整個文件 (VIM 教程)。為了確保正確保存,
+     請再次輸入 :!dir 查看您的目錄列表內容。
+
+---> 請注意︰如果您退出 VIM 然後在以文件名 TEST 為參數進入,那麼該文件內
+     容應該同您保存時的文件內容是完全一樣的。
+
+  5. 現在您可以通過輸入 :!rm TEST 來刪除 TEST 文件了。
+
+
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+		    第五講第三節︰一個具有選擇性的保存命令
+
+
+		** 要保存文件的部分內容,請輸入 :#,# w FILENAME **
+
+  1. 再來執行一次 :!dir 或者 :!ls 獲知當前目錄的內容,然後選擇一個合適的
+     不重名的文件名,比如 TEST 。
+
+  2. 接著將光標移動至本頁的最頂端,然後按 CTRL-g 找到該行的行號。別忘了
+     行號哦。
+
+  3. 接著把光標移動至本頁的最底端,再按一次 CTRL-g 。也別忘了這個行好哦。
+
+  4. 為了只保存文章的某個部分,請輸入 :#,# w TEST 。這裡的 #,# 就是上面
+     要求您記住的行號(頂端行號,底端行號),而 TEST 就是選定的文件名。
+
+  5. 最後,用 :!dir 確認文件是否正確保存。但是這次先別刪除掉。
+
+
+
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+		   第五講第四節︰提取和合並文件
+
+
+       ** 要向當前文件中插入另外的文件的內容,請輸入 :r FILENAME **
+
+  1. 請鍵入 :!dir 確認您前面創建的 TEST 文件還在。
+
+  2. 然後將光標移動至當前頁面的頂端。
+
+特別提示︰ 執行步驟3之後您將看到第五講第三節,請屆時再往下移動回到這裡來。
+
+  3. 接著通過 :r TEST 將前面創建的名為 TEST 的文件提取進來。
+
+特別提示︰您所提取進來的文件將從光標所在位置處開始置入。
+
+  4. 為了確認文件已經提取成功,移動光標回到原來的位置就可以注意有兩份第
+     五講第三節,一份是原本,另外一份是來自文件的副本。
+
+
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+			       第五講小結
+
+
+  1. :!command 用于執行一個外部命令 command。
+
+     請看一些實際例子︰
+	 :!dir		-  用于顯示當前目錄的內容。
+	 :!rm FILENAME	-  用于刪除名為 FILENAME 的文件。
+
+  2. :w FILENAME  可將當前 VIM 中正在編輯的文件保存到名為 FILENAME
+     的文件中。
+
+  3. :#,#w FILENAME 可將當前編輯文件第 # 行至第 # 行的內容保存到文件
+     FILENAME 中。
+
+  4. :r FILENAME 可提取磁盤文件 FILENAME 並將其插入到當前文件的光標位置
+     後面。
+
+
+
+
+
+
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+			 第六講第一節︰打開類命令
+
+
+	 ** 輸入 o 將在光標的下方打開新的一行並進入插入模式。**
+
+  1. 請將光標移動到本節中下面標記有 ---> 的那一行。
+
+  2. 接著輸入小寫的 o 在光標 *下方* 打開新的一行並進入插入模式。
+
+  3. 然後復制標記有 ---> 的行並按 <ESC> 鍵退出插入模式而進入正常模式。
+
+---> After typing  o  the cursor is placed on the open line in Insert mode.
+
+  4. 為了在光標 *上方* 打開新的一行,只需要輸入大寫的 O 而不是小寫的 o
+     就可以了。請在下行測試一下吧。當光標處在在該行上時,按 Shift-O可以
+     在該行上方新開一行。
+
+Open up a line above this by typing Shift-O while the cursor is on this line.
+
+
+
+
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+			第六講第二節︰光標後插入類命令
+
+
+		     ** 輸入 a 將可在光標之後插入文本。 **
+
+  1. 請在正常模式下通過輸入 $ 將光標移動到本節中下面標記有 ---> 的第一行
+     的末尾。
+
+  2. 接著輸入小寫的 a 則可在光標之後插入文本了。大寫的 A 則可以直接在行
+     末插入文本。
+
+提示︰輸入大寫 A 的操作方法可以在行末插入文本,避免了輸入 i,光標定位到
+      最後一個字符,輸入的文本,<ESC> 回復正常模式,箭頭右鍵移動光標以及
+      x 刪除當前光標所在位置字符等等諸多繁雜的操作。
+
+  3. 操作之後第一行就可以補充完整了。請注意光標後插入文本與插入模式是基
+     本完全一致的,只是文本插入的位置定位稍有不同罷了。
+
+---> This line will allow you to practice
+---> This line will allow you to practice appending text to the end of a line.
+
+
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+		    第六講第三節︰另外一個置換類命令的版本
+
+
+		      ** 輸入大寫的 R 可連續替換多個字符。**
+
+  1. 請將光標移動到本節中下面標記有 ---> 的第一行。
+
+  2. 移動光標到第一行中不同于標有 ---> 的第二行的第一個單詞的開始,即單
+     詞 last 處。
+
+  3. 然後輸入大寫的 R 開始把第一行中的不同于第二行的剩余字符逐一輸入,就
+     可以全部替換掉原有的字符而使得第一行完全雷同第二行了。
+
+---> To make the first line the same as the last on this page use the keys.
+---> To make the first line the same as the second, type R and the new text.
+
+  4. 請注意︰如果您按 <ESC> 退出置換模式回復正常模式,尚未替換的文本將仍
+     然保持原狀。
+
+
+
+
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+			    第六講第四節︰設置類命令的選項
+
+
+		  ** 設置可使查找或者替換可忽略大小寫的選項 **
+
+
+  1. 要查找單詞 ignore 可在正常模式下輸入 /ignore 。要重復查找該詞,可以
+     重復按 n 鍵。
+
+  2. 然後設置 ic 選項(ic就是英文忽略大小寫Ignore Case的首字母縮寫詞),即
+     輸入︰
+	:set ic
+
+  3. 現在可以通過鍵入 n 鍵再次查找單詞 ignore。重復查找可以重復鍵入 n 鍵。
+
+  4. 然後設置 hlsearch 和 incsearch 這兩個選項,輸入以下內容︰
+     :set hls is
+
+  5. 現在可以再次輸入查找命令,看看會有什麼效果︰
+     /ignore
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+			       第六講小結
+
+
+  1. 輸入小寫的 o 可以在光標下方打開新的一行並將光標置于新開的行首,進入
+     插入模式。
+     輸入大寫的 O 可以在光標上方打開新的一行並將光標置于新開的行首,進入
+     插入模式。
+
+  2. 輸入小寫的 a 可以在光標所在位置之後插入文本。
+     輸入大寫的 A 可以在光標所在行的行末之後插入文本。
+
+  3. 輸入大寫的 R 將進入替換模式,直至按 <ESC> 鍵退出替換模式而進入正常
+     模式。
+
+  4. 輸入 :set xxx 可以設置 xxx 選項。
+
+
+
+
+
+
+
+
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+		       第七講︰在線幫助命令
+
+		      ** 使用在線幫助系統 **
+
+  Vim 擁有一個細致全面的在線幫助系統。要啟動該幫助系統,請選擇如下三種方
+  法之一︰
+	- 按下 <HELP> 鍵 (如果鍵盤上有的話)
+	- 按下 <F1> 鍵 (如果鍵盤上有的話)
+	- 輸入	:help <回車>
+
+  輸入 :q <回車> 可以關閉幫助窗口。
+
+  提供一個正確的參數給":help"命令,您可以找到關于該主題的幫助。請試驗以
+  下參數(可別忘了按回車鍵哦。:)︰
+
+	  :help w <回車>
+	  :help c_<T <回車>
+	  :help insert-index <回車>
+	  :help user-manual <回車>
+
+
+
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+		      第八講︰創建一個啟動腳本
+
+			 ** 啟用vim的功能 **
+
+  Vim的功能特性要比vi多得多,但大部分功能都沒有缺省激活。為了啟動更多的
+  功能,您得創建一個vimrc文件。
+
+  1. 開始編輯vimrc文件,這取決于您所使用的操作系統︰
+
+     :edit ~/.vimrc		這是Unix系統所使用的命令
+     :edit $VIM/_vimrc		這是Windows系統所使用的命令
+
+  2. 接著導入vimrc范例文件︰
+
+     :read $VIMRUNTIME/vimrc_example.vim
+
+  3. 保存文件,命令為︰
+
+     :write
+
+  在下次您啟動vim的時候,編輯器就會有了語法高亮的功能。您可以繼續把您喜
+  歡的其它功能設置添加到這個vimrc文件中。
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+  vim 教程到此結束。本教程只是為了簡明地介紹一下vim編輯器,但已足以讓您
+  很容易學會使用本編輯器了。毋庸質疑,vim還有很多很多的命令,本教程所介
+  紹的還差得遠著呢。所以您要精通的話,還望繼續努力哦。下一步您可以閱讀
+  vim手冊,使用的命令是︰
+	:help user-manual
+
+  為了更進一步的參考和學習,以下這本書值得推薦︰
+
+	Vim - Vi Improved - 作者︰Steve Oualline
+	出版社︰New Riders
+
+  這是第一本完全講解vim的書籍。對于初學者特別有用。其中還包含有大量實例
+  和圖示。欲知詳情,請訪問 http://iccf-holland.org/click5.html
+
+  以下這本書比較老了而且內容主要是vi而不是vim,但是也值得推薦︰
+
+	Learning the Vi Editor - 作者︰Linda Lamb
+	出版社︰O'Reilly & Associates Inc.
+
+  這是一本不錯的書,通過它您幾乎能夠了解到全部vi能夠做到的事情。此書的第
+  六個版本也包含了一些關于vim的信息。
+
+  本教程是由來自Calorado School of Minese的Michael C. Pierce、Robert K.
+  Ware 所編寫的,其中來自Colorado State University的Charles Smith提供了
+  很多創意。編者通信地址是︰
+
+	bware@mines.colorado.edu
+
+  本教程已由Bram Moolenaar專為vim進行修訂。
+
+
+
+  譯制者附言︰
+  ===========
+      簡體中文教程翻譯版之譯制者為梁昌泰 <beos@turbolinux.com.cn>,還有
+      另外一個聯系地址︰linuxrat@gnuchina.org。
+
+      繁體中文教程是從簡體中文教程翻譯版使用 Debian GNU/Linux 中文項目小
+      組的于廣輝先生編寫的中文漢字轉碼器  autoconvert 轉換而成的,並對轉
+      換的結果做了一些細節的改動。
+
+  變更記錄︰
+  =========
+      2002年08月30日 梁昌泰 <beos@turbolinux.com.cn>
+      感謝 RMS@SMTH 的指正,將多處錯誤修正。
+
+      2002年04月22日 梁昌泰 <linuxrat@gnuchina.org>
+      感謝 xuandong@sh163.net 的指正,將兩處錯別字修正。
+
+      2002年03月18日 梁昌泰 <linuxrat@gnuchina.org>
+      根據Bram Molenaar先生在2002年03月16日的來信要求,將vimtutor1.4中譯
+      版升級到vimtutor1.5。
+
+      2001年11月15日 梁昌泰 <linuxrat@gnuchina.org>
+      將vimtutor1.4中譯版提交給Bram Molenaar和Sven Guckes。
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~