Vim Tips Wiki
(Move categories to tip template)
(Remove html character entities)
 
Line 17: Line 17:
 
Basically, I set it up so that when you're in perl and have a non keyword charcter, (except for @, $ and % for perl) and you type a { you get:
 
Basically, I set it up so that when you're in perl and have a non keyword charcter, (except for @, $ and % for perl) and you type a { you get:
 
{
 
{
| <- cursor
+
| <- cursor
 
}
 
}
   
Line 28: Line 28:
   
 
Finally, I made it so that, using the alt key,
 
Finally, I made it so that, using the alt key,
* &lt;Alt-'&gt; inserts a '
+
* <Alt-'> inserts a '
* &lt;Alt-/&gt; inserts a "
+
* <Alt-/> inserts a "
* &lt;Alt-[&gt; inserts a [
+
* <Alt-[> inserts a [
* &lt;Alt-]&gt; inserts a ]
+
* <Alt-]> inserts a ]
* &lt;Alt--&gt; inserts a {
+
* <Alt--> inserts a {
* &lt;Alt-=&gt; inserts a }
+
* <Alt-=> inserts a }
* &lt;Alt-,&gt; inserts a &lt;
+
* <Alt-,> inserts a <
* &lt;Alt-.&gt; inserts a &gt;
+
* <Alt-.> inserts a >
   
 
<pre>
 
<pre>
Line 44: Line 44:
 
" hashes
 
" hashes
 
function! InsertBrackets()
 
function! InsertBrackets()
let fileType = &amp;ft
+
let fileType = &ft
 
if fileType == 'perl'
 
if fileType == 'perl'
 
let col = col('.') - 1
 
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k' &amp;&amp; getline('.')[col - 1] !~ '\$' &amp;&amp; getline('.')[col - 1] !~ '@' &amp;&amp; getline('.')[col - 1] !~ '%' &amp;&amp; getline('.')[col - 1] !~ '#'
+
if !col || getline('.')[col - 1] !~ '\k' && getline('.')[col - 1] !~ '\$' && getline('.')[col - 1] !~ '@' && getline('.')[col - 1] !~ '%' && getline('.')[col - 1] !~ '#'
return "{\&lt;cr&gt;\&lt;bs&gt;}\&lt;esc&gt;ko"
+
return "{\<CR>\<BS>}\<Esc>ko"
 
else
 
else
return "{}\&lt;esc&gt;i\&lt;c-o&gt;:echo \&lt;cr&gt;"
+
return "{}\<Esc>i\<c-o>:echo \<CR>"
 
endif
 
endif
 
else
 
else
return "{\&lt;cr&gt;\&lt;bs&gt;}\&lt;esc&gt;ko"
+
return "{\<CR>\<BS>}\<Esc>ko"
 
endif
 
endif
 
endfunction
 
endfunction
Line 59: Line 59:
 
" This code jumps out of the brackets
 
" This code jumps out of the brackets
 
function! JumpNext(startChar, endChar)
 
function! JumpNext(startChar, endChar)
let ret1 = "\&lt;esc&gt;:echo searchpair('".a:startChar."','','".a:endChar."','W','synIDattr(synID(line(\".\"), col(\".\"), 0), \"name\") =~? \"string\"')\&lt;cr&gt;i\&lt;right&gt;"
+
let ret1 = "\<Esc>:echo searchpair('".a:startChar."','','".a:endChar."','W','synIDattr(synID(line(\".\"), col(\".\"), 0), \"name\") =~? \"string\"')\<CR>i\<Right>"
 
return ret1
 
return ret1
 
endfunction
 
endfunction
   
 
" mappings
 
