sponsor Vim development Vim logo Vim Book Ad

basic Tip #932: Autojump to ( when entering ), then jump back. Handy for Lisp.

 tip karma   Rating 4/9, Viewed by 1146 

Read and edit this tip on the Vim tip wiki. The wiki may have a more recent version of this tip.

created:   May 20, 2005 15:38      complexity:   basic
author:   Rory McCann      as of Vim:   5.7

Entering the following mapping will make writing lisp code (as well as other code) much easier:

imap ) )<esc>%:300sleep m<enter>%a

Whenever you type in a ) in insert mode, the cursor will jump to the corresponding (, then jump back 300 milliseconds later.

 rate this tip  Life Changing Helpful Unfulfilling 

<< STL (Standard Template Library/C++) help via tags. | search the web for  text selected in vim. >>

Additional Notes

Sunita, May 20, 2005 16:27
You can also use this

'showmatch' 'sm' boolean (default off)

When a bracket is inserted, briefly jump to the matching one. The
jump is only done if the match can be seen on the screen.  The time to
show the match can be set with 'matchtime'.
A Beep is given if there is no match (no matter if the match can be
seen or not).  This option is reset when the 'paste' option is set.
When the 'm' flag is not included in 'cpoptions', typing a character
will immediately move the cursor back to where it belongs.
See the "sm" field in 'guicursor' for setting the cursor shape and
blinking when showing the match.                      
Ivan Tishchenko, May 23, 2005 2:08
But anyway thanks for mentioning :sleep.  I didn't know about it.
inside@parasiterecords.com, May 23, 2005 5:22
set showmatch does the same
NdrOchip@ScampbellPfamily.AbizM - NOSPAM, May 26, 2005 6:56
On a related note, HiMtchBrkt.vim, available at http://mysite.verizon.net/astronaut/vim/index.html#VimFuncs under
"Highlighting Matching Brackets" will (after enabling with \[i), when the cursor is on one bracket ([{}]) specially
highlight the matching bracket.  (see vimtip#177 for more on this)

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Sponsored by Web Concept Group Inc. SourceForge.net Logo