help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: jump between if-fi


From: reader
Subject: Re: jump between if-fi
Date: Tue, 01 Jan 2008 09:47:35 -0600
User-agent: Gnus/5.110007 (No Gnus v0.7) Emacs/22.1 (gnu/linux)

"Lennart Borgman (gmail)" <address@hidden> writes:

> address@hidden wrote:
>> I hope this isn't one of those things that is just plain obvious to
>> lookup in emacs but I'm striking out with M-x apropos
>>
>> How can I make emacs do something similar with if-fi constructs as it
>> does with parens?
>>
>> Even better I'd like the kind of behaviour one can get in vim with
>> parens, where not only does the syntax coloring show the other paren
>> but you can jump there with a Ctrl-%
>


> Maybe you mean %, not C-%?
>
> You can in Emacs too, using Viper. But see
>
>   http://www.emacswiki.org/cgi-bin/wiki/ViKeys
>   http://www.emacswiki.org/cgi-bin/wiki/ViAndEmacs
>

Sorry I missed it in that first link you provided but
Turns out to be right in the emacs FAQ.   I repost it here incase
people searching these forms should hit this thread.

I didn't really like the idea of turning on a whole vi like mode and I
guess a good number of others didn't either.

>From the emacs FAQ

   * Here is some Emacs Lisp that will make the <%> key show the
     matching parenthesis, like in `vi'.  In addition, if the cursor
     isn't over a parenthesis, it simply inserts a % like normal.

          ;; By an unknown contributor

          (global-set-key "%" 'match-paren)

          (defun match-paren (arg)
            "Go to the matching paren if on a paren; otherwise insert %."
            (interactive "p")
            (cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1))
                  ((looking-at "\\s\)") (forward-char 1) (backward-list 1))
                  (t (self-insert-command (or arg 1)))))






reply via email to

[Prev in Thread] Current Thread [Next in Thread]