" mappings
inoremap " ""&lt;esc&gt;i&lt;c-o&gt;:echo &lt;cr&gt;
+
inoremap " ""<Esc>i<c-o>:echo <CR>
inoremap ' ''&lt;esc&gt;i&lt;c-o&gt;:echo &lt;cr&gt;
+
inoremap ' ''<Esc>i<c-o>:echo <CR>
inoremap &lt; &lt;&gt;&lt;esc&gt;i&lt;c-o&gt;:echo &lt;cr&gt;
+
inoremap < <><Esc>i<c-o>:echo <CR>
inoremap ( ()&lt;esc&gt;i&lt;c-o&gt;:echo &lt;cr&gt;
+
inoremap ( ()<Esc>i<c-o>:echo <CR>
inoremap [ []&lt;esc&gt;i&lt;c-o&gt;:echo &lt;cr&gt;
+
inoremap [ []<Esc>i<c-o>:echo <CR>
inoremap { &lt;c-r&gt;=InsertBrackets ()&lt;cr&gt;
+
inoremap { <c-r>=InsertBrackets ()<CR>
inoremap &gt; &lt;c-r&gt;=JumpNext("&lt;","&gt;")&lt;cr&gt;
+
inoremap > <c-r>=JumpNext("<",">")<CR>
inoremap ) &lt;c-r&gt;=JumpNext("(",")")&lt;cr&gt;
+
inoremap ) <c-r>=JumpNext("(",")")<CR>
inoremap ] &lt;c-r&gt;=JumpNext("[","]")&lt;cr&gt;
+
inoremap ] <c-r>=JumpNext("[","]")<CR>
inoremap } &lt;c-r&gt;=JumpNext("{","}")&lt;cr&gt;
+
inoremap } <c-r>=JumpNext("{","}")<CR>
inoremap &lt;m--&gt; [
+
inoremap <m--> [
inoremap &lt;m-=&gt; ]
+
inoremap <m-=> ]
inoremap &lt;m-/&gt; "
+
inoremap <m-/> "
inoremap &lt;m-[&gt; {
+
inoremap <m-[> {
inoremap &lt;m-]&gt; }
+
inoremap <m-]> }
inoremap &lt;m-,&gt; &lt;
+
inoremap <m-,> <
inoremap &lt;m-.&gt; &gt;
+
inoremap <m-.> >
inoremap &lt;m-9&gt; (
+
inoremap <m-9> (
inoremap &lt;m-0&gt; )
+
inoremap <m-0> )
inoremap &lt;m-'&gt; '
+
inoremap <m-'> '
 
</pre>
 
</pre>
   
Line 95: Line 95:
 
if !exists('b:edithelpers_on') || b:edithelpers_on == 0
 
if !exists('b:edithelpers_on') || b:edithelpers_on == 0
 
let b:edithelpers_on=1
 
let b:edithelpers_on=1
inoremap '' ''&lt;esc&gt;i
+
inoremap '' ''<Esc>i
 
inoremap ''' '''
 
inoremap ''' '''
 
inoremap """ """
 
inoremap """ """
inoremap "" ""&lt;esc&gt;i
+
inoremap "" ""<Esc>i
inoremap &lt;&gt; &lt;&gt;&lt;esc&gt;i
+
inoremap <> <><Esc>i
inoremap [] []&lt;esc&gt;i
+
inoremap [] []<Esc>i
inoremap () ()&lt;esc&gt;i
+
inoremap () ()<Esc>i
inoremap {} {}&lt;esc&gt;i
+
inoremap {} {}<Esc>i
cnoremap '' ''&lt;Left&gt;
+
cnoremap '' ''<Left>
 
cnoremap ''' '''
 
cnoremap ''' '''
 
cnoremap """ """
 
cnoremap """ """
cnoremap "" ""&lt;Left&gt;
+
cnoremap "" ""<Left>
cnoremap &lt;&gt; &lt;&gt;&lt;Left&gt;
+
cnoremap <> <><Left>
cnoremap [] []&lt;Left&gt;
+
cnoremap [] []<Left>
cnoremap () ()&lt;Left&gt;
+
cnoremap () ()<Left>
cnoremap {} {}&lt;Left&gt;
+
cnoremap {} {}<Left>
 
else
 
else
 
let b:edithelpers_on=0
 
let b:edithelpers_on=0
Line 117: Line 117:
 
iunmap """
 
iunmap """
 
