[comp.editors] VI showmatch option

cornily@cnetlu.UUCP (Cornily) (10/23/89)

I'm using VI for typing Spoke programs. This programming language, based
on Common-Lisp, uses '[' and ']' characters as expression delimiters.
I'd like to get the showmatch possibility for those characters. Now, it
seems to work only on '(' and ')' characters. Any solution ?
   Please, respond in this newsgroup. Thanks for advance.
Jean-Michel CORNILY.
Centre National d'Etudes des Telecommunications - Lannion - France

maart@cs.vu.nl (Maarten Litmaath) (10/24/89)

cornily@cnetlu.UUCP (Cornily) writes:
\... '[' and ']' characters as expression delimiters.
\I'd like to get the showmatch possibility for those characters. Now, it
\seems to work only on '(' and ')' characters. Any solution ?

`{' and `}' are handled too.
The following is a work-around for `[' and `]':

	map! ] ^V^V]^[%a ^H^[%a

(^V = ctrl-V, ^[ = escape, ^H = ctrl-H)
Note: when typed from within vi (using :map!), every one of the
abovementioned control characters has to be escaped with another ^V.

Explanation:

	^V^V]		- the double ^V will become a single one in the map;
			  when the `]' you typed is expanded, this ^V will
			  prevent the `]' in the map from being expanded too
			  (which would lead to a recursive macro)
	^[		- end insert mode
	%		- go to the match of `]'
	a ^H^[		- append a space, backspace to the point of insertion,
			  end append mode, i.e. nothing is appended; this
			  command sequence only serves to keep the cursor near
			  the matching `[' for a moment - you might want to
			  use a longer sequence
	%		- go to the match of the `[', i.e. the `]' you typed
	a		- re-enter append mode

Bug: if there's no match, the first `%' will fail, which will end the macro
expansion, i.e. the macro won't put you back into append mode.
-- 
A symbolic link is a POINTER to a file, | Maarten Litmaath @ VU Amsterdam:
 a hard link is the file system's GOTO. | maart@cs.vu.nl, mcsun!botter!maart