3 ms·
Vi has % to jump to a matching parenthesis as pretty ancient feature. It's in POSIX: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/vi.html#tag_20_1
by kazinator 8y ago
Vi has % to jump to a matching parenthesis as pretty ancient feature. It's in POSIX:
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/vi.html#tag_20_152_13_21 http://pubs.opengroup.org/onlinepubs/9699919799/utilities/vi...
Of course % is a movement that combines with commands like deletion: d%.
The original vi also has a Lisp mode (not described in POSIX) for indentation; that is of course in Vim also.
All the code you see here was written using little more than indentation via Lisp mode and % for paren matching:
http://www.kylheku.com/cgit/txr/tree/share/txr/stdlib http://www.kylheku.com/cgit/txr/tree/share/txr/stdlib
Though I work with syntax coloring and sometimes use Vim features like visual selection.
- m45t3r 8y ago> Vi has % to jump to a matching parenthesis as pretty ancient feature. I know. It helps, but it is far from being good enough. Making things like slurp is still a pain without proper editor support, and this is very common to do in Lisp. > All the code you see here was written using little more than indentation via Lisp mode and % for paren matching: Yeah, and K&R written Unix with only ed. My point still is valid: Nix is more readable than Lisp without proper editor support.
- kazinator 8y agoAlso, any half decent Lisp dialect can tell you where an unbalanced parenthesis lies; you shouldn't have any difficulties hunting for this in a large file. $ txr unbal.tl unbal.tl:8: syntax error unbal.tl:8: unterminated expression unbal.tl:8: while parsing form starting at line 5 $ pr -Tn unbal.tl 1 (defun foo() 2 3 ) 4 5 (defun bar() 6 (let (x) 7 )
- m45t3r 8y agoI don't think this is a great error message. I use Clojure everyday and I still had to look 2 times to find the error. If it was something like this, this would be much better: Unmatched parenthesis from starting at line 5. Maybe you wanted to do something like this? 1 (defun foo() 2 3 ) 4 5 (defun bar() 6 (let (x) 7 ) ^ This being a very basic code. In reality you will have multiple function calls inside more complicated functions (like a package definition in Guix), so you will end closing 10+ parenthesis and catching them can be hell.