iunmap ""
 
iunmap ""
iunmap &lt;&gt;
+
iunmap <>
 
iunmap []
 
iunmap []
 
iunmap ()
 
iunmap ()
Line 125: Line 125:
 
cunmap """
 
cunmap """
 
cunmap ""
 
cunmap ""
cunmap &lt;&gt;
+
cunmap <>
 
cunmap []
 
cunmap []
 
cunmap ()
 
cunmap ()
Line 132: Line 132:
 
endfun
 
endfun
 
" Allow to be easily switched on and off.
 
" Allow to be easily switched on and off.
nnoremap &lt;silent&gt;&lt;F9&gt; :call &lt;SID&gt;Toggle_EditHelpers()&lt;CR&gt;
+
nnoremap <silent><F9> :call <SID>Toggle_EditHelpers()<CR>
vnoremap &lt;silent&gt;&lt;F9&gt; &lt;C-C&gt;:call &lt;SID&gt;Toggle_EditHelpers()&lt;CR&gt;
+
vnoremap <silent><F9> <C-C>:call <SID>Toggle_EditHelpers()<CR>
inoremap &lt;silent&gt;&lt;F9&gt; &lt;C-O&gt;:call &lt;SID&gt;Toggle_EditHelpers()&lt;CR&gt;
+
inoremap <silent><F9> <C-O>:call <SID>Toggle_EditHelpers()<CR>
 
" turn on by default
 
" turn on by default
:call &lt;SID&gt;Toggle_EditHelpers()
+
:call <SID>Toggle_EditHelpers()
 
</pre>
 
</pre>
   
Line 145: Line 145:
 
" This code jumps out of the brackets
 
" This code jumps out of the brackets
 
function! JumpNext(startChar, endChar,oneItem)
 
function! JumpNext(startChar, endChar,oneItem)
let ret1 = "\&lt;esc&gt;:if \"0\"==searchpair('".a:startChar."','','".a:endChar."','W','synIDattr(synID(line(\".\"), col(\".\"), 0), \"name\") =~? \"string\"')\&lt;cr&gt;exec(\"normal i".a:oneItem."\")\&lt;cr&gt;endif\&lt;cr&gt;i\&lt;right&gt;"
+
let ret1 = "\<Esc>:if \"0\"==searchpair('".a:startChar."','','".a:endChar."','W','synIDattr(synID(line(\".\"), col(\".\"), 0), \"name\") =~? \"string\"')\<CR>exec(\"normal i".a:oneItem."\")\<CR>endif\<CR>i\<Right>"
 
return ret1
 
return ret1
 
endfunction
 
endfunction
   
 
" mappings
 
" mappings
inoremap &gt; &lt;c-r&gt;=JumpNext("&lt;","&gt;","\&lt;m-.&gt;")&lt;cr&gt;
+
inoremap > <c-r>=JumpNext("<",">","\<m-.>")<CR>
inoremap ) &lt;c-r&gt;=JumpNext("(",")","\&lt;m-0&gt;")&lt;cr&gt;
+
inoremap ) <c-r>=JumpNext("(",")","\<m-0>")<CR>
inoremap ] &lt;c-r&gt;=JumpNext("[","]","\&lt;m-=&gt;")&lt;cr&gt;
+
inoremap ] <c-r>=JumpNext("[","]","\<m-=>")<CR>
inoremap } &lt;c-r&gt;=JumpNext("{","}","\&lt;m-]&gt;")&lt;cr&gt;
+
inoremap } <c-r>=JumpNext("{","}","\<m-]>")<CR>
 
</pre>
 
</pre>
   
 
----
 
