[vim] Correctly matching paren

This is a discussion on [vim] Correctly matching paren within the Editors forums in Theory and Concepts category; Consider this made-up (shortened from a real world case) example for paren matching: response.write("funct1(x,funct2(){") response.write("})") Number the paren: 1 2 34 5 response.write("funct1(x,funct2(){") response.write("})") 6 7 8 (which will probably not be aligned properly after posting, but you get the idea.) Now when I place the cursor over paren 7 in Vim, it indicates, incorrectly, that paren 6 matches it. In Emacs, it correctly identifies paren 2. Not meaning to start a holy war, but am I doing something wrong in Vim?...

Go Back   Application Development Forum > Theory and Concepts > Editors

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 08-25-2008, 06:02 PM
Charles M
Guest
 
Default [vim] Correctly matching paren

Consider this made-up (shortened from a real world case) example for paren matching:

response.write("funct1(x,funct2(){")
response.write("})")

Number the paren:

1 2 34 5
response.write("funct1(x,funct2(){")
response.write("})")
6 7 8

(which will probably not be aligned properly after posting, but you get the idea.)

Now when I place the cursor over paren 7 in Vim, it indicates, incorrectly, that
paren 6 matches it. In Emacs, it correctly identifies paren 2.

Not meaning to start a holy war, but am I doing something wrong in Vim?
Reply With Quote
  #2  
Old 08-25-2008, 07:00 PM
Stefan Weiss
Guest
 
Default Re: [vim] Correctly matching paren

On 2008-08-26 00:02, Charles M wrote:
> Now when I place the cursor over paren 7 in Vim, it indicates, incorrectly, that
> paren 6 matches it. In Emacs, it correctly identifies paren 2.


Just out of interest, how is matching a closing parenthesis from one
string to an opening parenthesis in another string correct? In your
example it would be, obviously, but unless the strings are parsed for
syntax, how could an editor know if their contents are significant?

For example, how does Emacs match the parens in this case?

response.write("funct1(x,funct2(){");
log.write("I feel sad :-(");
response.write("})");

or

response.write("funct1(x,funct2(){");
log.write("I feel sad :-({");
response.write("})");

On the other hand, I'm always amazed at what cleverly designed editors
can do, and Emacs's behavior here is certainly worse than Vim's. FWIW,
if you use the % key on paren 7 in your example, the cursor doesn't jump
anywhere, which is what I would expect. But you're right, the
highlighting is off.

Stefan


PS: I have "let loaded_matchparen = 1" in my .vimrc, because paren
matching confused me more than it helped, and I don't write much LISP :-)
Reply With Quote
  #3  
Old 08-28-2008, 08:41 PM
Stefan Weiss
Guest
 
Default Re: [vim] Correctly matching paren

On 2008-08-26 01:00, Stefan Weiss wrote:
> and Emacs's behavior here is certainly worse than Vim's.


I'm very sorry, that should have read "Emacs's behaviour is certainly
*better* than Vim's". I honestly don't want to start or participate in
any flame wars either... I didn't use Emacs much in the past 8 years,
but in this case it looks like Emacs did a better job (even though I
don't understand how).

I would also be interested in more opinions on this topic.

stefan
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 05:02 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.