----
My only guess is that your escape char is &lt;m-[&gt; Changing that binding may fix your problem.
+
My only guess is that your escape char is <m-[> Changing that binding may fix your problem.
   
 
Here's an update, with toggle, and the toggle should let your escape work again:
 
Here's an update, with toggle, and the toggle should let your escape work again:
Line 168: Line 168:
 
" correctly with hashes.
 
" correctly with hashes.
 
function! InsertBrackets()
 
function! InsertBrackets()
let fileType = &amp;ft
+
let fileType = &ft
 
if fileType == 'perl'
 
if fileType == 'perl'
 
let col = col('.') - 1
 
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k' &amp;&amp; getline('.')[col - 1] !~ '\$' &amp;&amp; getline('.')[col - 1] !~ '@' &amp;&amp; getline('.')[col - 1] !~ '%' &amp;&amp; getline('.')[col - 1] !~ '#'
+
if !col || getline('.')[col - 1] !~ '\k' && getline('.')[col - 1] !~ '\$' && getline('.')[col - 1] !~ '@' && getline('.')[col - 1] !~ '%' && getline('.')[col - 1] !~ '#'
return "{\&lt;cr&gt;\&lt;bs&gt;}\&lt;esc&gt;ko"
+
return "{\<CR>\<BS>}\<Esc>ko"
 
else
 
else
return "{}\&lt;esc&gt;i\&lt;c-o&gt;:echo \&lt;cr&gt;"
+
return "{}\<Esc>i\<c-o>:echo \<CR>"
 
endif
 
endif
 
else
 
else
return "{\&lt;cr&gt;\&lt;bs&gt;}\&lt;esc&gt;ko"
+
return "{\<CR>\<BS>}\<Esc>ko"
 
endif
 
endif
 
endfunction
 
endfunction
Line 183: Line 183:
 
" This code jumps out of the brackets
 
" This code jumps out of the brackets
 
function! JumpNext(startChar, endChar,oneItem)
 
function! JumpNext(startChar, endChar,oneItem)
let ret1 = "\&lt;esc&gt;:if \"0\"==searchpair('".a:startChar."','','".a:endChar."','W','synIDattr(synID(line(\".\"), col(\".\"), 0), \"name\") =~? \"string\"')\&lt;cr&gt;exec(\"normal i".a:oneItem."\")\&lt;cr&gt;endif\&lt;cr&gt;i\&lt;right&gt;"
+
let ret1 = "\<Esc>:if \"0\"==searchpair('".a:startChar."','','".a:endChar."','W','synIDattr(synID(line(\".\"), col(\".\"), 0), \"name\") =~? \"string\"')\<CR>exec(\"normal i".a:oneItem."\")\<CR>endif\<CR>i\<Right>"
 
return ret1
 
return ret1
 
endfunction
 
endfunction
Line 189: Line 189:
 
" Added toggle.
 
" Added toggle.
 
fun! s:Toggle_Edit2()
 
fun! s:Toggle_Edit2()
if exists('b:edithelpers_on') &amp;&amp; b:edithelpers_on == 1
+
if exists('b:edithelpers_on') && b:edithelpers_on == 1
 
if (!exists('b:edithelpers2_on') || b:edithelpers2_on == 0)
 
if (!exists('b:edithelpers2_on') || b:edithelpers2_on == 0)
 
let b:edithelpers2_on=1
 
let b:edithelpers2_on=1
 
" mappings
 
" mappings
inoremap &gt; &lt;c-r&gt;=JumpNext("&lt;","&gt;","\&lt;m-.&gt;")&lt;cr&gt;
+
inoremap > <c-r>=JumpNext("<",">","\<m-.>")<CR>
inoremap ) &lt;c-r&gt;=JumpNext("(",")","\&lt;m-0&gt;")&lt;cr&gt;
+
inoremap ) <c-r>=JumpNext("(",")","\<m-0>")<CR>
inoremap ] &lt;c-r&gt;=JumpNext("[","]","\&lt;m-=&gt;")&lt;cr&gt;
+
inoremap ] <c-r>=JumpNext("[","]","\<m-=>")<CR>
inoremap } &lt;c-r&gt;=JumpNext("{","}","\&lt;m-]&gt;")&lt;cr&gt;
+
inoremap } <c-r>=JumpNext("{","}","\<m-]>")<CR>
inoremap &lt;m-=&gt; ]
+
inoremap <m-=> ]
inoremap &lt;m-]&gt; }
+
inoremap <m-]> }
inoremap &lt;m-.&gt; &gt;
+
inoremap <m-.> >
inoremap &lt;m-0&gt; )
+
inoremap <m-0> )
 
else
 
else
 
let b:edithelpers2_on=0
 
let b:edithelpers2_on=0
iunmap &gt;
+
iunmap >
 
iunmap )
 
iunmap )
 
iunmap ]
 
iunmap ]
 
iunmap }
 
iunmap }
iunmap &lt;m-=&gt;
+
iunmap <m-=>
iunmap &lt;m-]&gt;
+
iunmap <m-]>
iunmap &lt;m-.&gt;
+
iunmap <m-.>
iunmap &lt;m-0&gt;
+
iunmap <m-0>
 
endif
 
endif
 
endif
 
endif
Line 220: Line 220:
 
let b:edithelpers_on=1
 
let b:edithelpers_on=1
 
" mappings
 
" mappings
inoremap " ""&lt;esc&gt;i&lt;c-o&gt;:echo &lt;cr&gt;
+
inoremap " ""<Esc>i<c-o>:echo <CR>
inoremap ' ''&lt;esc&gt;i&lt;c-o&gt;:echo &lt;cr&gt;
+
inoremap ' ''<Esc>i<c-o>:echo <CR>
inoremap &lt; &lt;&gt;&lt;esc&gt;i&lt;c-o&gt;:echo &lt;cr&gt;
+
inoremap < <><Esc>i<c-o>:echo <CR>
inoremap ( ()&lt;esc&gt;i&lt;c-o&gt;:echo &lt;cr&gt;
+
inoremap ( ()<Esc>i<c-o>:echo <CR>
inoremap [ []&lt;esc&gt;i&lt;c-o&gt;:echo &lt;cr&gt;
+
inoremap [ []<Esc>i<c-o>:echo <CR>
inoremap { &lt;c-r&gt;=InsertBrackets ()&lt;cr&gt;
+
inoremap { <c-r>=InsertBrackets ()<CR>
inoremap &lt;m--&gt; [
+
inoremap <m--> [
inoremap &lt;m-/&gt; "
+
inoremap <m-/> "
inoremap &lt;m-[&gt; {
+
inoremap <m-[> {
inoremap &lt;m-,&gt; &lt;
+
inoremap <m-,> <
inoremap &lt;m-9&gt; (
+
inoremap <m-9> (
inoremap &lt;m-'&gt; '
+
inoremap <m-'> '
 
if !exists('b:edithelpers2_on') || b:edithelpers2_on == 0
 
if !exists('b:edithelpers2_on') || b:edithelpers2_on == 0
call &lt;SID&gt;Toggle_Edit2()
+
call <SID>Toggle_Edit2()
 
endif
 
endif
 
else
 
else
 
iunmap "
 
iunmap "
 
iunmap '
 
iunmap '
iunmap &lt;
+
iunmap <
 
iunmap (
 
iunmap (
 
iunmap [
 
iunmap [
 
iunmap {
 
iunmap {
iunmap &lt;m--&gt;
+
iunmap <m-->
iunmap &lt;m-/&gt;
+
iunmap <m-/>
iunmap &lt;m-[&gt;
+
iunmap <m-[>
iunmap &lt;m-,&gt;
+
iunmap <m-,>
iunmap &lt;m-9&gt;
+
iunmap <m-9>
iunmap &lt;m-'&gt;
+
iunmap <m-'>
if exists('b:edithelpers2_on') &amp;&amp; b:edithelpers2_on == 1
+
if exists('b:edithelpers2_on') && b:edithelpers2_on == 1
call &lt;SID&gt;Toggle_Edit2()
+
call <SID>Toggle_Edit2()
 
endif
 
endif
 
let b:edithelpers_on=0
 
let b:edithelpers_on=0
Line 255: Line 255:
 
endfun
 
endfun
   
nnoremap &lt;silent&gt;&lt;F9&gt; :call &lt;SID&gt;Toggle_Edit()&lt;CR&gt;
+
nnoremap <silent><F9> :call <SID>Toggle_Edit()<CR>
inoremap &lt;silent&gt;&lt;F9&gt; &lt;C-O&gt;:call &lt;SID&gt;Toggle_Edit()&lt;CR&gt;
+
inoremap <silent><F9> <C-O>:call <SID>Toggle_Edit()<CR>
call &lt;SID&gt;Toggle_Edit()
+
call <SID>Toggle_Edit()
nnoremap &lt;silent&gt;&lt;F8&gt; :call &lt;SID&gt;Toggle_Edit2()&lt;CR&gt;
+
nnoremap <silent><F8> :call <SID>Toggle_Edit2()<CR>
inoremap &lt;silent&gt;&lt;F8&gt; &lt;C-O&gt;:call &lt;SID&gt;Toggle_Edit2()&lt;CR&gt;
+
inoremap <silent><F8> <C-O>:call <SID>Toggle_Edit2()<CR>
 
" F-8 toggles the jump
 
" F-8 toggles the jump
 
" F-9 toggles the bracketing feature and overrides F-8
 
" F-9 toggles the bracketing feature and overrides F-8
Line 268: Line 268:
   
 
When the function is first called, you get, e.g.,
 
When the function is first called, you get, e.g.,
inoremap " ""&lt;esc&gt;i&lt;c-o&gt;:echo &lt;cr&gt;
+
inoremap " ""<Esc>i<c-o>:echo <CR>
   
 
but by the time you toggle it (calling the fucntion again)
 
but by the time you toggle it (calling the fucntion again)

Latest revision as of 05:35, 29 September 2008

Duplicate tip

This tip is very similar to the following:

These tips need to be merged – see the merge guidelines.

Tip 318 Printable Monobook Previous Next

created August 22, 2002 · complexity intermediate · author Abitkin · version 5.7


This is an extension of VimTip153. I found this tip useful, but the jump seemed out of place for me, I couldn't enter just one ' or ", and so I created an improvement

Basically, I set it up so that when you're in perl and have a non keyword charcter, (except for @, $ and % for perl) and you type a { you get:

{
  | <- cursor
}

Whereas, when I have a keyword I get:

word{}

With the cursor in the middle, for hashes in perl. I can jump out of any block, except the "..." or '...' blocks, by typing their closing character. So } jumps me out past the next } in the file.

Warning, this search may wrap around.

Finally, I made it so that, using the alt key,

  • <Alt-'> inserts a '
  • <Alt-/> inserts a "
  • <Alt-[> inserts a [
  • <Alt-]> inserts a ]
  • <Alt--> inserts a {
  • <Alt-=> inserts a }
  • <Alt-,> inserts a <
  • <Alt-.> inserts a >
" File - matchMe.vim
" Date - Wednesday, August 21, 2002
" This code fixes my problem with
" does the one format for perl and acts correctly with
" hashes
function! InsertBrackets()
  let fileType = &ft
  if fileType == 'perl'
    let col = col('.') - 1
    if !col || getline('.')[col - 1] !~ '\k' && getline('.')[col - 1] !~ '\$' && getline('.')[col - 1] !~ '@' && getline('.')[col - 1] !~ '%' && getline('.')[col - 1] !~ '#'
      return "{\<CR>\<BS>}\<Esc>ko"
    else
      return "{}\<Esc>i\<c-o>:echo \<CR>"
    endif
  else
    return "{\<CR>\<BS>}\<Esc>ko"
  endif
endfunction

" This code jumps out of the brackets
function! JumpNext(startChar, endChar)
  let ret1 = "\<Esc>:echo searchpair('".a:startChar."','','".a:endChar."','W','synIDattr(synID(line(\".\"), col(\".\"), 0), \"name\") =~? \"string\"')\<CR>i\<Right>"
  return ret1
endfunction

" mappings
inoremap " ""<Esc>i<c-o>:echo <CR>
inoremap ' ''<Esc>i<c-o>:echo <CR>
inoremap < <><Esc>i<c-o>:echo <CR>
inoremap ( ()<Esc>i<c-o>:echo <CR>
inoremap [ []<Esc>i<c-o>:echo <CR>
inoremap { <c-r>=InsertBrackets ()<CR>
inoremap > <c-r>=JumpNext("<",">")<CR>
inoremap ) <c-r>=JumpNext("(",")")<CR>
inoremap ] <c-r>=JumpNext("[","]")<CR>
inoremap } <c-r>=JumpNext("{","}")<CR>
inoremap <m--> [
inoremap <m-=> ]
inoremap <m-/> "
inoremap <m-[> {
inoremap <m-]> }
inoremap <m-,> <
inoremap <m-.> >
inoremap <m-9> (
inoremap <m-0> )
inoremap <m-'> '

Comments[]

I used a similar (but mostly far more basic...) set of functions and mappings for my C and Python code, but with a slightly different behavior...

Here is some code I find a bit more convenient (at least for my liking).

fun! s:Toggle_EditHelpers()
  if !exists('b:edithelpers_on') || b:edithelpers_on == 0
    let b:edithelpers_on=1
    inoremap '' ''<Esc>i
    inoremap ''' '''
    inoremap """ """
    inoremap "" ""<Esc>i
    inoremap <> <><Esc>i
    inoremap [] []<Esc>i
    inoremap () ()<Esc>i
    inoremap {} {}<Esc>i
    cnoremap '' ''<Left>
    cnoremap ''' '''
    cnoremap """ """
    cnoremap "" ""<Left>
    cnoremap <> <><Left>
    cnoremap [] []<Left>
    cnoremap () ()<Left>
    cnoremap {} {}<Left>
  else
    let b:edithelpers_on=0
    iunmap ''
    iunmap '''
    iunmap """
    iunmap ""
    iunmap <>
    iunmap []
    iunmap ()
    iunmap {}
    cunmap ''
    cunmap '''
    cunmap """
    cunmap ""
    cunmap <>
    cunmap []
    cunmap ()
    cunmap {}
  endif
endfun
" Allow to be easily switched on and off.
nnoremap <silent><F9> :call <SID>Toggle_EditHelpers()<CR>
vnoremap <silent><F9> <C-C>:call <SID>Toggle_EditHelpers()<CR>
inoremap <silent><F9> <C-O>:call <SID>Toggle_EditHelpers()<CR>
" turn on by default
:call <SID>Toggle_EditHelpers()

One more update. I found this quite useful, as sometimes I delete the ending char, to insert it around a block, and then when I type it again, I just get a flash...

" This code jumps out of the brackets
function! JumpNext(startChar, endChar,oneItem)
 let ret1 = "\<Esc>:if \"0\"==searchpair('".a:startChar."','','".a:endChar."','W','synIDattr(synID(line(\".\"), col(\".\"), 0), \"name\") =~? \"string\"')\<CR>exec(\"normal i".a:oneItem."\")\<CR>endif\<CR>i\<Right>"
 return ret1
endfunction

" mappings
inoremap > <c-r>=JumpNext("<",">","\<m-.>")<CR>
inoremap ) <c-r>=JumpNext("(",")","\<m-0>")<CR>
inoremap ] <c-r>=JumpNext("[","]","\<m-=>")<CR>
inoremap } <c-r>=JumpNext("{","}","\<m-]>")<CR>

My only guess is that your escape char is <m-[> Changing that binding may fix your problem.

Here's an update, with toggle, and the toggle should let your escape work again:

" File - matchMe.vim
" Date - Wednesday, August 21, 2002
" This code fixes my problem with
" does the one format for perl, and acts
" correctly with hashes.
function! InsertBrackets()
  let fileType = &ft
  if fileType == 'perl'
    let col = col('.') - 1
    if !col || getline('.')[col - 1] !~ '\k' && getline('.')[col - 1] !~ '\$' && getline('.')[col - 1] !~ '@' && getline('.')[col - 1] !~ '%' && getline('.')[col - 1] !~ '#'
      return "{\<CR>\<BS>}\<Esc>ko"
    else
      return "{}\<Esc>i\<c-o>:echo \<CR>"
    endif
  else
    return "{\<CR>\<BS>}\<Esc>ko"
  endif
endfunction

" This code jumps out of the brackets
function! JumpNext(startChar, endChar,oneItem)
  let ret1 = "\<Esc>:if \"0\"==searchpair('".a:startChar."','','".a:endChar."','W','synIDattr(synID(line(\".\"), col(\".\"), 0), \"name\") =~? \"string\"')\<CR>exec(\"normal i".a:oneItem."\")\<CR>endif\<CR>i\<Right>"
  return ret1
endfunction

" Added toggle.
fun! s:Toggle_Edit2()
  if exists('b:edithelpers_on') && b:edithelpers_on == 1
    if (!exists('b:edithelpers2_on') || b:edithelpers2_on == 0)
      let b:edithelpers2_on=1
      " mappings
      inoremap > <c-r>=JumpNext("<",">","\<m-.>")<CR>
      inoremap ) <c-r>=JumpNext("(",")","\<m-0>")<CR>
      inoremap ] <c-r>=JumpNext("[","]","\<m-=>")<CR>
      inoremap } <c-r>=JumpNext("{","}","\<m-]>")<CR>
      inoremap <m-=> ]
      inoremap <m-]> }
      inoremap <m-.> >
      inoremap <m-0> )
    else
      let b:edithelpers2_on=0
      iunmap >
      iunmap )
      iunmap ]
      iunmap }
      iunmap <m-=>
      iunmap <m-]>
      iunmap <m-.>
      iunmap <m-0>
    endif
  endif
endfun

" Added toggle.
fun! s:Toggle_Edit()
  if !exists('b:edithelpers_on') || b:edithelpers_on == 0
    let b:edithelpers_on=1
    " mappings
    inoremap " ""<Esc>i<c-o>:echo <CR>
    inoremap ' ''<Esc>i<c-o>:echo <CR>
    inoremap < <><Esc>i<c-o>:echo <CR>
    inoremap ( ()<Esc>i<c-o>:echo <CR>
    inoremap [ []<Esc>i<c-o>:echo <CR>
    inoremap { <c-r>=InsertBrackets ()<CR>
    inoremap <m--> [
    inoremap <m-/> "
    inoremap <m-[> {
    inoremap <m-,> <
    inoremap <m-9> (
    inoremap <m-'> '
    if !exists('b:edithelpers2_on') || b:edithelpers2_on == 0
      call <SID>Toggle_Edit2()
    endif
  else
    iunmap "
    iunmap '
    iunmap <
    iunmap (
    iunmap [
    iunmap {
    iunmap <m-->
    iunmap <m-/>
    iunmap <m-[>
    iunmap <m-,>
    iunmap <m-9>
    iunmap <m-'>
    if exists('b:edithelpers2_on') && b:edithelpers2_on == 1
      call <SID>Toggle_Edit2()
    endif
    let b:edithelpers_on=0
  endif
endfun

nnoremap <silent><F9> :call <SID>Toggle_Edit()<CR>
inoremap <silent><F9> <C-O>:call <SID>Toggle_Edit()<CR>
call <SID>Toggle_Edit()
nnoremap <silent><F8> :call <SID>Toggle_Edit2()<CR>
inoremap <silent><F8> <C-O>:call <SID>Toggle_Edit2()<CR>
" F-8 toggles the jump
" F-9 toggles the bracketing feature and overrides F-8

I think I understand why it doesn't work.

When the function is first called, you get, e.g.,

inoremap " ""<Esc>i<c-o>:echo <CR>

but by the time you toggle it (calling the fucntion again)

iunmap "

It doesn't work because the " is substituted by " " by the interpreter, which is under the influence of the first inoremap, hence the error "No such mapping". I don't know why the interpreter behaves like this, It might be something I have in my .vimrc. Any solutions?